Module: check_mk
Branch: master
Commit: a16e6d1104c8ec8c934522fad0461acba55d8108
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a16e6d1104c8ec…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Aug 16 15:07:26 2017 +0200
Minor cleanup cisco_temp
Change-Id: If7a9c1c60848323cd11249e9e0d01f07004bd041
---
checks/cisco_cpu | 4 ++++
checks/cisco_temp | 57 +++++++++++++++----------------------------------------
2 files changed, 19 insertions(+), 42 deletions(-)
diff --git a/checks/cisco_cpu b/checks/cisco_cpu
index 4fc92d2..bc56745 100644
--- a/checks/cisco_cpu
+++ b/checks/cisco_cpu
@@ -27,14 +27,17 @@
# oid(".1.3.6.1.4.1.9.9.109.1.1.1.1.5.1") is depreceated by
# oid(".1.3.6.1.4.1.9.9.109.1.1.1.1.8.1"), we recognize both for now
+
cisco_cpu_default_levels = (80.0, 90.0)
+
def inventory_cisco_cpu(info):
if info and \
(info[0][0].isdigit() or \
info[0][1].isdigit()):
return [( None, 'cisco_cpu_default_levels') ]
+
def check_cisco_cpu(item, params, info):
# Value of info could be (None, None) or ("", "").
if not info[0][0].isdigit() and \
@@ -59,6 +62,7 @@ def check_cisco_cpu(item, params, info):
return state, infotext, [("util", util, warn, crit, 0, 100)]
+
check_info["cisco_cpu"] = {
"check_function" : check_cisco_cpu,
"inventory_function" : inventory_cisco_cpu,
diff --git a/checks/cisco_temp b/checks/cisco_temp
index 4c7bd84..e6e3a5d 100644
--- a/checks/cisco_temp
+++ b/checks/cisco_temp
@@ -24,57 +24,30 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-# Possible values for state:
-# Valid values are:
-#
-# normal(1): the environment is good, such as low
-# temperature.
-#
-# warning(2): the environment is bad, such as temperature
-# above normal operation range but not too
-# high.
-#
-# critical(3): the environment is very bad, such as
-# temperature much higher than normal
-# operation limit.
-#
-# shutdown(4): the environment is the worst, the system
-# should be shutdown immediately.
-#
-# notPresent(5): the environmental monitor is not present,
-# such as temperature sensors do not exist.
-#
-# notFunctioning(6): the environmental monitor does not
-# function properly, such as a temperature
-# sensor generates a abnormal data like
-# 1000 C.
-
def inventory_cisco_temp(checktyp, info):
- # Skip sensors with state 5 (not present)
for name, state in info:
if state != '5':
yield name, None
+
def check_cisco_temp(item, _no_params, info):
- for name, state in info:
+ map_states = {
+ "1": (0, "OK"),
+ "2": (1, "warning"),
+ "3": (2, "critical"),
+ "4": (2, "shutdown"),
+ "5": (3, "not present"),
+ "6": (3, "value out of range"),
+ }
+
+ for name, dev_state in info:
if name == item:
- if state == '1':
- return (0, "status is OK")
- elif state == '2':
- return (1, "status is WARNING")
- elif state == '3':
- return (2, "status is CRITICAL")
- elif state == '4':
- return (2, "status is SHUTDOWN")
- elif state == '5':
- return (3, "sensor not present")
- elif state == '6':
- return (3, "sensor value out of range")
- else:
- return (3, "invalid state '%s'" % state)
+ state, state_readable = map_states.get(dev_state, (3, "unknown[%s]" % dev_state))
+ return state, "Status: %s" % state_readable
+
+ return 3, "sensor not found in SNMP output"
- return (3, "sensor not found in SNMP output")
check_info["cisco_temp"] = {
'check_function': check_cisco_temp,