From 65275991de38b1674f3643a97d90fa84f35a9310 Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 7 Jun 2023 13:22:28 +0200 Subject: [PATCH] Add ping/pushover scripts --- zsh/scripts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/zsh/scripts b/zsh/scripts index e2fca07..c3581d1 100644 --- a/zsh/scripts +++ b/zsh/scripts @@ -98,3 +98,27 @@ function extract () { echo "'$1' is not a valid file" fi } + +# Monitor IP/Host and report with Pushover +pnotify-online() { + local ip_address="$1" + + while true; do + if ping -c 1 -W 1 "$ip_address" >/dev/null; then + echo "$1 is online now." + pushover "$1 is online now." + break + fi + done +} + +pnotify-offline() { + local ip_address="$1" + while true; do + if ! ping -c 1 -W 1 "$ip_address" >/dev/null; then + echo "$1 is offline now." + pushover "$1 is offline now." + break + fi + done +}