Module: check_mk
Branch: master
Commit: a0590ded7552542a681029c50aa46c1fed5dfc7a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a0590ded755254…
Author: Ronny Bruska <rb(a)mathias-kettner.de>
Date: Mon Feb 11 11:45:32 2019 +0100
7152 ucs_c_rack_server_fans: New check for monitoring ucs c series
This werk adds a check reporting the state of ucs c series fans.
CMK-1067
Change-Id: I6457893d531511bc5cce152526b2b5493962a4da
---
.werks/7152 | 12 ++++
checkman/ucs_c_rack_server_fans | 37 +++++++++++
checks/ucs_c_rack_server_fans | 73 ++++++++++++++++++++++
.../datasets/ucs_c_rack_server_fans.py | 49 +++++++++++++++
4 files changed, 171 insertions(+)
diff --git a/.werks/7152 b/.werks/7152
new file mode 100644
index 0000000..69045c4
--- /dev/null
+++ b/.werks/7152
@@ -0,0 +1,12 @@
+Title: ucs_c_rack_server_fans: New check for monitoring ucs c series
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1549881126
+Class: feature
+
+This werk adds a check reporting the state of ucs c series fans.
+
+CMK-1067
diff --git a/checkman/ucs_c_rack_server_fans b/checkman/ucs_c_rack_server_fans
new file mode 100644
index 0000000..b471e01
--- /dev/null
+++ b/checkman/ucs_c_rack_server_fans
@@ -0,0 +1,37 @@
+title: UCS C-Series Rack Server: Health status of fans
+agents: agent_ucs_bladecenter
+catalog: hw/server/cisco
+license: GPL
+distribution: check_mk
+description:
+ This check displays the information of fans of an UCS C-Series Rack Server.
+ The information provided includes the number of fans per unit and the operability
+ state of each fan.
+
+ This check supports the following C-Series Rack Server models providing XML API 2.0
+ [Cisco UCS Rack-Mount Servers Cisco IMC XML API 2.0]:
+
+ - Cisco UCS C220 M5 Rack Server
+ - Cisco UCS C240 M5 Rack Server
+ - Cisco UCS C480 M5 Rack Server
+ - Cisco UCS C480 ML M5 Rack Server
+ - Cisco UCS C220 M4 Rack Server
+ - Cisco UCS C240 M4 Rack Server
+ - Cisco UCS C460 M4 Rack Server
+
+ This check does not support the C-Series Rack Server model Cisco UCS C125 M5 Rack Server
Node
+ which is used as part of a Cisco UCS C4200 Series Rack Server Chassis.
+
+ Check status:
+ - {OK} in case the monitored operability status is one of:
+ operable
+ - {CRIT} in case the monitored operability status is one of:
+ inoperable
+ - {UNKNOWN} in case the monitored operability status is one of:
+ unknown
+
+item:
+ One item for every fan.
+
+Inventory:
+ One service for every unit requested by the Special Agent agent_ucs_bladecenter.
diff --git a/checks/ucs_c_rack_server_fans b/checks/ucs_c_rack_server_fans
new file mode 100644
index 0000000..d8ad8f5
--- /dev/null
+++ b/checks/ucs_c_rack_server_fans
@@ -0,0 +1,73 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2019 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.
+
+# exemplary agent output (separator is <TAB> and is tabulator):
+# <<<ucs_c_rack_server_fans:sep(9)>>>
+# equipmentFan<TAB>dn sys/rack-unit-1/fan-module-1-1/fan-1<TAB>id
1<TAB>operability operable
+
+
+def parse_ucs_c_rack_server_fans(info):
+ parsed = {}
+
+ for fan in info:
+ try:
+ key_value_pairs = [kv.split(" ", 1) for kv in fan[1:]]
+ fan = key_value_pairs[0][1].replace("sys/",
+
"").replace("rack-unit-", "Rack Unit ").replace(
+ "/fan-module-", "
Module ").replace(
+ "/fan-", "
")
+ parsed[fan] = {'operability': key_value_pairs[2][1]}
+ except (IndexError, ValueError):
+ pass
+
+ return parsed
+
+
+operability_to_status_mapping = {
+ "unknown": 3,
+ "operable": 0,
+ "inoperable": 2,
+}
+
+
+@get_parsed_item_data
+def check_ucs_c_rack_server_fans(item, _no_params, data):
+ operability = data["operability"]
+ try:
+ status = operability_to_status_mapping[operability]
+ status_readable = "Operability Status is %s" % operability
+ except KeyError:
+ status = 3
+ status_readable = "Unknown Operability Status: %s" % operability
+ yield status, status_readable
+
+
+check_info["ucs_c_rack_server_fans"] = {
+ 'parse_function': parse_ucs_c_rack_server_fans,
+ 'inventory_function': discover(),
+ 'check_function': check_ucs_c_rack_server_fans,
+ 'service_description': 'Fan %s',
+}
diff --git a/tests/unit/checks/generictests/datasets/ucs_c_rack_server_fans.py
b/tests/unit/checks/generictests/datasets/ucs_c_rack_server_fans.py
new file mode 100644
index 0000000..c09c517
--- /dev/null
+++ b/tests/unit/checks/generictests/datasets/ucs_c_rack_server_fans.py
@@ -0,0 +1,49 @@
+# yapf: disable
+
+checkname = 'ucs_c_rack_server_fans'
+
+
+info = [['equipmentFan',
+ 'dn sys/rack-unit-1/fan-module-1-1/fan-1',
+ 'id 1',
+ 'operability operable'],
+ ['equipmentFan',
+ 'dn sys/rack-unit-1/fan-module-1-1/fan-2',
+ 'id 2',
+ 'operability operable'],
+ ['equipmentFan',
+ 'dn sys/rack-unit-2/fan-module-1-1/fan-1',
+ 'id 1',
+ 'operability operable'],
+ ['equipmentFan',
+ 'dn sys/rack-unit-2/fan-module-1-1/fan-2',
+ 'id 2',
+ 'operability bla'],
+ ['equipmentFan',
+ 'dn sys/rack-unit-2/fan-module-1-1/fan-3',
+ 'id 3',
+ 'operability blub']]
+
+
+discovery = {'': [('Rack Unit 1 Module 1-1 1', {}),
+ ('Rack Unit 1 Module 1-1 2', {}),
+ ('Rack Unit 2 Module 1-1 1', {}),
+ ('Rack Unit 2 Module 1-1 2', {}),
+ ('Rack Unit 2 Module 1-1 3', {})]}
+
+
+checks = {'': [('Rack Unit 1 Module 1-1 1',
+ {},
+ [(0, 'Operability Status is operable', [])]),
+ ('Rack Unit 1 Module 1-1 2',
+ {},
+ [(0, 'Operability Status is operable', [])]),
+ ('Rack Unit 2 Module 1-1 1',
+ {},
+ [(0, 'Operability Status is operable', [])]),
+ ('Rack Unit 2 Module 1-1 2',
+ {},
+ [(3, 'Unknown Operability Status: bla', [])]),
+ ('Rack Unit 2 Module 1-1 3',
+ {},
+ [(3, 'Unknown Operability Status: blub', [])])]}