[kwlug-disc] Moving away from Rogers Internet

Khalid Baheyeldin kb at 2bits.com
Fri Jul 25 22:16:06 EDT 2014


And I tried to be too smart, and wrote a script that will notify me on my
Gmail account.

But, I forgot to run it with nohup, so it aborted and was not running to
inform anyone ...


#!/bin/sh

MAIL=yourmail at gmail.com
HOST=1.1.1.1 # Your external IP address

PING_SECS=60
PING_CHECK_COUNT=5

PING_FAIL_COUNT=0
while true
do
  sleep $PING_SECS

  fping -q $HOST
  if [ "$?" != 0 ]; then
    PING_FAIL_COUNT=`expr $PING_FAIL_COUNT + 1`
  else
    # Reset the counter
    PING_FAIL_COUNT=0
  fi

  # If ping fails for 5 times in a row, notify
  if [ $PING_FAIL_COUNT -gt $PING_CHECK_COUNT ]; then
    echo "$PING_CHECK_COUNT consecutive failures ... sending notification!"
    mail -s "Internet is not working!" $MAIL <<EOF
The internet connection is not working.

Inform your techie-in-residence now!
Make sure you inform them verbally, in person, NOT by
email, and not by a VoIP line.
EOF
    echo "Notification sent. Exiting!"
    exit
  fi
done
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20140725/b9195454/attachment.htm>


More information about the kwlug-disc mailing list