Module: check_mk
Branch: master
Commit: ffd366b184c11cb607bda96d13cca03fb139ed65
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ffd366b184c11c…
Author: Florian Kromer <fk(a)mathias-kettner.de>
Date: Wed Dec 5 12:40:55 2018 +0100
refactor alcatel_fans check
CMK-1188
Change-Id: I5a838979a57dd02e1143770b938f8bfd7f509304
---
checks/alcatel.include | 20 ++++++++++++++++++++
checks/alcatel_fans | 28 +++++-----------------------
2 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/checks/alcatel.include b/checks/alcatel.include
index ded1309..fe19844 100644
--- a/checks/alcatel.include
+++ b/checks/alcatel.include
@@ -56,6 +56,26 @@ def check_alcatel_cpu(_no_item, params, info):
return status, "total: %.1f%%" % cpu_perc + levelstext, perfdata
+def inventory_alcatel_fans(info):
+ for nr, _value in enumerate(info, 1):
+ yield nr, None
+
+
+def check_alcatel_fans(item, _no_params, info):
+ fan_states = {
+ 0: "has no status",
+ 1: "not running",
+ 2: "running",
+ }
+ for nr, value in enumerate(info):
+ if nr + 1 == item:
+ fan_state = int(value[0])
+ state = 0
+ if fan_state != 2:
+ state = 2
+ return state, "Fan " + fan_states[fan_state]
+
+
def inventory_alcatel_power(info):
for line in info:
oid_end, _, device_type, power_type = line
diff --git a/checks/alcatel_fans b/checks/alcatel_fans
index b74ca1a..d16c059 100644
--- a/checks/alcatel_fans
+++ b/checks/alcatel_fans
@@ -24,31 +24,13 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-
-def inventory_alcatel_fans(info):
- for nr, _value in enumerate(info, 1):
- yield nr, None
-
-
-def check_alcatel_fans(item, _no_params, info):
- fan_states = {
- 0: "has no status",
- 1: "not running",
- 2: "running",
- }
- for nr, value in enumerate(info):
- if nr + 1 == item:
- fan_state = int(value[0])
- state = 0
- if fan_state != 2:
- state = 2
- return state, "Fan " + fan_states[fan_state]
-
-
check_info["alcatel_fans"] = {
"check_function": check_alcatel_fans,
"inventory_function": inventory_alcatel_fans,
"service_description": "Fan %s",
- "snmp_scan_function": lambda oid:
oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.6486.800"),
- "snmp_info": (".1.3.6.1.4.1.6486.800.1.1.1.3.1.1.11.1", [2]),
+ "snmp_scan_function": alcatel_networking_products_scan_function,
+ "snmp_info": (
+ ".1.3.6.1.4.1.6486.800.1.1.1.3.1.1.11.1", # MIB object
"alaChasEntPhysFanEntry"
+ [2]), # MIB object "alaChasEntPhysFanStatus"
+ "includes": ["alcatel.include"],
}