Ping logger/alarm ================= Public domain ******************************************************************************** ### /usr/local/sbin/ping-alarm.sh #!/bin/bash REPLY="0" LOSS="1" if [ "$1" == "" ]; then IP="8.8.8.8" else IP="$1" fi while :; do /bin/ping -w 2 -c 1 $IP &> /dev/null if [ "$?" == "$LOSS" ]; then COUNT=$(expr $COUNT + 1 ) /usr/bin/mplayer /usr/share/sounds/pop.wav &> /dev/null if [ "$COUNT" == "1" ]; then echo "###############################################" date fi echo -n "$COUNT-" sleep 1 else if [ "$COUNT" != "0" ]; then echo date echo "###############################################" fi COUNT=0 sleep 1 fi done ******************************************************************************** ### /etc/rc.d/rc.local /usr/bin/env SCREENDIR="/root/.screen" /usr/bin/screen -dmS ping /usr/local/sbin/ping-alarm.sh /usr/bin/env SCREENDIR="/root/.screen" /usr/bin/screen -dmS test /usr/local/sbin/ping-alarm.sh 4.2.2.1 ******************************************************************************** _BY: Pejman Moghadam_ _TAG: ping, screen, bash-script, bash_ _DATE: 2012-12-10 15:11:12_