Skip to content
Snippets Groups Projects
Commit cf3f09f5 authored by root's avatar root
Browse files

Added perfdata monitoring to check_mellanox.

parent a851f445
No related branches found
No related tags found
No related merge requests found
...@@ -52,6 +52,8 @@ def snmpWalk(oid): ...@@ -52,6 +52,8 @@ def snmpWalk(oid):
except EasySNMPNoSuchNameError: except EasySNMPNoSuchNameError:
return None return None
perfdata = ""
session = Session(hostname=options.host, community=options.community, version=int(options.version)) session = Session(hostname=options.host, community=options.community, version=int(options.version))
dataReturned = 0 dataReturned = 0
...@@ -80,6 +82,8 @@ for idx in snmpWalk(".1.3.6.1.2.1.99.1.1"): ...@@ -80,6 +82,8 @@ for idx in snmpWalk(".1.3.6.1.2.1.99.1.1"):
if options.debug: if options.debug:
print("{} {} {} {}".format(sensortype, desc, value, units)) print("{} {} {} {}".format(sensortype, desc, value, units))
perfdata += " '" + desc + "'=" + str(value)
# Check Thresholds # Check Thresholds
if sensortype.startswith("Temperature") and desc.lower().startswith("mgmt/board"): if sensortype.startswith("Temperature") and desc.lower().startswith("mgmt/board"):
if value >= int(options.tempcrit): if value >= int(options.tempcrit):
...@@ -93,6 +97,56 @@ for idx in snmpWalk(".1.3.6.1.2.1.99.1.1"): ...@@ -93,6 +97,56 @@ for idx in snmpWalk(".1.3.6.1.2.1.99.1.1"):
elif int(value) <= int(options.fanwarn): elif int(value) <= int(options.fanwarn):
WARNING_TEXT += desc + " speed is " + value + " " + units + ". " WARNING_TEXT += desc + " speed is " + value + " " + units + ". "
# Collect interface statistics
for idx in snmpWalk(".1.3.6.1.2.1.2.2.1.1"):
idx = idx.value
ifDescr = snmpGet("IF-MIB::ifDescr." + idx)
ifType = snmpGet("IF-MIB::ifType." + idx)
ifMtu = snmpGet("IF-MIB::ifMtu." + idx)
ifSpeed = snmpGet("IF-MIB::ifSpeed." + idx)
ifHighSpeed = snmpGet("IF-MIB::ifHighSpeed." + idx)
#ifPhysAddress = snmpGet("IF-MIB::ifPhysAddress." + idx)
ifAdminStatus = snmpGet("IF-MIB::ifAdminStatus." + idx)
ifOperStatus = snmpGet("IF-MIB::ifOperStatus." + idx)
ifLastChange = snmpGet("IF-MIB::ifLastChange." + idx)
ifInOctets = snmpGet("IF-MIB::ifInOctets." + idx)
ifInUcastPkts = snmpGet("IF-MIB::ifInUcastPkts." + idx)
ifInNUcastPkts = snmpGet("IF-MIB::ifInNUcastPkts." + idx)
ifInDiscards = snmpGet("IF-MIB::ifInDiscards." + idx)
ifInErrors = snmpGet("IF-MIB::ifInErrors." + idx)
ifInUnknownProtos = snmpGet("IF-MIB::ifInUnknownProtos." + idx)
ifOutOctets = snmpGet("IF-MIB::ifOutOctets." + idx)
ifOutUcastPkts = snmpGet("IF-MIB::ifOutUcastPkts." + idx)
ifOutNUcastPkts = snmpGet("IF-MIB::ifOutNUcastPkts." + idx)
ifOutDiscards = snmpGet("IF-MIB::ifOutDiscards." + idx)
ifOutErrors = snmpGet("IF-MIB::ifOutErrors." + idx)
ifOutQLen = snmpGet("IF-MIB::ifOutQLen." + idx)
perfdata += " '" + ifDescr + "_ifType'=" + ifType
perfdata += " '" + ifDescr + "_ifMtu'=" + ifMtu
perfdata += " '" + ifDescr + "_ifSpeed'=" + ifSpeed
perfdata += " '" + ifDescr + "_ifHighSpeed'=" + ifHighSpeed
#perfdata += " '" + ifDescr + "_ifPhysAddress'=" + ifPhysAddress
perfdata += " '" + ifDescr + "_ifAdminStatus'=" + ifAdminStatus
perfdata += " '" + ifDescr + "_ifOperStatus'=" + ifOperStatus
perfdata += " '" + ifDescr + "_ifLastChange'=" + ifLastChange
perfdata += " '" + ifDescr + "_ifInOctets'=" + ifInOctets
perfdata += " '" + ifDescr + "_ifInUcastPkts'=" + ifInUcastPkts
perfdata += " '" + ifDescr + "_ifInNUcastPkts'=" + ifInNUcastPkts
perfdata += " '" + ifDescr + "_ifInDiscards'=" + ifInDiscards
perfdata += " '" + ifDescr + "_ifInErrors'=" + ifInErrors
perfdata += " '" + ifDescr + "_ifInUnknownProtos'=" + ifInUnknownProtos
perfdata += " '" + ifDescr + "_ifOutOctets'=" + ifOutOctets
perfdata += " '" + ifDescr + "_ifOutUcastPkts'=" + ifOutUcastPkts
perfdata += " '" + ifDescr + "_ifOutNUcastPkts'=" + ifOutNUcastPkts
perfdata += " '" + ifDescr + "_ifOutDiscards'=" + ifOutDiscards
perfdata += " '" + ifDescr + "_ifOutErrors'=" + ifOutErrors
perfdata += " '" + ifDescr + "_ifOutQLen'=" + ifOutQLen
if dataReturned == 0: if dataReturned == 0:
print("UNKNOWN - SNMP returned no data (Host is unreachable or SNMP is not responding) | ") print("UNKNOWN - SNMP returned no data (Host is unreachable or SNMP is not responding) | ")
...@@ -121,11 +175,11 @@ for idx in snmpWalk(".1.3.6.1.2.1.47.1.1.1.1.1"): ...@@ -121,11 +175,11 @@ for idx in snmpWalk(".1.3.6.1.2.1.47.1.1.1.1.1"):
# Critical/Warning Think Logic # Critical/Warning Think Logic
if CRITICAL_TEXT and (CRITICAL_TEXT is not None): if CRITICAL_TEXT and (CRITICAL_TEXT is not None):
print("CRITICAL - " + CRITICAL_TEXT + "|") print("CRITICAL - " + CRITICAL_TEXT + "|" + perfdata)
sys.exit(STATE_CRITICAL) sys.exit(STATE_CRITICAL)
elif WARNING_TEXT and (WARNING_TEXT is not None): elif WARNING_TEXT and (WARNING_TEXT is not None):
print("WARNING - " + WARNING_TEXT + "|") print("WARNING - " + WARNING_TEXT + "|" + perfdata)
sys.exit(STATE_WARNING) sys.exit(STATE_WARNING)
else: else:
print("OK - No problems detected |") print("OK - No problems detected |" + perfdata)
sys.exit(STATE_OK) sys.exit(STATE_OK)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment