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 GLOBAL_SYSTEM_STATUS_OID = '.1.3.6.1.4.1.674.10892.5.2.1.0' def main(args): system_status = get_snmp_value(GLOBAL_SYSTEM_STATUS_OID, args.ip, args.community) if system_status == 1: exit_code = nagios.STATE_UNKNOWN text_result = 'status is other' elif system_status == 2: exit_code = nagios.STATE_UNKNOWN text_result = 'status is unknown' elif system_status == 3: exit_code = nagios.STATE_OK text_result = 'status is nominal' elif system_status == 4: exit_code = nagios.STATE_WARN text_result = 'status is non-critical' elif system_status == 5: exit_code = nagios.STATE_CRIT text_result = 'status is critical' elif system_status == 6: exit_code = nagios.STATE_CRIT text_result = 'status is non-recoverable' else: exit_code = nagios.STATE_UNKNOWN text_result = 'status is critical' quit_check(text_result, exit_code) 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') 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)