check_zfs_zpool: don't force table critical

This commit is contained in:
Cyberes 2023-07-06 09:44:37 -06:00
parent 6fa48b0fd8
commit 6076d794e1
2 changed files with 17 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import zfslib as zfs
from checker import nagios from checker import nagios
from checker.markdown import list_to_markdown_table from checker.markdown import list_to_markdown_table
from checker.nagios import state_to_txt
from checker.units import filesize from checker.units import filesize
@ -92,9 +93,11 @@ def check_vdev_devices(vdev_devices: list, critical_free, warning_free, critical
states[device['device']] = state states[device['device']] = state
return critical, warning, states return critical, warning, states
def is_dash(string:str):
def is_dash(string: str):
return string == '-' return string == '-'
def get_vdev_info(zpool: str, vdev_type: str): def get_vdev_info(zpool: str, vdev_type: str):
output_zpool_logs = zpool_list(zpool, vdev_type) output_zpool_logs = zpool_list(zpool, vdev_type)
zpool_vdev_devices = [] zpool_vdev_devices = []
@ -204,7 +207,7 @@ def main():
filesize(pool_status['free'], spaces=False, formatter=False), filesize(pool_status['free'], spaces=False, formatter=False),
float_to_percent(pool_status['fragmentation']), float_to_percent(pool_status['fragmentation']),
float_to_percent(pool_status['capacity']), float_to_percent(pool_status['capacity']),
pool_status['health'], f"[{('ok' if exit_code == nagios.OK else 'critical').upper()}]") pool_status['health'], f"[{state_to_txt(exit_code).upper()}]")
] ]
for device in vdev_devices: for device in vdev_devices:
if isinstance(device['frag'], float): if isinstance(device['frag'], float):

View File

@ -3,3 +3,14 @@ UNKNOWN = STATE_UNKNOWN = -1
OK = STATE_OK = 0 OK = STATE_OK = 0
WARNING = STATE_WARN = 1 WARNING = STATE_WARN = 1
CRITICAL = STATE_CRIT = 2 CRITICAL = STATE_CRIT = 2
def state_to_txt(state: int) -> str:
if state == STATE_UNKNOWN:
return 'UNKNOWN'
elif state == STATE_OK:
return 'OK'
elif state == STATE_CRIT:
return 'CRITICAL'
elif state == STATE_WARN:
return 'WARNING'