Module: check_mk
Branch: master
Commit: 48338549bbe1956984abb72fe178612bb2c08d08
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=48338549bbe195…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon Jul 13 16:45:58 2015 +0200
#2402 FIX netapp_api_disk: fixed broken WATO and check configuration
Incorrect parameters were used within the WATO and the check configuration.
This check got an incomplete rework two months ago where naming for the parameters got
changed.
This fix is able to migrate any existing old configuration, so there are no further
changes required.
---
.werks/2402 | 11 ++++++++++
ChangeLog | 1 +
checks/netapp_api_disk | 19 +++++++++++-----
web/plugins/wato/check_parameters.py | 40 ++++++++++++++++++++++------------
4 files changed, 51 insertions(+), 20 deletions(-)
diff --git a/.werks/2402 b/.werks/2402
new file mode 100644
index 0000000..569b191
--- /dev/null
+++ b/.werks/2402
@@ -0,0 +1,11 @@
+Title: netapp_api_disk: fixed broken WATO and check configuration
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i3
+Date: 1436798438
+Class: fix
+
+Incorrect parameters were used within the WATO and the check configuration.
+This check got an incomplete rework two months ago where naming for the parameters got
changed.
+This fix is able to migrate any existing old configuration, so there are no further
changes required.
diff --git a/ChangeLog b/ChangeLog
index 28d0a2c..a5f96c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -47,6 +47,7 @@
* 2374 FIX: md: Fix exception for certain outputs of certain special MD
configurations...
* 2458 FIX: FreeBSD-Agent: Fixed uptime calculation
* 1271 FIX: omd_apache: Fixed handling of urls with whitespace
+ * 2402 FIX: netapp_api_disk: fixed broken WATO and check configuration...
Multisite:
* 2385 SEC: Fixed possible reflected XSS on all GUI pages where users can produce
unhandled exceptions...
diff --git a/checks/netapp_api_disk b/checks/netapp_api_disk
index 262f554..2a498bd 100644
--- a/checks/netapp_api_disk
+++ b/checks/netapp_api_disk
@@ -54,8 +54,13 @@ def check_netapp_api_disk_summary(_no_item, params, info):
"shelf-uids-of-disks":
{"block-name": "shelf-uid-instance",
"key":
"shelf-uid"}})
+ # Convert legacy levels
+ if "broken_spare_ratio" in params:
+ params = { "failed_spare_ratio": params["broken_spare_ratio"]
}
+
disks = disks_info.get("disk-list-info")
shelfs = disks_info.get("shelf-uids-of-disks")
+
# The device can contain disks who belongs to another filer. We only check the ones
# belonging to this filer.
# TODO Do we need that?
@@ -65,9 +70,10 @@ def check_netapp_api_disk_summary(_no_item, params, info):
def find_disk_shelf_uid(disk_uid):
if not disk_to_shelf_map:
for shelf, values in shelfs.items():
- disks = values["disks"].split(" ")
- for disk in disks:
- disk_to_shelf_map[disk] = shelf
+ if "disks" in values:
+ disks = values["disks"].split(" ")
+ for disk in disks:
+ disk_to_shelf_map[disk] = shelf
return disk_to_shelf_map.get(disk_uid)
disks_converted = []
@@ -81,8 +87,9 @@ def check_netapp_api_disk_summary(_no_item, params, info):
disk_info += " (Shelf: %s, Bay %s)" % (shelf_uid,
disk.get("bay"))
disk['identifier'] = disk_info
disk['type'] = False
- raid_type = disk.get("raid-type")
- if disk.get("raid-state", "") == "broken":
+ raid_type = disk.get("raid-type")
+ raid_state = disk.get("raid-state")
+ if raid_state == "broken":
disk['state'] = 'failed'
elif disk.get("prefailed", "false") not in [
"false", "None" ]:
disk['state'] = 'prefailed'
@@ -90,7 +97,7 @@ def check_netapp_api_disk_summary(_no_item, params, info):
disk['type'] = 'parity'
elif raid_type == "data":
disk['type'] = 'data'
- elif raid_type == "spare":
+ elif raid_state == "spare":
disk['state'] = "spare"
else:
disk['state'] = 'ok'
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 8841581..10eed13 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -6236,20 +6236,32 @@ register_check_parameters(
subgroup_storage,
"netapp_disks",
_("Filer Disk Levels (netapp, ibm svc)"),
- Dictionary(
- elements = [
- ( "broken_spare_ratio",
- Tuple(
- title = _("Broken to spare ratio"),
- help = _("You can set a limit to the broken to spare disk ratio.
"
- "The ratio is calculated with <i>broken / (broken +
spare)</i>."),
- elements = [
- Percentage(title = _("Warning at or above"), default_value
= 1.0),
- Percentage(title = _("Critical at or above"), default_value
= 50.0),
- ]
- )),
- ],
- optional_keys = False
+ Transform(
+ Dictionary(
+ elements = [
+ ( "failed_spare_ratio",
+ Tuple(
+ title = _("Failed to spare ratio"),
+ help = _("You can set a limit to the failed to spare disk
ratio. "
+ "The ratio is calculated with <i>spare / (failed
+ spare)</i>."),
+ elements = [
+ Percentage(title = _("Warning at or above"),
default_value = 1.0),
+ Percentage(title = _("Critical at or above"),
default_value = 50.0),
+ ]
+ )),
+ ( "offline_spare_ratio",
+ Tuple(
+ title = _("Offline to spare ratio"),
+ help = _("You can set a limit to the offline to spare disk
ratio. "
+ "The ratio is calculated with <i>spare /
(offline + spare)</i>."),
+ elements = [
+ Percentage(title = _("Warning at or above"),
default_value = 1.0),
+ Percentage(title = _("Critical at or above"),
default_value = 50.0),
+ ]
+ )),
+ ],
+ ),
+ forth = lambda a: "broken_spare_ratio" in a and
{"failed_spare_ratio": a["broken_spare_ratio"]} or a
),
None,
match_type = "dict",