Module: check_mk
Branch: master
Commit: 3152011085040ef7727d9a4137bb0df13f90fa7b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3152011085040e…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Fri Jan 12 11:01:39 2018 +0100
5600 hp_fan: New check to monitor the fans of HP switches
Change-Id: I8d22d79444eb9a8c409f32b54c04d841aafa457e
---
.werks/5600 | 10 ++++++++++
checkman/hp_fan | 15 ++++++++++++++
checks/hp_fan | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 86 insertions(+)
diff --git a/.werks/5600 b/.werks/5600
new file mode 100644
index 0000000..4b4871e
--- /dev/null
+++ b/.werks/5600
@@ -0,0 +1,10 @@
+Title: hp_fan: New check to monitor the fans of HP switches
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i3
+Date: 1515751182
+Class: feature
+
+
diff --git a/checkman/hp_fan b/checkman/hp_fan
new file mode 100644
index 0000000..76b5c50
--- /dev/null
+++ b/checkman/hp_fan
@@ -0,0 +1,15 @@
+title: HP Switches: Fan Status
+agents: SNMP
+catalog: hw/network/hp
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the state of fans in HP switches. "unknown" and
"maxstate"
+ are treated as UNKNOWN, "removed" and "off" as CRIT,
"underspeed" and "overspeed"
+ as WARN. "ok" is OK.
+
+item:
+ The tray index and the fan index, e.g. 0/3
+
+inventory:
+ One service per fan is created.
diff --git a/checks/hp_fan b/checks/hp_fan
new file mode 100644
index 0000000..2d62072
--- /dev/null
+++ b/checks/hp_fan
@@ -0,0 +1,61 @@
+#!/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 parse_hp_fan(info):
+ return { "%s/%s" % (tray_index, fan_index) : fan_state for fan_index,
tray_index, fan_state in info }
+
+
+def inventory_hp_fan(parsed):
+ for fan in parsed:
+ yield fan, None
+
+
+def check_hp_fan(item, _no_params, parsed):
+ statemap = {
+ "0" : (3, "unknown"),
+ "1" : (2, "removed"),
+ "2" : (2, "off"),
+ "3" : (1, "underspeed"),
+ "4" : (1, "overspeed"),
+ "5" : (0, "ok"),
+ "6" : (3, "maxstate"),
+ }
+ return statemap[parsed[item]]
+
+
+check_info['hp_fan'] = {
+ 'parse_function' : parse_hp_fan,
+ 'inventory_function' : inventory_hp_fan,
+ 'check_function' : check_hp_fan,
+ 'service_description' : 'Fan %s',
+ 'snmp_info' : ('.1.3.6.1.4.1.11.2.14.11.5.1.54.2.1.1', [
# FAN-MIB - hpicfFanEntry
+ OID_END, # HpicfDcFanIndex is not-accessible,
so this will have to do.
+ "2", # hpicfFanTray
+ "4", # hpicfFanState
+ ]),
+ 'snmp_scan_function' : lambda oid: "hp" in
oid(".1.3.6.1.2.1.1.1.0").lower() and "switch" in
oid(".1.3.6.1.2.1.1.1.0").lower(),
+}