SOURCES: nagios-plugin-check_multipath.sh (NEW) - from nagiosexcha...

glen glen at pld-linux.org
Wed Oct 24 23:05:59 CEST 2007


Author: glen                         Date: Wed Oct 24 21:05:59 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- from nagiosexchange.org

---- Files affected:
SOURCES:
   nagios-plugin-check_multipath.sh (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/nagios-plugin-check_multipath.sh
diff -u /dev/null SOURCES/nagios-plugin-check_multipath.sh:1.1
--- /dev/null	Wed Oct 24 23:05:59 2007
+++ SOURCES/nagios-plugin-check_multipath.sh	Wed Oct 24 23:05:54 2007
@@ -0,0 +1,94 @@
+#!/bin/sh
+#
+# Nagios plugin to check the state of Linux device mapper multipath devices
+# 
+# (C) 2006 Riege Software International GmbH
+# Licensed under the General Public License, Version 2
+# Contact: Gunther Schlegel, schlegel at riege.com
+#
+# v1.0	20060220 gs	new script
+
+PROGNAME=`basename $0`
+PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
+REVISION=`echo '$Revision$' | sed -e 's/[^0-9.]//g'`
+
+. $PROGPATH/utils.sh
+
+MULTIPATH='/usr/bin/sudo /sbin/multipath'
+
+print_usage() {
+  echo "Usage:"
+  echo "  $PROGNAME"
+}
+
+print_help() {
+  print_revision $PROGNAME $REVISION
+  echo ""
+  print_usage
+  echo ""
+  echo "Check multipath status"
+  echo ""
+  echo "really simple: runs /sbin/multipath and greps for \"failed\" paths. No options yet."
+  echo "Requires sudo."
+  echo ""
+  echo "Add this to your sudoers file by running visudo to add access:"
+  echo "Cmnd_Alias MULTIPATH=/sbin/multipath -l"
+  echo "nagios  ALL= NOPASSWD: MULTIPATH"
+  echo "The user nagios may very well be nobody or someone else depending on your configuration"
+  echo ""
+  support
+}
+
+# Information options
+case "$1" in
+--help)
+		print_help
+    exit $STATE_OK
+    ;;
+-h)
+		print_help
+    exit $STATE_OK
+    ;;
+--version)
+		print_revision $PLUGIN $REVISION
+    exit $STATE_OK
+    ;;
+-V)
+		print_revision $PLUGIN $REVISION
+    exit $STATE_OK
+    ;;
+esac
+
+# check
+if [ `/usr/bin/sudo -l|grep -c multipath` -eq 0 ]; then 
+	echo "MULTIPATH: UNKNOWN - sudo not configured"
+	exit $STATE_UNKNOWN
+else 
+	if [  -x /sbin/multipath ]; then 
+		MODCOUNT=`/sbin/lsmod|grep -c ^dm_multipath`
+		if [ $MODCOUNT -gt 0 ]; then	
+			PATHCOUNT=`$MULTIPATH -l|wc -l`
+			if [ $PATHCOUNT -eq 0 ]; then
+				echo "MULTIPATH: WARNING - no paths defined"
+				exit $STATEWARNING
+			else 
+				FAILCOUNT=`$MULTIPATH -l|grep -c failed`
+				if [ $FAILCOUNT -eq 0 ]; then
+					echo "MULTIPATH: OK - no failed paths"
+					exit $STATE_OK
+				else
+					echo "MULTIPATH: CRITICAL - $FAILCOUNT paths failed"
+					exit $STATE_CRITICAL
+				fi
+			fi
+		else 
+			echo "MULTIPATH: UNKNOWN - module dm_multipath not loaded"
+			exit $STATE_UNKNOWN
+		fi	
+	else
+		echo "MULTIPATH: UNKNOWN - /sbin/multipath not found"
+		exit $STATE_UNKNOWN
+	fi
+fi
+
+# vim: ts=4
================================================================


More information about the pld-cvs-commit mailing list