commit bc8e3a73697d0ab5eced59b944ef5cd70686d8b3
Author: Elan Ruusamäe <[email protected]>
Date:   Wed Oct 24 09:28:56 2012 +0300

    v0.2: improve logic to detect permission errors

 check_vserver_count.sh                 | 35 +++++++++++++++++++++++++++-------
 nagios-plugin-check_vserver_count.spec |  2 +-
 2 files changed, 29 insertions(+), 8 deletions(-)
---
diff --git a/nagios-plugin-check_vserver_count.spec 
b/nagios-plugin-check_vserver_count.spec
index b4f71a6..3ec4844 100644
--- a/nagios-plugin-check_vserver_count.spec
+++ b/nagios-plugin-check_vserver_count.spec
@@ -2,7 +2,7 @@
 %define                plugin  check_vserver_count
 Summary:       Nagios plugin to check vserver count
 Name:          nagios-plugin-%{plugin}
-Version:       0.1
+Version:       0.2
 Release:       1
 License:       GPL v2
 Group:         Networking
diff --git a/check_vserver_count.sh b/check_vserver_count.sh
index 33d02d4..7db7f68 100755
--- a/check_vserver_count.sh
+++ b/check_vserver_count.sh
@@ -10,13 +10,34 @@ if [ ! -e "$UTIL_VSERVER_VARS" ] ; then
 fi
 . "$UTIL_VSERVER_VARS"
 
-shouldrun=$(grep . $__CONFDIR/*/apps/init/mark | wc -l)
+# check files so that we are able to understand permission errors
+errors=""
+shouldrun=0
+for markfile in $(ls -1 $__CONFDIR/*/apps/init/mark 2>/dev/null); do
+       vs=${markfile%/apps/init/mark}
+       vs=${vs#$__CONFDIR/}
+       marked=$(grep . $markfile)
+       if [ $? != 0 -a $? != 1 ]; then
+               errors="$errors $vs"
+       else
+               shouldrun=$((shouldrun + 1))
+       fi
+       marks="$marks $markfile"
+done
+errors=${errors# }
+
 running=$(awk '/Active/{ print $2 }' /proc/virtual/status)
 
-if [ $shouldrun = $running ]; then
-       echo "OK: running $running out of $shouldrun vservers"
-       exit 0
-else
-       echo "CRITICAL: running $running out of $shouldrun vservers"
-       exit 2
+rc=0
+status=OK
+
+if [ $running -lt $shouldrun ]; then
+       rc=2
+       status="CRITICAL"
+elif [ $running != $shouldrun ]; then
+       rc=1
+       status="WARNING"
 fi
+
+echo "$status: running $running out of $shouldrun vservers.${errors:+ (Error 
checking vservers: $errors)}"
+exit $rc
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/nagios-plugin-check_vserver_count.git/commitdiff/bc8e3a73697d0ab5eced59b944ef5cd70686d8b3

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to