summaryrefslogtreecommitdiff
path: root/checkaddr.sh
diff options
context:
space:
mode:
Diffstat (limited to 'checkaddr.sh')
-rwxr-xr-xcheckaddr.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/checkaddr.sh b/checkaddr.sh
new file mode 100755
index 0000000..1b636f9
--- /dev/null
+++ b/checkaddr.sh
@@ -0,0 +1,27 @@
+#!/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