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]', [])])]
+}
Module: check_mk
Branch: master
Commit: a64037cffd6e9578f640e9527a1eb662f37a7628
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a64037cffd6e95…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Feb 21 15:17:28 2019 +0100
7179 FIX Fixed site filtering when creating availability PDF reports
When having a filtered availability view which shows information of specific
sites in distributed setups, the PDF reports created with "Export as PDF" were
not applying the site filter. In this situation a query was sent to all
distributed sites for fetching the data. It was not only querying too many
sites, the PDFs also contained more hosts / services than intended in this
situation.
Change-Id: Ia15a5533e4e45b27c97f7f0bd00322b4608c0f9b
---
.werks/7179 | 16 ++++++++++++++++
cmk/gui/bi.py | 3 +--
cmk/gui/plugins/views/inventory.py | 3 +--
cmk/gui/visuals.py | 13 ++++++++-----
4 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/.werks/7179 b/.werks/7179
new file mode 100644
index 0000000..a1e2038
--- /dev/null
+++ b/.werks/7179
@@ -0,0 +1,16 @@
+Title: Fixed site filtering when creating availability PDF reports
+Level: 1
+Component: reporting
+Class: fix
+Compatible: compat
+Edition: cee
+State: unknown
+Version: 1.6.0i1
+Date: 1550673927
+
+When having a filtered availability view which shows information of specific
+sites in distributed setups, the PDF reports created with "Export as PDF" were
+not applying the site filter. In this situation a query was sent to all
+distributed sites for fetching the data. It was not only querying too many
+sites, the PDFs also contained more hosts / services than intended in this
+situation.
diff --git a/cmk/gui/bi.py b/cmk/gui/bi.py
index 276c1fe..c7e29f1 100644
--- a/cmk/gui/bi.py
+++ b/cmk/gui/bi.py
@@ -3335,8 +3335,7 @@ def singlehost_table(columns, add_headers, only_sites, limit, filters, joinbynam
filter_code = ""
for filt in filters:
header = filt.filter("bi_host_aggregations")
- if not header.startswith("Sites:"):
- filter_code += header
+ filter_code += header
log("* Getting status information about hosts...")
host_columns = [c for c in columns if c.startswith("host_")]
diff --git a/cmk/gui/plugins/views/inventory.py b/cmk/gui/plugins/views/inventory.py
index f838ac8..c96a26d 100644
--- a/cmk/gui/plugins/views/inventory.py
+++ b/cmk/gui/plugins/views/inventory.py
@@ -1387,8 +1387,7 @@ def inv_multisite_table(infoname, invpath, columns, add_headers, only_sites, lim
filter_code = ""
for filt in filters:
header = filt.filter(infoname)
- if not header.startswith("Sites:"):
- filter_code += header
+ filter_code += header
host_columns = ["host_name"] + list(
{c for c in columns if c.startswith("host_") and c != "host_name"})
diff --git a/cmk/gui/visuals.py b/cmk/gui/visuals.py
index 45647e5..e4e1ce3 100644
--- a/cmk/gui/visuals.py
+++ b/cmk/gui/visuals.py
@@ -1200,10 +1200,10 @@ def get_context_from_uri_vars(only_infos=None, single_infos=None):
# Compute Livestatus-Filters based on a given context. Returns
# the only_sites list and a string with the filter headers
+# TODO: Untangle only_sites and filter headers
def get_filter_headers(table, infos, context):
# Prepare Filter headers for Livestatus
filter_headers = ""
- only_sites = None
with html.stashed_vars():
for filter_name, filter_vars in context.items():
# first set the HTML variables. Sorry - the filters need this
@@ -1213,15 +1213,18 @@ def get_filter_headers(table, infos, context):
else:
html.request.set_var(filter_name, filter_vars)
+ # Apply the site hint / filter (Same logic as in views.py)
+ if html.request.var("site"):
+ only_sites = [html.request.var("site")]
+ else:
+ only_sites = None
+
# Now compute filter headers for all infos of the used datasource
for filter_name, filter_class in filter_registry.items():
filter_object = filter_class()
if filter_object.info in infos:
header = filter_object.filter(table)
- if header.startswith("Sites:"):
- only_sites = header.strip().split(" ")[1:]
- else:
- filter_headers += header
+ filter_headers += header
return filter_headers, only_sites