Benjamin Renard authored 12 years ago
1) #!/bin/bash 2) # 3) # Nagios plugin to check Gnokii USB modem state 4) # 5) # Author : Benjamin Renard <brenard@easter-eggs.com> 6) # Date : Wed, 25 Jul 2012 18:33:33 +0200 7) # 8) 9) # Path to gnokii binary (default : /usr/bin/gnokii) 10) GNOKII=/usr/bin/gnokii 11) 12) # Path to gnokii config file (default : /etc/gnokiirc) 13) CONFIG=/etc/gnokiirc 14) 15) 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\)/' ) 16) if [ ! -n "$KEY" ] 17) then 18) echo "CRITICAL - USB key not detected" 19) exit 2 20) fi 21) 22) PINSTATUS=$( $GNOKII --config $CONFIG --getsecuritycodestatus 2>/dev/null|grep "Security code status"|sed 's/Security code status: //' ) 23) if [ "$PINSTATUS" == "waiting for PIN." ] 24) then 25) echo "CRITICAL - SIM Locked ! You have to unlocked SIM !" 26) exit 2 27) elif [ "$PINSTATUS" != "nothing to enter." ] 28) then 29) echo "UNKNOWN - PIN status unkwown : $PINSTATUS" 30) exit 3 31) fi 32)
33) NETWORK=$( $GNOKII --config $CONFIG --monitor once 2> /dev/null|grep ^Network|sed 's/^Network: \([^(]*\).*$/\1/' ) 34) if [ "$NETWORK" == "" -o $( echo "$NETWORK"|grep -ic unknown ) -gt 0 ] 35) then 36) echo "CRITICAL - Not connected (Network : $NETWORK)" 37) exit 2 38) fi 39) 40) echo "OK - Key : $KEY - SIM Unlocked - Network : $NETWORK"