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'] = {