ntfy_scripts/clouds_check.sh

22 lines
772 B
Bash
Executable File

#!/bin/bash
### this scripts checks if the login page of a nextcloud instance is reacheable, and alerts ntfy in case it cannot receive a "200 OK" response from the webserver
# written by tech_at_hangar.org
HOSTS="https://cloud.EXAMPLE.ORG/index.php,https://cloud.CHANGE.ME/index.php,https://nuvol.EIXAMPLE.CAT/index.php"
topicurl=https://NTFY_SERVER_IP/cloud_alerts
for i in ${HOSTS//,/ }
do
RESPONSE=$(wget --no-check-certificate "$i" 2>&1 | grep -wic "200 OK")
if [ ${RESPONSE} != 1 ]; then
curl -k --retry 3 \
-d "Cloud $i not online" \
-H "Title: Cloud $i has some problems" \
-H "Priority: high" \
-H "Tags: warning,boar" \
$topicurl
fi
done