+

Added network check in nagios plugin

Benjamin Renard [2013-01-31 09:25:37]
Added network check in nagios plugin
Filename
check_gnokii
diff --git a/check_gnokii b/check_gnokii
index 17d2993..f08a24e 100755
--- a/check_gnokii
+++ b/check_gnokii
@@ -30,5 +30,12 @@ then
 	exit 3
 fi

-echo "OK - Key : $KEY - SIM Unlocked"
+NETWORK=$( $GNOKII --config $CONFIG --monitor once 2> /dev/null|grep ^Network|sed 's/^Network: \([^(]*\).*$/\1/' )
+if [ "$NETWORK" == "" -o $( echo "$NETWORK"|grep -ic unknown ) -gt 0 ]
+then
+	echo "CRITICAL - Not connected (Network : $NETWORK)"
+	exit 2
+fi
+
+echo "OK - Key : $KEY - SIM Unlocked - Network : $NETWORK"
 exit 0
ViewGit