check_snology fix

This commit is contained in:
Cyberes 2024-10-21 15:44:45 -06:00
parent 9fc856fb7f
commit 83ac54fa73
1 changed files with 23 additions and 1 deletions

View File

@ -53,6 +53,28 @@ def check_failed(value: str):
return output.lower(), int(value), exit_code 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): def query_snmp(host, community, oid: str):
error_indication, error_status, error_index, var_binds = next( error_indication, error_status, error_index, var_binds = next(
getCmd(SnmpEngine(), getCmd(SnmpEngine(),
@ -204,7 +226,7 @@ def main(args):
perfdata_dict = {} perfdata_dict = {}
exit_code = nagios.STATE_OK exit_code = nagios.STATE_OK
for disk, data in enumerate(disk_data): 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 exit_code = d_exit_code
result_str = result_str + f'Disk {disk + 1}: {output}' result_str = result_str + f'Disk {disk + 1}: {output}'
perfdata_dict[f'disk_{disk + 1}_status'] = { perfdata_dict[f'disk_{disk + 1}_status'] = {