]> src.twobees.de Git - dotfiles.git/commitdiff
netchecker
authorTobias Sachs <git-pngdhxpf-ts@twobees.de>
Wed, 27 Sep 2023 20:06:45 +0000 (22:06 +0200)
committerTobias Sachs <git-pngdhxpf-ts@twobees.de>
Wed, 27 Sep 2023 20:06:45 +0000 (22:06 +0200)
stow/bin/.bin/netcheck.sh [new file with mode: 0755]

diff --git a/stow/bin/.bin/netcheck.sh b/stow/bin/.bin/netcheck.sh
new file mode 100755 (executable)
index 0000000..fc0b773
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+upOrDown=3 # 1 = down, 2 up , 3 unknown
+host="1.1.1.1"
+
+SLEEP_SECS=1
+while true
+do
+    
+    if ping -w 2 -c 1 "$host" > /dev/null 2>&1;
+    then
+        if [ $upOrDown -ne 2 ];then
+            upOrDown=2
+            echo "$(date) $host ok"
+        fi
+    else
+        if [ $upOrDown -ne 1 ];then
+            upOrDown=1
+            echo "$(date) $host NOT OK"
+        fi
+    fi
+    sleep $SLEEP_SECS
+done