-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcisco_nexus_system
57 lines (47 loc) · 1.9 KB
/
cisco_nexus_system
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python
# OIDs used:
# CISCO-SYSTEM-EXT-MIB::cseSysCPUUtilization .1.3.6.1.4.1.9.9.305.1.1.1.0
# CISCO-SYSTEM-EXT-MIB::cseSysMemoryUtilization .1.3.6.1.4.1.9.9.305.1.1.2.0
# SNMPv2-MIB::sysDescr .1.3.6.1.2.1.1.1.0
# Scan function looks for 'Cisco NX-OS' in sysDescr
# Author: Mike Julian - [email protected] - http://mikejulian.com
cisco_nexus_system_default_levels = (80.0, 90.0)
def inventory_cisco_nexus_system(info):
return [ (None, cisco_nexus_system_default_levels) ]
def check_cisco_nexus_system(item, params, info):
warn,crit = params
cpuUtil = float(info[0][0])
memUtil = float(info[0][1])
states = []
cpuInfo = "CPU: %2.1f%%" % cpuUtil
if cpuUtil >= crit:
cpuInfo += "(!!)"
state = 2
elif cpuUtil >= warn:
cpuInfo += "(!)"
state = 1
else:
state = 0
states.append((state,cpuInfo,("CPU (percentage)", cpuUtil, warn, crit, 0, 100)))
memInfo = "Mem: %2.1f%%" % memUtil
if memUtil >= crit:
memInfo += "(!!)"
state = 2
elif memUtil >= warn:
memInfo += "(!)"
state = 1
else:
state = 0
states.append((state,memInfo,("Memory (percentage)", memUtil, warn, crit, 0, 100)))
worst_state = max([x[0] for x in states])
info_text = ", ".join([x[1] for x in states])
state_text = { 0:"OK", 1:"WARN", 2:"CRIT" }.get(worst_state)
return (worst_state, "%s - Usages: %s" % (state_text, info_text), [x[2] for x in states if x[2] != None])
check_info["cisco_nexus_system"] = {
"check_function" : check_cisco_nexus_system,
"inventory_function" : inventory_cisco_nexus_system,
"service_description" : "Nexus System",
"has_perfdata" : True,
"snmp_scan_function" : lambda oid: "Cisco NX-OS" in oid(".1.3.6.1.2.1.1.1.0"),
"snmp_info" : ( ".1.3.6.1.4.1.9.9.305.1.1", [ "1.0", "2.0" ] )
}