Zionetrix::Git
Repositories
Help
Report an Issue
gnokii-admin-scripts
Code
Commits
Branches
Tags
Search
Tree:
60e54b8
Branches
Tags
master
gnokii-admin-scripts
check_gnokii
Added network check in nagios plugin
Benjamin Renard
commited
60e54b8
at 2013-01-31 09:25:37
check_gnokii
Blame
History
Raw
#!/bin/bash # # Nagios plugin to check Gnokii USB modem state # # Author : Benjamin Renard <brenard@easter-eggs.com> # Date : Wed, 25 Jul 2012 18:33:33 +0200 # # Path to gnokii binary (default : /usr/bin/gnokii) GNOKII=/usr/bin/gnokii # Path to gnokii config file (default : /etc/gnokiirc) CONFIG=/etc/gnokiirc KEY=$( $GNOKII --config $CONFIG --identify 2>/dev/null|tr '\n' " "|grep IMEI|sed 's/IMEI *: \([0-9]*\) Manufacturer *: \(.*\) Model *: \(.*\) Product name.*Revision.*/\2 \3 \(IMEI \: \1\)/' ) if [ ! -n "$KEY" ] then echo "CRITICAL - USB key not detected" exit 2 fi PINSTATUS=$( $GNOKII --config $CONFIG --getsecuritycodestatus 2>/dev/null|grep "Security code status"|sed 's/Security code status: //' ) if [ "$PINSTATUS" == "waiting for PIN." ] then echo "CRITICAL - SIM Locked ! You have to unlocked SIM !" exit 2 elif [ "$PINSTATUS" != "nothing to enter." ] then echo "UNKNOWN - PIN status unkwown : $PINSTATUS" exit 3 fi 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