summaryrefslogtreecommitdiff
path: root/roles/common/files/onmon.sh
diff options
context:
space:
mode:
Diffstat (limited to 'roles/common/files/onmon.sh')
-rw-r--r--roles/common/files/onmon.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/roles/common/files/onmon.sh b/roles/common/files/onmon.sh
new file mode 100644
index 0000000..66a7974
--- /dev/null
+++ b/roles/common/files/onmon.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+ping -nq -W 1 -c 1 1.1.1.1 > /dev/null 2>&1
+state=$?
+oldstate=$state
+
+while true; do
+ ping -nq -W 1 -c 1 1.1.1.1 > /dev/null 2>&1
+ state=$?
+
+ if [[ $oldstate -ne $state ]]; then
+ if [[ $state -eq 0 ]]; then
+ echo "Device went back online"
+ else
+ echo "Device went offline"
+ fi
+ fi
+
+ oldstate=$state
+ sleep 5
+done