Module: check_mk
Branch: master
Commit: 6a44cabe5c745188e71d2846385d1b893a0c939d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6a44cabe5c7451…
Author: Florian Kromer <fk(a)mathias-kettner.de>
Date: Thu Mar 7 16:30:58 2019 +0100
ucs_c_rack_server_health: Make check reliable against namespace conflict
Change-Id: Ia1b4873ae66fd05be633236f56147719dd7b4389
---
checks/ucs_c_rack_server_health | 24 ++++++-------
.../datasets/ucs_c_rack_server_health.py | 42 ++++++++++++----------
2 files changed, 36 insertions(+), 30 deletions(-)
diff --git a/checks/ucs_c_rack_server_health b/checks/ucs_c_rack_server_health
index f3ff547..05aa57b 100644
--- a/checks/ucs_c_rack_server_health
+++ b/checks/ucs_c_rack_server_health
@@ -30,18 +30,6 @@
# storageControllerHealth<TAB>dn
# sys/rack-unit-2/board/storage-SAS-SLOT-HBA/vd-0 <TAB>id SLOT-HBA<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):
"""
@@ -72,6 +60,18 @@ 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.
"""
+ # 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,
+ }
+
try:
status = health_to_status_mapping[health]
status_readable = health
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
index 52cf0de..5b05c59 100644
--- a/tests/unit/checks/generictests/datasets/ucs_c_rack_server_health.py
+++ b/tests/unit/checks/generictests/datasets/ucs_c_rack_server_health.py
@@ -1,20 +1,26 @@
+# yapf: disable
+
+
checkname = 'ucs_c_rack_server_health'
-info = [[
- 'storageControllerHealth', 'dn
sys/rack-unit-1/board/storage-SAS-SLOT-HBA/vd-0', 'id SLOT-HBA',
- 'health Good'
-],
- [
- 'storageControllerHealth', 'dn
sys/rack-unit-2/board/storage-SAS-SLOT-HBA/vd-0',
- 'id SLOT-HBA', '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]', [])])]
-}
+
+info = [['storageControllerHealth',
+ 'dn sys/rack-unit-1/board/storage-SAS-SLOT-HBA/vd-0',
+ 'id SLOT-HBA',
+ 'health Good'],
+ ['storageControllerHealth',
+ 'dn sys/rack-unit-2/board/storage-SAS-SLOT-HBA/vd-0',
+ 'id SLOT-HBA',
+ '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]', [])])]}
\ No newline at end of file