Module: check_mk
Branch: master
Commit: 752396a0e7b5285818a3299788fb7fe7d490233e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=752396a0e7b528…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Dec 17 16:23:55 2013 +0100
FIX nfsmounts: correctly handle mount points with spaces
If you have a space in the name of your <b>moint point</b> (not in the name
of the export) then the Linux agent would show this mount point always as
<tt>hanging</tt>. The reason is that in <tt>/proc/mounts</tt>
spaces are
displayed as <tt>\040</tt>. This has now been fixed in the agent, which
outputs spaces correctly. Also the according check has been modified so that
it can deal with spaces in the names of the mount points.
---
.werks/350 | 15 +++++++++++++++
ChangeLog | 1 +
agents/check_mk_agent.linux | 1 +
checks/nfsmounts | 16 ++++++++++------
4 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/.werks/350 b/.werks/350
new file mode 100644
index 0000000..f3d4647
--- /dev/null
+++ b/.werks/350
@@ -0,0 +1,15 @@
+Title: nfsmounts: correctly handle mount points with spaces
+Level: 1
+Component: checks
+Class: fix
+State: unknown
+Version: 1.2.5i1
+Date: 1387293636
+Targetversion: future
+
+If you have a space in the name of your <b>moint point</b> (not in the name
+of the export) then the Linux agent would show this mount point always as
+<tt>hanging</tt>. The reason is that in <tt>/proc/mounts</tt>
spaces are
+displayed as <tt>\040</tt>. This has now been fixed in the agent, which
+outputs spaces correctly. Also the according check has been modified so that
+it can deal with spaces in the names of the mount points.
diff --git a/ChangeLog b/ChangeLog
index c67a9ac..d0b1e3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -56,6 +56,7 @@
* 0383 FIX: solaris_mem: Is now compatible to more systems...
* 0109 FIX: cisco_fantray: Prevent inventory for not available fans
* 0110 FIX: cisco_fru_power: Prevent inventory for not available FRUs
+ * 0350 FIX: nfsmounts: correctly handle mount points with spaces...
Multisite:
* 0371 Added log class filter to hostsvcevents view
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 2f67328..7c24e92 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -138,6 +138,7 @@ then
echo '<<<nfsmounts>>>'
sed -n '/ nfs4\? /s/[^ ]* \([^ ]*\) .*/\1/p' < /proc/mounts |
+ sed 's/\\040/ /g' |
while read MP
do
if [ $STAT_VERSION != $STAT_BROKE ]; then
diff --git a/checks/nfsmounts b/checks/nfsmounts
index 60df36b..e86cfa7 100644
--- a/checks/nfsmounts
+++ b/checks/nfsmounts
@@ -24,22 +24,26 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+# Example out from agent:
+# <<<nfsmounts>>>
+# /foobar hanging 0 0 0 0
+# /with spaces ok 217492 123563 112515 524288
def inventory_nfsmounts(info):
- return [ (line[0], None) for line in info ]
+ return [ (" ".join(line[:-5]), None) for line in info ]
def check_nfsmounts(item, _no_params, info):
for line in info:
- mountpoint = line[0]
+ mountpoint = " ".join(line[:-5])
if mountpoint == item:
- size_blocks = int(line[2])
- free_blocks = int(line[4]) # for non-root user
- blocksize = int(line[5])
+ size_blocks = int(line[-4])
+ free_blocks = int(line[-2]) # for non-root user
+ blocksize = int(line[-1])
if size_blocks < 0 or free_blocks < 0 or blocksize > 1024*1024:
return (2, "Stale NFS handle")
- if line[1] == 'ok':
+ if line[-5] == 'ok':
gb = 1024 * 1024 * 1024.0
size_gb = (size_blocks * blocksize) / gb
if size_gb == 0: