Module: check_mk
Branch: master
Commit: ebf272809bdcdfee664decd2ca1198e6f228d237
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ebf272809bdcdf…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Oct 26 11:09:21 2017 +0200
5438 diskstat: Discovers a sort of diskless partitions which can be found on XEN virtual
setups
Change-Id: I193379fb8d42b46e0bf127f9f601b6e23dad75d2
---
.werks/5438 | 10 ++++++++++
agents/check_mk_agent.linux | 2 +-
checks/diskstat | 18 +++++++++++++++++-
checks/diskstat.include | 35 ++++++++++++++++++++---------------
web/plugins/wato/check_parameters.py | 1 +
5 files changed, 49 insertions(+), 17 deletions(-)
diff --git a/.werks/5438 b/.werks/5438
new file mode 100644
index 0000000..e716562
--- /dev/null
+++ b/.werks/5438
@@ -0,0 +1,10 @@
+Title: diskstat: Discovers a sort of diskless partitions which can be found on XEN
virtual setups
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1509008915
+Class: feature
+
+
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index f857fc1..0a94bdc 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -440,7 +440,7 @@ fi
# Performancecounter Platten
echo '<<<diskstat>>>'
date +%s
-egrep '
(x?[shv]d[a-z]*|cciss/c[0-9]+d[0-9]+|emcpower[a-z]+|dm-[0-9]+|VxVM.*|mmcblk.*|dasd[a-z]*|bcache[0-9]+|nvme[0-9]+n[0-9]+)
' < /proc/diskstats
+egrep '
(x?[shv]d[a-z]*[0-9]*|cciss/c[0-9]+d[0-9]+|emcpower[a-z]+|dm-[0-9]+|VxVM.*|mmcblk.*|dasd[a-z]*|bcache[0-9]+|nvme[0-9]+n[0-9]+)
' < /proc/diskstats
if type dmsetup >/dev/null ; then
echo '[dmsetup_info]'
dmsetup info -c --noheadings --separator ' ' -o name,devno,vg_name,lv_name
diff --git a/checks/diskstat b/checks/diskstat
index 175398a..b2edbe7 100644
--- a/checks/diskstat
+++ b/checks/diskstat
@@ -100,17 +100,32 @@
#
# Returns a pair of the timestamp and that dictionary
# parsed = timestamp, disks
+
+
+diskstat_diskless_pattern = re.compile("x?[shv]d[a-z]*[0-9]+")
+
+
def parse_diskstat(info):
timestamp_str, proc_diskstat, name_info = diskstat_extract_name_info(info)
timestamp = int(timestamp_str)
- disks = {}
+ # Here we discover real partitions and exclude them:
+ # Sort of partitions with disks - typical in XEN virtual setups.
+ # Eg. there are xvda1, xvda2, but no xvda...
+ device_names = [line[3] for line in proc_diskstat]
+ real_partitions = {device_name for device_name in device_names
+ if diskstat_diskless_pattern.match(device_name)
+ and re.sub('[0-9]+$', '', device_name)}
+ disks = {}
for node_name, major, minor, device, \
read_ios, read_merges, read_sectors, read_ticks, \
write_ios, write_merges, write_sectors, write_ticks, \
ios_in_prog, total_ticks, rq_ticks in proc_diskstat:
+ if device in real_partitions:
+ continue
+
if (node_name, int(major), int(minor)) in name_info:
device = name_info[(node_name, int(major), int(minor))]
@@ -259,6 +274,7 @@ def diskstat_extract_name_info(info):
for line in info:
if node == None:
node = line[0]
+
if line[1] == '[dmsetup_info]':
phase = 'dmsetup_info'
elif line[1] == '[vx_dsk]':
diff --git a/checks/diskstat.include b/checks/diskstat.include
index b5d7469..619b13d 100644
--- a/checks/diskstat.include
+++ b/checks/diskstat.include
@@ -43,9 +43,9 @@ diskstat_inventory = []
# ( [ 'summary', 'physical', 'lvm', 'vxvm' ], ALL_HOSTS
),
# ]
-def inventory_diskstat_generic(info):
+def inventory_diskstat_generic(parsed):
# Skip over on empty data
- if not info:
+ if not parsed:
return
# New style: use rule based configuration, defaulting to summary mode
@@ -70,23 +70,28 @@ def inventory_diskstat_generic(info):
if "legacy" in modes:
inventory += [ ( "read", None ), ( "write", None ) ]
- if "physical" in modes:
- inventory += [ (line[1], "diskstat_default_levels")
- for line in info
- if not ' ' in line[1] ]
+ for line in parsed:
+ name = line[1]
+ if "physical" in modes and \
+ not ' ' in name and \
+ not diskstat_diskless_pattern.match(name):
+ inventory.append((name, "diskstat_default_levels"))
- if "lvm" in modes:
- inventory += [ (line[1], "diskstat_default_levels")
- for line in info
- if line[1].startswith("LVM ") ]
+ if "lvm" in modes and \
+ name.startswith("LVM "):
+ inventory.append((name, "diskstat_default_levels"))
- if "vxvm" in modes:
- inventory += [ (line[1], "diskstat_default_levels")
- for line in info
- if line[1].startswith("VxVM ") ]
+ if "vxvm" in modes and \
+ name.startswith("VxVM "):
+ inventory.append((name, "diskstat_default_levels"))
- return inventory
+ if "diskless" in modes and \
+ diskstat_diskless_pattern.match(name):
+ # Sort of partitions with disks - typical in XEN virtual setups.
+ # Eg. there are xvda1, xvda2, but no xvda...
+ inventory.append((name, "diskstat_default_levels"))
+ return inventory
def check_diskstat_line(this_time, item, params, line, mode='sectors'):
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index df192cf..c346835 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -11752,6 +11752,7 @@ register_rule(
( "physical", _("Create a separate check for each physical
disk") ),
( "lvm", _("Create a separate check for each LVM volume
(Linux)") ),
( "vxvm", _("Creata a separate check for each VxVM volume
(Linux)") ),
+ ( "diskless", _("Creata a separate check for each partition
(XEN)") ),
],
default_value = [ 'summary' ],
),