Module: check_mk
Branch: master
Commit: 8cd703e9ff045a92e04a1497e2ab5462ae705a74
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8cd703e9ff045a…
Author: Florian Kromer <fk(a)mathias-kettner.de>
Date: Fri Feb 22 08:59:11 2019 +0100
7040 ucs_c_rack_server_topsystem: Topsystem Information
This werk adds a check which displays information about Cisco UCS C-Series Rack Servers.
CMK-1067
Change-Id: I46d2913fe22745f80501843708080cb4c061f573
---
.werks/7040 | 12 +++
checkman/ucs_c_rack_server_topsystem | 26 +++++++
checks/ucs_c_rack_server_topsystem | 87 ++++++++++++++++++++++
.../datasets/ucs_c_rack_server_topsystem.py | 23 ++++++
4 files changed, 148 insertions(+)
diff --git a/.werks/7040 b/.werks/7040
new file mode 100644
index 0000000..81cba4e
--- /dev/null
+++ b/.werks/7040
@@ -0,0 +1,12 @@
+Title: ucs_c_rack_server_topsystem: Topsystem Information
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1550822320
+Class: feature
+
+This werk adds a check which displays information about Cisco UCS C-Series Rack Servers.
+
+CMK-1067
diff --git a/checkman/ucs_c_rack_server_topsystem b/checkman/ucs_c_rack_server_topsystem
new file mode 100644
index 0000000..2019be4
--- /dev/null
+++ b/checkman/ucs_c_rack_server_topsystem
@@ -0,0 +1,26 @@
+title: UCS C-Series Rack Server: TopSystem Info
+agents: agent_ucs_bladecenter
+catalog: hw/server/cisco
+license: GPL
+distribution: check_mk
+description:
+ This check displays the information of the TopSystem class of an UCS C-Series Rack
Server.
+ The information provided includes the IP-Address, Date and Time, Mode, System Name. The
check
+ displays always the status {OK}.
+
+ 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.
+
+Inventory:
+ One service for every server requested by the Special Agent agent_ucs_bladecenter.
diff --git a/checks/ucs_c_rack_server_topsystem b/checks/ucs_c_rack_server_topsystem
new file mode 100644
index 0000000..e98e9cf
--- /dev/null
+++ b/checks/ucs_c_rack_server_topsystem
@@ -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 the special agent ucs_bladecenter (separator is <TAB> and
means tabulator):
+#
+#<<<ucsc_topsystem:sep(9)>>>
+#topSystem<TAB>dn sys<TAB>address 192.168.1.1<TAB>currentTime Wed Feb
6 09:12:12 2019<TAB>mode stand-alone<TAB>name CIMC-istreamer2a-etn
+
+
+def parse_ucs_c_rack_server_topsystem(info):
+ """
+ Input: Single line info with a rack server topsystem information.
+ Output: Returns dict with dn, address, current time, mode and name as keys (with
corresponding values).
+ """
+
+ def format_data_and_time(date_and_time):
+ """Converts date and time and returns in time format.
+
+ E.g. Wed Feb 6 09:12:12 2019 -> 2019-02-06 09:12:12
+ """
+ #time.strptime('Jun 1 2005 1:33PM', '%b %d %Y %I:%M%p')
+ struct_time = time.strptime(date_and_time[4:], '%b %d %H:%M:%S %Y')
+ formatted = time.strftime('%Y-%m-%d %H:%M:%S', struct_time)
+ return formatted
+
+ parsed = {}
+ # The element count of info lines is under our control (agent output) and
+ # ensured to have expected length. It is ensured that elements contain a
+ # string. No bad case handling required here.
+ for _, dn, ip, date_and_time, mode, name in info:
+ # If more than one info line given or in case of unexpected info list element
format the
+ # parsed dict will be empty.
+ parsed.update({
+ 'DN': dn.replace("dn ", ""),
+ 'IP': ip.replace("address ", ""),
+ 'Mode': mode.replace("mode ", ""),
+ 'Name': name.replace("name ", ""),
+ })
+ try:
+ parsed.update(
+ {'Date and time':
format_data_and_time(date_and_time.replace("currentTime ", ""))})
+ except ValueError:
+ # indicate date and time format not supported
+ parsed.update({'Date and time': 'unknown[%s]' %
date_and_time[4:]})
+ return parsed
+
+
+def inventory_ucs_c_rack_server_topsystem(parsed):
+ if parsed:
+ return [(None, None)]
+
+
+#@get_parsed_item_data
+def check_ucs_c_rack_server_topsystem(item, _no_params, data):
+ for title, value in data.items():
+ yield 0, "%s: %s" % (title, value)
+
+
+check_info["ucs_c_rack_server_topsystem"] = {
+ 'parse_function': parse_ucs_c_rack_server_topsystem,
+ 'inventory_function': inventory_ucs_c_rack_server_topsystem,
+ 'check_function': check_ucs_c_rack_server_topsystem,
+ 'service_description': 'UCS C-Series Rack Server TopSystem Info',
+}
diff --git a/tests/unit/checks/generictests/datasets/ucs_c_rack_server_topsystem.py
b/tests/unit/checks/generictests/datasets/ucs_c_rack_server_topsystem.py
new file mode 100644
index 0000000..dce53ac
--- /dev/null
+++ b/tests/unit/checks/generictests/datasets/ucs_c_rack_server_topsystem.py
@@ -0,0 +1,23 @@
+# yapf: disable
+
+checkname = 'ucs_c_rack_server_topsystem'
+
+
+info = [['topSystem',
+ 'dn sys',
+ 'address 192.168.1.1',
+ 'currentTime Wed Feb 6 09:12:12 2019',
+ 'mode stand-alone',
+ 'name CIMC-istreamer2a-etn']]
+
+
+discovery = {'': [(None, None)]}
+
+
+checks = {'': [(None,
+ {},
+ [(0, 'DN: sys', []),
+ (0, 'IP: 192.168.1.1', []),
+ (0, 'Date and time: 2019-02-06 09:12:12', []),
+ (0, 'Mode: stand-alone', []),
+ (0, 'Name: CIMC-istreamer2a-etn', [])])]}