Module: check_mk
Branch: master
Commit: 71b702e2755b95ac01b20f90747f59fa309c0848
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=71b702e2755b95…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Mar 10 16:09:48 2015 +0100
#2134 winperf_phydisk: allow device to appear more than one time in agent output
This can e.g. be the case in Windows clusters, where the drive letter
<tt>E:</tt> appears
three times. The check now adds up all counters of the three devices - just like in the
summary check.
---
.werks/2134 | 11 +++++++++++
ChangeLog | 1 +
checks/diskstat.include | 44 ++++++++++++++++++++------------------------
3 files changed, 32 insertions(+), 24 deletions(-)
diff --git a/.werks/2134 b/.werks/2134
new file mode 100644
index 0000000..4d1e882
--- /dev/null
+++ b/.werks/2134
@@ -0,0 +1,11 @@
+Title: winperf_phydisk: allow device to appear more than one time in agent output
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i1
+Date: 1426000114
+Class: feature
+
+This can e.g. be the case in Windows clusters, where the drive letter
<tt>E:</tt> appears
+three times. The check now adds up all counters of the three devices - just like in the
+summary check.
diff --git a/ChangeLog b/ChangeLog
index a11c426..19a0c19 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -119,6 +119,7 @@
* 1226 mysql: New check to show the version of the mysql deamon
* 2100 if64: check can now impose limits on the number of outgoing and incoming
non-unicast packets per second
* 1227 mysql_ping: New Check to detect misconfiguration of the mk_mysql plugin
+ * 2134 winperf_phydisk: allow device to appear more than one time in agent output...
* 1457 FIX: logins: new check renamed from "users" check...
NOTE: Please refer to the migration notes!
* 1762 FIX: lnx_thermal: Now ignoring trip points with level 0...
diff --git a/checks/diskstat.include b/checks/diskstat.include
index 9090f70..04813cd 100644
--- a/checks/diskstat.include
+++ b/checks/diskstat.include
@@ -212,33 +212,29 @@ def check_diskstat_generic(item, params, this_time, info,
mode='sectors'):
if item in [ 'read', 'write' ]:
return check_diskstat_old(item, params, this_time, info)
- # summary mode
- if item == 'SUMMARY': # summary mode (only summarize physical disks!)
- summary_line = [0] * 13
- if len(info) == 0:
- return 3, "No performance information about any disk found"
- for line in info:
- if line[0] != None:
- return 3, "summary mode not supported in a cluster"
- devname = line[1]
- if ' ' in devname:
- continue
- summary_line = map(lambda e: e[0] + int(e[1]), zip(summary_line, line[2:]))
- return check_diskstat_line(this_time, "SUMMARY", params, [None,
''] + summary_line, mode)
-
- # single mode
- result = ""
+ # Sum up either all physical disks (if item is "SUMMARY") or
+ # all entries matching the item in question. It is not a bug if
+ # a disk appears more than once. This can for example happen in
+ # Windows clusters - even if they are no Check_MK clusters.
+
+ summed_up = [0] * 13
+ matching = 0
+
for line in info:
- if line[1] == item: # this may happen several times for a cluster
- if result == "":
- result = check_diskstat_line(this_time, item, params, line, mode)
- else:
- result = (2, "more than one device found in cluster")
+ if item == 'SUMMARY' and line[0] != None:
+ return 3, "summary mode not supported in a cluster"
- if result != "":
- return result
+ elif item == 'SUMMARY' and ' ' in line[1]:
+ continue # skip non-physical disks
- return (3, "device missing")
+ elif item == 'SUMMARY' or line[1] == item:
+ matching += 1
+ summed_up = map(lambda e: e[0] + int(e[1]), zip(summed_up, line[2:]))
+
+ if matching == 0:
+ return 3, "No matching disk found"
+ else:
+ return check_diskstat_line(this_time, item, params, [None, ''] +
summed_up, mode)
# This is the legacy version of diskstat as used in <= 1.1.10.