SOURCES: nagios-plugin-check_multipath.sh - might need sudo for ls...

glen glen at pld-linux.org
Thu Oct 25 00:01:18 CEST 2007


Author: glen                         Date: Wed Oct 24 22:01:18 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- might need sudo for lsmod too

---- Files affected:
SOURCES:
   nagios-plugin-check_multipath.sh (1.4 -> 1.5) 

---- Diffs:

================================================================
Index: SOURCES/nagios-plugin-check_multipath.sh
diff -u SOURCES/nagios-plugin-check_multipath.sh:1.4 SOURCES/nagios-plugin-check_multipath.sh:1.5
--- SOURCES/nagios-plugin-check_multipath.sh:1.4	Wed Oct 24 23:57:12 2007
+++ SOURCES/nagios-plugin-check_multipath.sh	Thu Oct 25 00:01:13 2007
@@ -16,6 +16,7 @@
 
 MULTIPATH=/sbin/multipath
 SUDO=/usr/bin/sudo
+LSMOD=/sbin/lsmod
 
 print_usage() {
 	echo "Usage:"
@@ -33,7 +34,11 @@
 	echo "Requires sudo."
 	echo ""
 	echo "Add this to your sudoers file by running visudo to add access:"
-	echo "Cmnd_Alias MULTIPATH=$MULTIPATH -l"
+	if [ -r /proc/modules ]; then
+		echo "Cmnd_Alias MULTIPATH=$MULTIPATH -l"
+	else
+		echo "Cmnd_Alias MULTIPATH=$MULTIPATH -l, $SUDO"
+	fi
 	echo "nagios  ALL= NOPASSWD: MULTIPATH"
 	echo "The user nagios may very well be nobody or someone else depending on your configuration"
 	echo ""
@@ -72,9 +77,14 @@
 		exit $STATE_UNKNOWN
 	fi
 	MULTIPATH="$SUDO $MULTIPATH"
+
+	# on grsec kernel /proc might be protected
+	if [ ! -r /proc/modules ]; then
+		LSMOD="$SUDO $LSMOD"
+	fi
 fi
 
-MODCOUNT=`/sbin/lsmod | grep -c ^dm_multipath`
+MODCOUNT=`$LSMOD | grep -c ^dm_multipath`
 if [ $MODCOUNT -gt 0 ]; then
 	PATHCOUNT=`$MULTIPATH -l | wc -l`
 	if [ $PATHCOUNT -eq 0 ]; then
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/nagios-plugin-check_multipath.sh?r1=1.4&r2=1.5&f=u



More information about the pld-cvs-commit mailing list