ntfy_scripts/clouds_check.sh

22 lines
772 B
Bash
Raw Permalink Normal View History

2023-09-19 14:45:14 +02:00
#!/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"
2024-04-16 14:43:23 +02:00
topicurl=https://NTFY_SERVER_IP/cloud_alerts
2023-09-19 14:45:14 +02:00
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