packages: nagios-plugin-check_multipath/nagios-plugin-check_multipath.sh - ...
glen
glen at pld-linux.org
Thu Sep 10 19:42:06 CEST 2009
Author: glen Date: Thu Sep 10 17:42:06 2009 GMT
Module: packages Tag: HEAD
---- Log message:
- make it parse also newer multipath tools
---- Files affected:
packages/nagios-plugin-check_multipath:
nagios-plugin-check_multipath.sh (1.12 -> 1.13)
---- Diffs:
================================================================
Index: packages/nagios-plugin-check_multipath/nagios-plugin-check_multipath.sh
diff -u packages/nagios-plugin-check_multipath/nagios-plugin-check_multipath.sh:1.12 packages/nagios-plugin-check_multipath/nagios-plugin-check_multipath.sh:1.13
--- packages/nagios-plugin-check_multipath/nagios-plugin-check_multipath.sh:1.12 Wed Apr 2 20:10:30 2008
+++ packages/nagios-plugin-check_multipath/nagios-plugin-check_multipath.sh Thu Sep 10 19:42:00 2009
@@ -8,9 +8,9 @@
#
# v1.0 20060220 gs new script
-PROGNAME=`basename $0`
-PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
-REVISION=`echo '$Revision$' | sed -e 's/[^0-9.]//g'`
+PROGNAME=${1##*/}
+PROGPATH=${0%/*}
+REVISION=$(echo '$Revision$' | sed -e 's/[^0-9.]//g')
. $PROGPATH/utils.sh
@@ -95,7 +95,7 @@
OUTPUT=$($MULTIPATH -l 2>/dev/null)
if [ $? != 0 ]; then
# Failed. grab more info why
- if [ $(id -un) != "root" ] && [ `$SUDO -l | grep -c multipath` -eq 0 ]; then
+ if [ $(id -un) != "root" ] && [ $($SUDO -l | grep -c multipath) -eq 0 ]; then
echo "MULTIPATH: UNKNOWN - sudo not configured"
exit $STATE_UNKNOWN
fi
@@ -113,7 +113,7 @@
PATHCOUNT=$(echo "$OUTPUT" | wc -l)
if [ $PATHCOUNT -eq 0 ]; then
echo "MULTIPATH: WARNING - No paths defined"
- exit $STATEWARNING
+ exit $STATE_WARNING
fi
FAILCOUNT=$(echo "$OUTPUT" | grep -c failed)
@@ -123,27 +123,74 @@
fi
if [ "$NUMPATHS" ]; then
- echo "$OUTPUT" | awk -vnumpaths=$NUMPATHS -vrc=0 -vlun= -vtargets=0 '
- /^\[/{next} # skip flags
- /^\\/{targets++; next} # count targets
- /^ \\/{next} # skip devinfo
- {
- # The LUN line
- # process if this is not first LUN
- if (lun && numpaths != targets) {
- printf("CRITICAL: %d of %d paths available for LUN %s\n", targets, numpaths, lun)
- rc = 1
+ # multipath-tools-0.4.8-0.12.amd64
+ # LUN-32 (36006016002c11800b2d9d4c3142adc11) dm-9 DGC ,RAID 10 [1]
+ # [size=4.0G][features=1 queue_if_no_path][hwhandler=1 emc] [2]
+ # \_ round-robin 0 [prio=0][active] [3]
+ # \_ 0:0:0:1 sdb 8:16 [active][undef] [4]
+ # \_ round-robin 0 [prio=0][enabled]
+ # \_ 0:0:1:1 sdg 8:96 [active][undef]
+ # multipath-tools-0.4.8-13.x86_64
+ # LUN-33 (36006016002c11800ec11344a7134dc11) dm-6 DGC,RAID 10 [1]
+ # size=30G features='1 queue_if_no_path' hwhandler='1 emc' wp=rw [2]
+ # |-+- policy='round-robin 0' prio=-1 status=active [3]
+ # | `- 1:0:1:0 sdc 8:32 active undef running [4]
+ # `-+- policy='round-robin 0' prio=-1 status=enabled
+ # `- 1:0:0:0 sdb 8:16 active undef running
+
+
+ echo "$OUTPUT" | awk -vnpaths=$NUMPATHS \
+ -vSTATE_OK=$STATE_OK \
+ -vSTATE_WARNING=$STATE_WARNING \
+ -vSTATE_CRITICAL=$STATE_CRITICAL \
+ -vSTATE_UNKNOWN=$STATE_UNKNOWN \
+ '
+ BEGIN {
+ nlun = -1;
+ }
+ /([0-9a-f]*) dm-[0-9]+/ { # find lun [1]
+ nlun++;
+ names[nlun] = $1 " " $2;
+ targets[nlun] = 0;
+ next;
+ }
+
+ /size=.*features=/ { # skip flags [2]
+ next
+ }
+
+ /prio=/ {
+ targets[nlun]++;
+ # skip first dev line [3]
+ next
+ }
+
+ /[#0-9]+:[#0-9]+:[#0-9]+:[#0-9]+ [^ ]+ [0-9]+:[0-9]/ { # second line with device [4]
+ next
+ }
+
+ END {
+ if (nlun == -1) {
+ print "MULTIPATH: No paths parsed from multipath output."
+ exit STATE_UNKNOWN;
}
- # reset counter
- targets = 0
- lun = $0
+ rc = STATE_OK;
+ for (i = 0; i <= nlun; i++) {
+ if (npaths != targets[i]) {
+ printf("CRITICAL: %d of %d paths available for LUN %s\n", targets[i], npaths, names[i])
+ rc = 1
+ }
+ }
+
+ if (rc) {
+ exit rc;
+ }
+ printf("Found %d LUNs each having %d paths OK\n", 1 + nlun, npaths);
+ exit rc;
}
- END { exit rc }
'
- if [ $? -gt 0 ]; then
- exit $STATE_CRITICAL
- fi
+ exit $?
fi
echo "MULTIPATH: OK - No failed paths"
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/nagios-plugin-check_multipath/nagios-plugin-check_multipath.sh?r1=1.12&r2=1.13&f=u
More information about the pld-cvs-commit
mailing list