Add ping/pushover scripts

This commit is contained in:
Jan 2023-06-07 13:22:28 +02:00
parent 2737a4e86d
commit 65275991de
1 changed files with 24 additions and 0 deletions

View File

@ -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
}