check_zfs_zpool: don't force table critical
This commit is contained in:
parent
6fa48b0fd8
commit
6076d794e1
|
@ -8,6 +8,7 @@ import zfslib as zfs
|
|||
|
||||
from checker import nagios
|
||||
from checker.markdown import list_to_markdown_table
|
||||
from checker.nagios import state_to_txt
|
||||
from checker.units import filesize
|
||||
|
||||
|
||||
|
@ -92,16 +93,18 @@ def check_vdev_devices(vdev_devices: list, critical_free, warning_free, critical
|
|||
states[device['device']] = state
|
||||
return critical, warning, states
|
||||
|
||||
def is_dash(string:str):
|
||||
|
||||
def is_dash(string: str):
|
||||
return string == '-'
|
||||
|
||||
|
||||
def get_vdev_info(zpool: str, vdev_type: str):
|
||||
output_zpool_logs = zpool_list(zpool, vdev_type)
|
||||
zpool_vdev_devices = []
|
||||
for line in list(filter(None, output_zpool_logs.split('\n'))):
|
||||
data = list(filter(None, clean_device_list(line).split(' ')))
|
||||
zpool_vdev_devices.append({
|
||||
'pool': False, # not (is_dash(data[2]) and is_dash(data[3]) and is_dash(data[6]) and is_dash(data[7])),
|
||||
'pool': False, # not (is_dash(data[2]) and is_dash(data[3]) and is_dash(data[6]) and is_dash(data[7])),
|
||||
# TODO: better pool detection
|
||||
|
||||
'device': data[0],
|
||||
|
@ -204,7 +207,7 @@ def main():
|
|||
filesize(pool_status['free'], spaces=False, formatter=False),
|
||||
float_to_percent(pool_status['fragmentation']),
|
||||
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:
|
||||
if isinstance(device['frag'], float):
|
||||
|
|
|
@ -3,3 +3,14 @@ UNKNOWN = STATE_UNKNOWN = -1
|
|||
OK = STATE_OK = 0
|
||||
WARNING = STATE_WARN = 1
|
||||
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'
|
||||
|
|
Loading…
Reference in New Issue