"envmon_power_status": "1.3.6.1.4.1.9.9.13.1.5.1.3", # from CISCO-ENVMON-MIB } # Store all sensors data sensor_data = [] # Query using CISCO-ENTITY-SENSOR-MIB be default, fallback to CISCO-ENVMON-MIB query = plugin.snmp.getnext(oids) # Return OK if no hardware sensor support is available if ( not query.has_key("sensors_status") and not query.has_key("envmon_fan_status") and not query.has_key("envmon_power_status") ): plugin.ok("No support for hardware sensor available.") if not query.has_key("sensors_status"): # Does not support CISCO-ENTITY-SENSOR-MIB logger.debug("Device not supporting CISCO-ENTITY-SENSOR-MIB, fallback.") sensor_status = query["envmon_fan_status"] + query["envmon_power_status"] for sensor in sensor_status: sensor_name = [e.pretty() for e in query["sensor_names"] if e.index == sensor.index][0] sensor_status = sensor.value # Skip sensor status marked as unavailable(2) if sensor_status == 5: continue sensor_data.append((sensor_name, sensor_status))
if temp_value != 2: exit_code = 2 nbr_error += 1 if re.search(r'470$', temp_index): longoutput_error += ' * %s: (PSU1) (%d) %s *\n' % (temp_descr, temp_value, desc[temp_value]) elif re.search(r'471$', temp_index): longoutput_error += ' ** %s: (PSU2) (%d) %s **\n' % (temp_descr, temp_value, desc[temp_value]) else: nbr_ok += 1 if re.search(r'470$', temp_index): longoutput_ok += ' %s: (PSU1) %s\n' % (temp_descr, desc[temp_value]) elif re.search(r'471$', temp_index): longoutput_ok += ' %s: (PSU2) %s\n' % (temp_descr, desc[temp_value]) # Format output if nbr_error > 0: longoutput += 'ERROR: %d\n%s\n' % (nbr_error, longoutput_error) if nbr_ok > 0: longoutput += 'ON: %d\n%s\n' % (nbr_ok, longoutput_ok) # Output to Nagios longoutput = longoutput.rstrip('\n') if exit_code == 2: output = '%d PSU : ERROR !\n' % nbr_error plugin.critical(output + longoutput) elif not exit_code: output = 'All PSU are ON.\n' plugin.ok(output + longoutput)
'envmon_fan_status': '1.3.6.1.4.1.9.9.13.1.4.1.3', # from CISCO-ENVMON-MIB 'envmon_power_status': '1.3.6.1.4.1.9.9.13.1.5.1.3', # from CISCO-ENVMON-MIB } # Store all sensors data sensor_data = [] # Query using CISCO-ENTITY-SENSOR-MIB be default, fallback to CISCO-ENVMON-MIB query = plugin.snmp.getnext(oids) # Return OK if no hardware sensor support is available if not query.has_key('sensors_status') \ and not query.has_key('envmon_fan_status') \ and not query.has_key('envmon_power_status'): plugin.ok('No support for hardware sensor available.') if not query.has_key('sensors_status'): # Does not support CISCO-ENTITY-SENSOR-MIB logger.debug('Device not supporting CISCO-ENTITY-SENSOR-MIB, fallback.') sensor_status = query['envmon_fan_status'] + query['envmon_power_status'] for sensor in sensor_status: sensor_name = [ e.pretty() for e in query['sensor_names'] if e.index == sensor.index ][0] sensor_status = sensor.value # Skip sensor status marked as unavailable(2) if sensor_status == 5: