Module: check_mk
Branch: master
Commit: b56e15fe5e142dc4adf3894d9dd5796e87dbb83f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b56e15fe5e142d…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Feb 17 12:52:06 2016 +0100
#2993 FIX zfs_arc_cache: fixed crash, no longer reports unknown if not all data is
available
Fixed division by zero exception. Some zfs systems do not report all data, the check
is now able to tolerate this.
---
.werks/2993 | 11 +++++++++
ChangeLog | 1 +
checks/zfs_arc_cache | 60 +++++++++++++-------------------------------------
3 files changed, 27 insertions(+), 45 deletions(-)
diff --git a/.werks/2993 b/.werks/2993
new file mode 100644
index 0000000..d22ec12
--- /dev/null
+++ b/.werks/2993
@@ -0,0 +1,11 @@
+Title: zfs_arc_cache: fixed crash, no longer reports unknown if not all data is
available
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.9i1
+Date: 1455709812
+Class: fix
+
+Fixed division by zero exception. Some zfs systems do not report all data, the check
+is now able to tolerate this.
+
diff --git a/ChangeLog b/ChangeLog
index 01c621d..467df0c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -26,6 +26,7 @@
* 3217 FIX: fortigate_sessions: Fixed exception in case of empty data provided by the
device
* 3186 FIX: fortigate_node: fixed empty item
NOTE: Please refer to the migration notes!
+ * 2993 FIX: zfs_arc_cache: fixed crash, no longer reports unknown if not all data is
available...
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/checks/zfs_arc_cache b/checks/zfs_arc_cache
index 4c038e0..b529191 100644
--- a/checks/zfs_arc_cache
+++ b/checks/zfs_arc_cache
@@ -116,60 +116,30 @@ def inventory_zfs_arc_cache(parsed):
return []
def check_zfs_arc_cache(_no_item, _no_params, parsed):
- status = 0
- perfdata = []
- message = "ZFS arc cache:"
-
- # hit ratio
- if "hits" in parsed.keys() and "misses" in parsed.keys():
- hit_ratio = float(parsed["hits"]) / (parsed["hits"] +
parsed["misses"]) * 100
- message += " hit ratio: %0.2f %%" % hit_ratio
- perfdata.append(("hit_ratio", "%0.2f" % hit_ratio,
'', '', 0, 100))
- else:
- message += " no info about hit ratio available"
- perfdata.append(("hit_ratio", 0, '', '', 0, 100))
- status = 3
-
- # prefetch data hit ratio
- if "prefetch_data_hits" in parsed.keys() and
"prefetch_data_misses" in parsed.keys():
- prefetch_data_hit_ratio = float(parsed["prefetch_data_hits"]) /
(parsed["prefetch_data_hits"] + parsed["prefetch_data_misses"]) * 100
- message += ", prefetch data hit ratio: %0.2f %%" %
prefetch_data_hit_ratio
- perfdata.append(("prefetch_data_hit_ratio", "%0.2f" %
prefetch_data_hit_ratio, '', '', 0, 100))
- else:
- message += ", no info about prefetch data hit ratio available"
- perfdata.append(("prefetch_data_hit_ratio", 0, '', '',
0, 100))
- status = 3
-
- # prefetch metadata hit ratio
- if "prefetch_metadata_hits" in parsed.keys() and
"prefetch_metadata_misses" in parsed.keys():
- prefetch_metadata_hit_ratio = float(parsed["prefetch_metadata_hits"]) /
(parsed["prefetch_metadata_hits"] +
parsed["prefetch_metadata_misses"]) * 100
- message += ", prefetch metadata hit ratio: %0.2f %%" %
prefetch_metadata_hit_ratio
- perfdata.append(("prefetch_metadata_hit_ratio", "%0.2f" %
prefetch_metadata_hit_ratio, '', '', 0, 100))
- else:
- message += ", no info about prefetch metadata hit ratio available"
- perfdata.append(("prefetch_metadata_hit_ratio", 0, '',
'', 0, 100))
- status = 3
+ for key in [ "", "prefetch_data_", "prefetch_metadata_"
]:
+ human_key = key.replace("_", " ")
+ total_hits_misses = parsed["%shits" % key] +
parsed["%smisses" % key]
+ if not total_hits_misses:
+ yield 0, " No %sHits or Misses" % human_key,
[("%shit_ratio" % key, 0, '', '', 0, 100)]
+ else:
+ hit_ratio = float(parsed["%shits" % key]) / total_hits_misses *
100
+ yield 0, " %sHit Ratio: %0.2f %%" % (human_key.title(), hit_ratio),
[("%shit_ratio" % key, "%0.2f" % hit_ratio, '', '', 0,
100)]
# size
if "size" in parsed.keys():
- message += ", cache size: %d MB" % parsed["size"]
- perfdata.append(("size", parsed["size"] * 1024 * 1024,
'', '', 0))
- else:
- message += ", no info about cache size available"
- perfdata.append(("size", 0, '', '', 0))
- status = 3
+ yield 0, "Cache size: %d MB" % parsed["size"],
[("size", parsed["size"] * 1024 * 1024, '', '', 0)]
# arc_meta
# these values may be missing, this is ok too
# in this case just do not report these values
if "arc_meta_used" in parsed.keys() and "arc_meta_limit" in
parsed.keys() and "arc_meta_max" in parsed.keys():
- message += ", arc meta %d MB used, limit %d MB, max %d MB" \
- % (parsed["arc_meta_used"],
parsed["arc_meta_limit"], parsed["arc_meta_max"])
- perfdata.append(("arc_meta_used", parsed["arc_meta_used"] *
1024 * 1024, '', '', 0))
- perfdata.append(("arc_meta_limit", parsed["arc_meta_limit"] *
1024 * 1024, '', '', 0))
- perfdata.append(("arc_meta_max", parsed["arc_meta_max"] *
1024 * 1024, '', '', 0))
+ yield 0, "Arc Meta %d MB used, Limit %d MB, Max %d MB" \
+ % (parsed["arc_meta_used"],
parsed["arc_meta_limit"], parsed["arc_meta_max"]),[
+ ("arc_meta_used", parsed["arc_meta_used"] * 1024 * 1024,
'', '', 0),
+ ("arc_meta_limit", parsed["arc_meta_limit"] * 1024 * 1024,
'', '', 0),
+ ("arc_meta_max", parsed["arc_meta_max"] * 1024 * 1024,
'', '', 0)
+ ]
- return status, message, perfdata
check_info["zfs_arc_cache"] = {
"parse_function" : parse_zfs_arc_cache,