Module: check_mk
Branch: master
Commit: 58c5af1b7acfdbaae139fa45530a28fe6756931b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=58c5af1b7acfdb…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Jan 30 11:43:43 2017 +0100
4294 statgrab_disk: works now as other diskstat check plugins
Change-Id: I91fa78aa1e7abc9d6b3c65359cb6620dd748b349
---
.werks/4294 | 17 +++++++++++++
ChangeLog | 2 ++
checks/statgrab_disk | 69 +++++++++++++++++++++++++++++++++++++---------------
3 files changed, 68 insertions(+), 20 deletions(-)
diff --git a/.werks/4294 b/.werks/4294
new file mode 100644
index 0000000..100e2ff
--- /dev/null
+++ b/.werks/4294
@@ -0,0 +1,17 @@
+Title: statgrab_disk: Works now in the same way as other diskstat check plugins
+Level: 1
+Component: checks
+Compatible: incomp
+Version: 1.4.0i4
+Date: 1485251642
+Class: feature
+
+Reconstructed statgrab_disk check plugin: {{read}} and {{write}} values
+will be handled in one service as in other diskstat check plugins.
+Moreover the check has a discovery rule within which you can specify whether
+a summary service or services for each disk are generated. Default is
+summary mode.
+
+In order to make the new check plugin work you have to perform a
+re-discovery on the affected hosts.
+
diff --git a/ChangeLog b/ChangeLog
index f927788..cbfff19 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,8 @@
* 4257 logwatch.groups: now allows regular expressions within include and exclude
patterns each beginning with a tilde
* 4013 Ruckus Spot / ruckus_spot_locations: new check to monitor the number of unqiue
MACs addresses...
* 4293 wut_webtherm: now detects devices which support WebGraphThermoBaro-MIB
+ * 4294 statgrab_disk: Works now in the same way as other diskstat check plugins...
+ NOTE: Please refer to the migration notes!
* 4296 mssql_databases: new check which monitors the auto close and shrink state of
MSSQL databases...
* 4215 hp_webmgmt_status: Now also displays device model and serial number
* 4332 check_http: Add support for TLSv1.1 and TLSv1.2 as configuration option...
diff --git a/checks/statgrab_disk b/checks/statgrab_disk
index d60a290..881401c 100644
--- a/checks/statgrab_disk
+++ b/checks/statgrab_disk
@@ -24,31 +24,60 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-def inventory_statgrab_disk(info):
+
+# <<<statgrab_disk>>>
+# 1/md0.disk_name 1/md0
+# 1/md0.read_bytes 611352576
+# 1/md0.systime 1471423620
+# 1/md0.write_bytes 39462400
+# 1/md1.disk_name 1/md1
+# 1/md1.read_bytes 611352576
+# 1/md1.systime 1471423620
+# 1/md1.write_bytes 39462400
+# 1/md2.disk_name 1/md2
+# 1/md2.read_bytes 611351552
+
+
+def parse_statgrab_disk(info):
+ parsed = {}
for line in info:
- if line[0].endswith('read_bytes') or
line[0].endswith('write_bytes'):
- return [ ('read', None), ('write', None) ]
- return []
+ disk_name = line[0].split(".")[0]
+ parsed.setdefault(disk_name, {})
+
+ if line[0].endswith('read_bytes'):
+ parsed[disk_name]["read_bytes"] = int(line[1])
+
+ elif line[0].endswith('write_bytes'):
+ parsed[disk_name]["write_bytes"] = int(line[1])
+
+ elif line[0].endswith("systime"):
+ parsed[disk_name]["systime"] = int(line[1])
+
+ return parsed
+
+
+def inventory_statgrab_disk(parsed):
+ return inventory_diskstat_generic([[None, item] for item in parsed])
-def check_statgrab_disk(item, _no_params, info):
- # item is 'read' or 'write'
- if item != 'read' and item != "write":
- return (3, "invalid item %s" % (item,))
- this_val = 0
- for var, value in info:
- if var.endswith("." + item + "_bytes"):
- this_val += int(value)
+def check_statgrab_disk(item, params, parsed):
+ now = time.time()
+ disks = {}
+ for disk_name, attrs in parsed.items():
+ disks[disk_name] = {
+ "read_throughput" : get_rate("statgrab_disk.read.%s" %
item, now, attrs["read_bytes"]),
+ "write_throughput" : get_rate("statgrab_disk.write.%s" %
item, now, attrs["write_bytes"]),
+ }
- this_time = int(time.time())
- bytes_per_sec = get_rate("diskstat." + item, this_time, this_val)
- perfdata = [ (item, bytes_per_sec) ]
- return 0, "%s/s" % get_bytes_human_readable(bytes_per_sec), perfdata
+ return check_diskstat_dict(item, params, disks)
check_info["statgrab_disk"] = {
- 'check_function': check_statgrab_disk,
- 'inventory_function': inventory_statgrab_disk,
- 'service_description': 'Disk IO %s',
- 'has_perfdata': True,
+ 'parse_function' : parse_statgrab_disk,
+ 'inventory_function' : inventory_statgrab_disk,
+ 'check_function' : check_statgrab_disk,
+ 'service_description' : 'Disk IO %s',
+ 'has_perfdata' : True,
+ 'group' : 'diskstat',
+ 'includes' : [ "diskstat.include" ],
}