Module: check_mk
Branch: master
Commit: 4ad5d66dcbe369935605bbaf2e933757569dad1d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4ad5d66dcbe369…
Author: Florian Heigl <fh(a)mathias-kettner.de>
Date: Thu Sep 29 18:47:05 2011 +0200
nfs export check
---
agents/plugins/nfsexports | 18 ++++++++++++++++++
checks/nfsexports | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/agents/plugins/nfsexports b/agents/plugins/nfsexports
new file mode 100755
index 0000000..185de07
--- /dev/null
+++ b/agents/plugins/nfsexports
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# this check will only run if we have a working nfs environment or SHOULD have one.
+# not tested for nfs3
+
+# verify if there are exports defined in your local /etc/exports
+if [ -r /etc/exports ]; then
+ EXPORTS=$(grep -v -e ^# -e ^$ /etc/exports)
+fi
+pgrep portmap 1>/dev/null && pgrep rpc.mountd 1>/dev/null &&
DAEMONS="ok"
+
+# any exports or have running daemons? then look for registered exports
+if [[ $EXPORTS ]]; then
+ echo "<<<nfsexports>>>"
+ if [[ $DAEMONS ]]; then
+ waitmax 3 showmount --no-headers -e
+ fi
+fi
diff --git a/checks/nfsexports b/checks/nfsexports
new file mode 100644
index 0000000..8013fc3
--- /dev/null
+++ b/checks/nfsexports
@@ -0,0 +1,45 @@
+#!/usr/bin/python
+
+
+# This check verifies a given NFS export is registered with mountd.
+# Optionally we can add tracking of allowed clients and filesystem ID.
+
+# Agent info
+# [['/mirrored/data/recording', '172.0.0.0/255.0.0.0']]
+
+
+
+
+def inventory_nfsexports(checkname, info):
+ # reminder to self: inventorize the exported fs, and maybe even the fs id.
+ # but do not inventorize the allowed clients unless i'm really sure that
+ # it's not bugged for "features" like multiple different option exports
of
+ # same FS.
+ inventory = []
+ for line in info:
+ # will not inventorize unless there is SOME export at inventory time.
+ if line[0].startswith("/"):
+ inventory.append((line[0], None))
+
+ return inventory
+
+
+def check_nfsexports(item, _no_params, info):
+ # if the agent returned an empty list then it found entries in /etc/exports
+ # but apparently no daemons were running.
+ if len(info) == 0:
+ return (2, "CRITICAL - exports defined but no exports found in export list.
Daemons might not be working")
+
+ # otherwise lets see if our export exists.
+ for line in info:
+ exported_path = line[0]
+ if exported_path == item:
+ return (0, "OK - export is active")
+ return (2, "CRITICAL - export not found in export list")
+
+# return (3, "UNKNOWN - invalid data returned from Agent")
+
+
+
+
+check_info['nfsexports'] = (check_nfsexports, "NFS export %s", 0,
inventory_nfsexports)