Module: check_mk
Branch: master
Commit: 33eb97b8f44e2a1491348f82a85606bf457fef4f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=33eb97b8f44e2a…
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 | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++
checks/alcatel_fans | 31 +++++++---------------------
2 files changed, 63 insertions(+), 24 deletions(-)
diff --git a/checks/alcatel.include b/checks/alcatel.include
new file mode 100644
index 0000000..ba7e376
--- /dev/null
+++ b/checks/alcatel.include
@@ -0,0 +1,56 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2018 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+
+def alcatel_scan_function(oid):
+ sys_descr_id = ".1.3.6.1.2.1.1.1.0"
+ return "alcatel" in oid(sys_descr_id).lower()
+
+
+def alcatel_networking_products_scan_function(oid):
+ sys_object_id = ".1.3.6.1.2.1.1.2.0" # MIB object "sysObjectID"
+ alcatel_ind_1_base_mib = ".1.3.6.1.4.1.6486.800" # MIB object
"alcatelIND1BaseMIB"
+ return alcatel_scan_function(oid) and
oid(sys_object_id).startswith(alcatel_ind_1_base_mib)
+
+
+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]
diff --git a/checks/alcatel_fans b/checks/alcatel_fans
index b74ca1a..426b0c6 100644
--- a/checks/alcatel_fans
+++ b/checks/alcatel_fans
@@ -7,7 +7,7 @@
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
-# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+# | Copyright Mathias Kettner 2018 mk(a)mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
@@ -24,31 +24,14 @@
# 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
"alaChasEntPhysFanTable"
+ [2] # MIB object "alaChasEntPhysFanStatus": noStatus(0),
notRunning(1), running(2)
+ ),
+ "includes": ["alcatel.include"],
}