Module: check_mk
Branch: master
Commit: bf1ad637a2eec45e430636e92428024c426d8146
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bf1ad637a2eec4…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sat Oct 31 11:42:16 2015 +0100
#2671 df: avoid duplicate items for btrfs that is mounted several times
With SLES 12 btrfs has been introduced. Here one filesystem (e.g.
<tt>/dev/sda1</tt>) is
mounted at a lot of directories at the same times and Check_MK had created one service
for each of this - showing exactly the same stats. This has now been fixed so that only
one filesystem check is being created for each btrfs device. The service in our example
has the name <tt>Filesystem btrfs /dev/sda1</tt>. You need to redo service
discovery
or the affected hosts.
---
.werks/2671 | 14 ++++++++++++++
ChangeLog | 2 ++
checks/df | 26 +++++++++++++++++++++++++-
3 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/.werks/2671 b/.werks/2671
new file mode 100644
index 0000000..25f899e
--- /dev/null
+++ b/.werks/2671
@@ -0,0 +1,14 @@
+Title: df: avoid duplicate items for btrfs that is mounted several times
+Level: 1
+Component: checks
+Compatible: incomp
+Version: 1.2.7i4
+Date: 1446287956
+Class: feature
+
+With SLES 12 btrfs has been introduced. Here one filesystem (e.g.
<tt>/dev/sda1</tt>) is
+mounted at a lot of directories at the same times and Check_MK had created one service
+for each of this - showing exactly the same stats. This has now been fixed so that only
+one filesystem check is being created for each btrfs device. The service in our example
+has the name <tt>Filesystem btrfs /dev/sda1</tt>. You need to redo service
discovery
+or the affected hosts.
diff --git a/ChangeLog b/ChangeLog
index bf984d9..82b7f8f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,8 @@
* 2703 logwatch.ec: now transfers the service level to the event console...
* 2705 winperf_if: added option to warn if an interface is using dhcp...
* 2699 windows_tasks: new task success constant 'an instance of the task is
already running'
+ * 2671 df: avoid duplicate items for btrfs that is mounted several times...
+ NOTE: Please refer to the migration notes!
* 2660 FIX: fixed windows agent using the wrong working directory...
* 2664 FIX: ps: Speedup in situation with many matching processes...
* 2661 FIX: windows agent: fixed incomplete process list...
diff --git a/checks/df b/checks/df
index 74bbebc..0ab4b9c 100644
--- a/checks/df
+++ b/checks/df
@@ -37,10 +37,28 @@
# Data NTFS 976506816 528665344 447841472 55% D:\
# PS3 PlayStation(R)3 File System 0 0 0 0% P:\
+# An example with btrfs (SLES 12). Here the same device is mounted
+# several times at different mount point. But must only be monitored
+# once. We use the device instead of the mount point in this case.
+# <<<df>>>
+# /dev/sda1 btrfs 20970496 4169036 16539348 21% /
+# devtmpfs devtmpfs 497396 0 497396 0% /dev
+# tmpfs tmpfs 506312 0 506312 0% /dev/shm
+# tmpfs tmpfs 506312 6980 499332 2% /run
+# tmpfs tmpfs 506312 0 506312 0% /sys/fs/cgroup
+# /dev/sda1 btrfs 20970496 4169036 16539348 21% /.snapshots
+# /dev/sda1 btrfs 20970496 4169036 16539348 21% /var/tmp
+# /dev/sda1 btrfs 20970496 4169036 16539348 21% /var/spool
+# /dev/sda1 btrfs 20970496 4169036 16539348 21% /var/opt
+# /dev/sda1 btrfs 20970496 4169036 16539348 21% /var/log
+
+
def df_parse_info(info):
df_blocks = []
df_inodes = []
+ btrfs_devices = set() # We might generalize that later
lines = iter(info)
+
try:
is_inode = False
while True:
@@ -55,7 +73,13 @@ def df_parse_info(info):
# Handle known cases, where the file system contains spaces
if line[2] == "File" and line[3] == "System":
line = [ line[0], " ".join(line[1:4]) ] + line[4:]
- df_blocks.append(line)
+ if line[1] == "btrfs":
+ device = line[0]
+ if device not in btrfs_devices:
+ btrfs_devices.add(device)
+ df_blocks.append(line[:6] + [ "btrfs " + line[0] ]) #
replace mount point with device
+ else:
+ df_blocks.append(line)
else:
df_inodes.append(line)
except StopIteration: