51 lines
1.7 KiB
Python
Executable File
51 lines
1.7 KiB
Python
Executable File
import argparse
|
|
import sys
|
|
import traceback
|
|
|
|
from checker import nagios
|
|
from checker.result import quit_check
|
|
from checker.snmp import get_snmp_value
|
|
|
|
# TODO: support iDRAC 8
|
|
|
|
# https://github.com/ilovepancakes95/idrac_snmp-grafana/blob/master/idrac-input.conf
|
|
FAN_SPEED_OID = '.1.3.6.1.4.1.674.10892.5.4.700.12.1.6.1.'
|
|
|
|
|
|
def main(args):
|
|
text_result = ''
|
|
perf_data = {}
|
|
fan_speeds = []
|
|
for i in range(args.fan_num):
|
|
value = get_snmp_value(FAN_SPEED_OID + str(i + 1), args.ip, args.community)
|
|
if not value:
|
|
continue
|
|
fan_speeds.append(value)
|
|
text_result += f'Fan{i + 1}: {value}, '
|
|
perf_data[f'Fan{i + 1}'] = {'value': value, 'warn': args.warn, 'crit': args.crit}
|
|
text_result = text_result.strip(', ')
|
|
|
|
exit_code = nagios.STATE_OK
|
|
if min(fan_speeds) <= args.crit:
|
|
exit_code = max(nagios.STATE_CRIT, exit_code)
|
|
elif min(fan_speeds) <= args.warn:
|
|
exit_code = max(nagios.STATE_WARN, exit_code)
|
|
|
|
quit_check(text_result, exit_code, perfdata=perf_data)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('--ip', required=True, help='The iDRAC IP to query.')
|
|
parser.add_argument('--community', default='public', help='Your SNMP community. Default: public')
|
|
parser.add_argument('--fan-num', type=int, default=1, help='Number of fans. Default: 1')
|
|
parser.add_argument('--warn', type=int, default=840, help='RPM warning level. Default: 840')
|
|
parser.add_argument('--crit', type=int, default=600, help='RPM critical level. Default: 600')
|
|
args = parser.parse_args()
|
|
try:
|
|
main(args)
|
|
except Exception as e:
|
|
print(f"UNKNOWN: exception\n{e}")
|
|
print(traceback.format_exc())
|
|
sys.exit(nagios.STATE_UNKNOWN)
|