Module: check_mk
Branch: master
Commit: 37c8b6199a9730f28839136fadb5c18d12a00372
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=37c8b6199a9730…
Author: Florian Kromer <fk(a)mathias-kettner.de>
Date: Tue Feb 12 17:01:47 2019 +0100
7039 ucs_c_rack_server_health: Storage controller health
This werk adds support for monitoring the storage controller
health of an Cisco UCS C-Series Rack Servers racks.
CMK-1067
Change-Id: I8b8ccc8d657c3a79577abe8872db996cc575f72d
---
.werks/7039 | 11 +++
checkman/ucs_c_rack_server_health | 30 ++++++++
checks/ucs_c_rack_server_health | 87 ++++++++++++++++++++++
.../datasets/ucs_c_rack_server_health.py | 19 +++++
4 files changed, 147 insertions(+)
diff --git a/.werks/7039 b/.werks/7039
new file mode 100644
index 0000000..66d7d93
--- /dev/null
+++ b/.werks/7039
@@ -0,0 +1,11 @@
+Title: ucs_c_rack_server_health: Storage controller health
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1549987107
+Class: feature
+
+This werk adds support for monitoring the storage controller
+health of an Cisco UCS C-Series Rack Servers racks.
diff --git a/checkman/ucs_c_rack_server_health b/checkman/ucs_c_rack_server_health
new file mode 100644
index 0000000..620fc6a
--- /dev/null
+++ b/checkman/ucs_c_rack_server_health
@@ -0,0 +1,30 @@
+title: UCS C-Series Rack Server: Storage controller health
+agents: agent_ucs_bladecenter
+catalog: hw/server/cisco
+license: GPL
+distribution: check_mk
+description:
+ This check provides information about the storage controller health of an UCS C-Series
Rack Servers racks.
+ 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".
+
+ Checks status:
+ - {OK} in case the health value provided by the special agent is {Good}
+ - {UNKNOW} in case of any other health value than {Good}
+
+inventory:
+ All server racks included in the special agent output are found automatically.
+
+item:
+ One item per rack.
diff --git a/checks/ucs_c_rack_server_health b/checks/ucs_c_rack_server_health
new file mode 100644
index 0000000..8ff34da
--- /dev/null
+++ b/checks/ucs_c_rack_server_health
@@ -0,0 +1,87 @@
+#!/usr/bin/env 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 output of special agent agent_ucs_bladecenter (<TAB> is tabulator):
+# storageControllerHealth<TAB>dn
sys/rack-unit-1/board/storage-SAS-SLOT-HBA/vd-0<TAB>health Good
+# storageControllerHealth<TAB>dn
sys/rack-unit-2/board/storage-SAS-SLOT-HBA/vd-0<TAB>health Good
+
+# Dict keys are storage controller health strings provided via special agent -> XML
+# API of servers. Dict values are corresponding check status.
+# For information about the data provided by the special agent
+# "storageControllerHealth" refer to Cisco C-Series Rack Server XML 2.0 Schema
files:
+#
[
https://community.cisco.com/t5/unified-computing-system/cisco-ucs-c-series-…]
+# Note: The possible string values are not defined/documented in the XML schema.
+# "Good" is the only value known from exemplary data output. Pre-process the
+# data to lowercase only chars.
+health_to_status_mapping = {
+ 'good': 0,
+}
+
+
+def parse_ucs_c_rack_server_health(info):
+ """
+ Input: list of lists containing storage controller health data on a per rack basis.
+ Output: Returns dict with indexed Rack Units mapped to keys and lowercase health
string mapped to value
+ 'health' if rack server has racks attached or empty dict if not.
+ """
+ parsed = {}
+ for _, dn, health in info:
+ rack_storage_board = dn.replace("dn sys/",
"").replace("rack-unit-", "Rack unit ").replace(
+ "/board/storage-", " Storage ").replace("-",
" ").replace("/", " ")
+ parsed[rack_storage_board] = health.replace("health ",
"").lower()
+ return parsed
+
+
+def inventory_ucs_c_rack_server_health(parsed):
+ """
+ Input: dict containing items as keys or empty dict.
+ Output: Yields indexed racks and storage controllers as items (e.g. Rack Unit 1
Storage SAS SLOT HBA vd 0) in case parsed contains items.
+ """
+ for key in parsed.iterkeys():
+ yield key, {}
+
+
+@get_parsed_item_data
+def check_ucs_c_rack_server_health(item, params, health):
+ """
+ Check function is called only in case parsed is a dict and item exists as key in
parsed[item].
+ All other potential bad case conditions are handled by @get_parsed_item_data.
+ """
+ try:
+ status = health_to_status_mapping[health]
+ status_readable = health
+ except KeyError:
+ status = 3
+ status_readable = "unknown[%s]" % health
+ yield status, "Status: %s" % status_readable
+
+
+check_info["ucs_c_rack_server_health"] = {
+ 'parse_function': parse_ucs_c_rack_server_health,
+ 'inventory_function': inventory_ucs_c_rack_server_health,
+ 'check_function': check_ucs_c_rack_server_health,
+ 'service_description': 'Health %s',
+}
diff --git a/tests/unit/checks/generictests/datasets/ucs_c_rack_server_health.py
b/tests/unit/checks/generictests/datasets/ucs_c_rack_server_health.py
new file mode 100644
index 0000000..b5ebb9e
--- /dev/null
+++ b/tests/unit/checks/generictests/datasets/ucs_c_rack_server_health.py
@@ -0,0 +1,19 @@
+checkname = 'ucs_c_rack_server_health'
+
+info = [[
+ 'storageControllerHealth', 'dn
sys/rack-unit-1/board/storage-SAS-SLOT-HBA/vd-0', 'health Good'
+],
+ [
+ 'storageControllerHealth', 'dn
sys/rack-unit-2/board/storage-SAS-SLOT-HBA/vd-0',
+ 'health AnythingElse'
+ ]]
+
+discovery = {
+ '': [('Rack unit 1 Storage SAS SLOT HBA vd 0', {}), ('Rack unit 2
Storage SAS SLOT HBA vd 0',
+ {})]
+}
+
+checks = {
+ '': [('Rack unit 1 Storage SAS SLOT HBA vd 0', {}, [(0, 'Status:
good', [])]),
+ ('Rack unit 2 Storage SAS SLOT HBA vd 0', {}, [(3, 'Status:
unknown[anythingelse]', [])])]
+}