From 83ac54fa732d6d88edbd24a210b0d61295d67e40 Mon Sep 17 00:00:00 2001 From: Cyberes Date: Mon, 21 Oct 2024 15:44:45 -0600 Subject: [PATCH] check_snology fix --- check_synology.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/check_synology.py b/check_synology.py index 4e11dce..4dbab99 100755 --- a/check_synology.py +++ b/check_synology.py @@ -53,6 +53,28 @@ def check_failed(value: str): return output.lower(), int(value), exit_code +def check_disk_status(value: str): + if value == '1': + exit_code = nagios.STATE_OK + output = 'Normal' + elif value == '2': + exit_code = nagios.STATE_WARN + output = 'Initialized' + elif value == '3': + exit_code = nagios.STATE_WARN + output = 'Not Initialized' + elif value == '4': + exit_code = nagios.STATE_CRIT + output = 'System Partition Failed' + elif value == '5': + exit_code = nagios.STATE_CRIT + output = 'Crashed' + else: + exit_code = nagios.STATE_UNKNOWN + output = 'Unknown status replied' + return output.lower(), int(value), exit_code + + def query_snmp(host, community, oid: str): error_indication, error_status, error_index, var_binds = next( getCmd(SnmpEngine(), @@ -204,7 +226,7 @@ def main(args): perfdata_dict = {} exit_code = nagios.STATE_OK for disk, data in enumerate(disk_data): - output, value, d_exit_code = check_failed(data[4]) + output, value, d_exit_code = check_disk_status(data[4]) exit_code = d_exit_code result_str = result_str + f'Disk {disk + 1}: {output}' perfdata_dict[f'disk_{disk + 1}_status'] = {