#!/bin/bash
if [ -z "$1" ] ; then
IP=8.8.8.8
else
IP=$1
fi
STATE=-1
while true ; do
ping -c 1 -t 5 $IP > /dev/null
STATUS=$?
if [ $STATUS -ne $STATE ] ; then
STATE=$STATUS
if [ $STATE -eq 0 ] ; then
echo $(date): Connnected to $IP
else
echo $(date): Disconnected from $IP
fi
fi
sleep 60
done