This repository has been archived on 2024-11-01. You can view files and clone it, but cannot push or open issues or pull requests.
services/healthcheck/data/http

56 lines
1.3 KiB
Text
Raw Normal View History

2022-11-24 14:22:31 +00:00
#!/usr/bin/sh
cd /opt/ || exit
hc_url="https://hc-ping.com/$HTTP_HC_UID"
2023-11-19 04:59:30 +00:00
services_down=""
2022-11-24 14:22:31 +00:00
error=""
alias curl_hc='curl -LA "$USER_AGENT" --retry 3'
check_url ()
{
2023-11-19 04:59:30 +00:00
url="https://$1$2"
printf "checking url %s ." "$url"
2022-11-24 14:22:31 +00:00
dig A "$1" >/dev/null
2023-11-19 04:59:30 +00:00
printf "."
result=$(curl -LsSfv "$url" 2>&1)
code="$?"
printf ".\n"
#shellcheck disable=SC2181
if [ "$code" = "0" ]
2022-11-24 14:22:31 +00:00
then
echo "... good"
else
2023-11-19 04:59:30 +00:00
services_down=$(printf "%s\n%s" "$services_down" "$1")
error=$(printf "%s\n==========\n%s:\n%s" "$error" "$1" "$result")
2022-11-24 14:22:31 +00:00
echo "... bad"
fi
}
2023-12-08 00:55:57 +00:00
check_url "acme.serguzim.me" "/health"
2022-11-24 14:22:31 +00:00
check_url "analytics.serguzim.me"
check_url "auth.serguzim.me"
check_url "ci.serguzim.me"
2023-11-19 04:59:30 +00:00
#check_url "cloud.serguzim.me" "/login?noredir=1"
2022-11-24 14:22:31 +00:00
check_url "git.serguzim.me"
check_url "graph.serguzim.me"
check_url "hook.serguzim.me"
check_url "mail.serguzim.me"
2023-06-13 08:59:25 +00:00
#check_url "msrg.cc" # disabled because it keeps creating false alerts
2023-11-19 04:59:30 +00:00
check_url "prometheus.serguzim.me" "/-/healthy"
check_url "registry.serguzim.me" "/account/sign-in"
2022-11-24 14:22:31 +00:00
check_url "rss.serguzim.me"
2023-06-13 08:59:25 +00:00
#check_url "serguzim.me" # disabled because it keeps creating false alerts
2023-01-01 15:35:14 +00:00
check_url "tick.serguzim.me"
2022-11-24 14:22:31 +00:00
check_url "wiki.serguzim.me"
check_url "www.reitanlage-oranienburg.de"
if [ "$error" = "" ]
then
2023-11-19 04:59:30 +00:00
curl_hc "$hc_url" >/dev/null
echo "ALL GOOD"
2022-11-24 14:22:31 +00:00
else
2023-11-19 04:59:30 +00:00
curl_hc --data-raw "$services_down$error" "$hc_url/fail" >/dev/null
2022-11-24 14:22:31 +00:00
fi