ntfy_scripts/ping_check.sh

21 lines
585 B
Bash
Executable File

#!/bin/bash
### This script checks for available ping response from HOST_IP and alerts ntfy in case they're not responding
HOSTS="IP_HOST_1,IP_HOST_2,IP_HOST_3"
topicurl=https://NTFY_SERVER_IP/net_alerts
for i in ${HOSTS//,/ }
do
LAST_PINGS=$(ping -c 5 "$i" | grep -wic "Unreachable")
if [ ${LAST_PINGS} != 0 ]; then
curl -k --retry 3 \
-d "Ping lost with $i" \
-H "Title: Ping lost with $i" \
-H "Priority: high" \
-H "Tags: warning,boar" \
$topicurl
fi
done