Improve utils and healthchecks
This commit is contained in:
parent
ccf7f7a598
commit
ac40d18f67
4 changed files with 33 additions and 14 deletions
|
@ -24,3 +24,9 @@ lego -a --email "tobias@msrg.cc" \
|
||||||
--dns "acme-dns" \
|
--dns "acme-dns" \
|
||||||
--domains "$domain" \
|
--domains "$domain" \
|
||||||
"$action"
|
"$action"
|
||||||
|
|
||||||
|
# Copy registry.serguzim.me files to harbor data directory
|
||||||
|
if [ "$domain" = "registry.serguzim.me" ]; then
|
||||||
|
sudo cp "$LEGO_WORKING_PATH/certificates/registry.serguzim.me.crt" /opt/services/harbor/data/secret/cert/server.crt
|
||||||
|
sudo cp "$LEGO_WORKING_PATH/certificates/registry.serguzim.me.key" /opt/services/harbor/data/secret/cert/server.key
|
||||||
|
fi
|
||||||
|
|
|
@ -1,24 +1,29 @@
|
||||||
#!/usr/bin/sh
|
#!/usr/bin/sh
|
||||||
|
|
||||||
set -e
|
|
||||||
cd /opt/ || exit
|
cd /opt/ || exit
|
||||||
|
|
||||||
hc_url="https://hc-ping.com/$HTTP_HC_UID"
|
hc_url="https://hc-ping.com/$HTTP_HC_UID"
|
||||||
|
services_down=""
|
||||||
error=""
|
error=""
|
||||||
|
|
||||||
alias curl_hc='curl -LA "$USER_AGENT" --retry 3'
|
alias curl_hc='curl -LA "$USER_AGENT" --retry 3'
|
||||||
|
|
||||||
check_url ()
|
check_url ()
|
||||||
{
|
{
|
||||||
url="https://$1"
|
url="https://$1$2"
|
||||||
echo "checking url $url ..."
|
printf "checking url %s ." "$url"
|
||||||
dig A "$1" >/dev/null
|
dig A "$1" >/dev/null
|
||||||
if curl_hc -sSf "$url" >/dev/null 2>&1
|
printf "."
|
||||||
|
result=$(curl -LsSfv "$url" 2>&1)
|
||||||
|
code="$?"
|
||||||
|
printf ".\n"
|
||||||
|
#shellcheck disable=SC2181
|
||||||
|
if [ "$code" = "0" ]
|
||||||
then
|
then
|
||||||
echo "... good"
|
echo "... good"
|
||||||
else
|
else
|
||||||
result=$(curl -Lv "$url" 2>&1)
|
services_down=$(printf "%s\n%s" "$services_down" "$1")
|
||||||
error=$(printf "%s\n==========\n%s:\n%s" "$error" "$url" "$result")
|
error=$(printf "%s\n==========\n%s:\n%s" "$error" "$1" "$result")
|
||||||
echo "... bad"
|
echo "... bad"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -26,14 +31,14 @@ check_url ()
|
||||||
check_url "analytics.serguzim.me"
|
check_url "analytics.serguzim.me"
|
||||||
check_url "auth.serguzim.me"
|
check_url "auth.serguzim.me"
|
||||||
check_url "ci.serguzim.me"
|
check_url "ci.serguzim.me"
|
||||||
check_url "cloud.serguzim.me"
|
#check_url "cloud.serguzim.me" "/login?noredir=1"
|
||||||
check_url "git.serguzim.me"
|
check_url "git.serguzim.me"
|
||||||
check_url "graph.serguzim.me"
|
check_url "graph.serguzim.me"
|
||||||
check_url "hook.serguzim.me"
|
check_url "hook.serguzim.me"
|
||||||
check_url "mail.serguzim.me"
|
check_url "mail.serguzim.me"
|
||||||
#check_url "msrg.cc" # disabled because it keeps creating false alerts
|
#check_url "msrg.cc" # disabled because it keeps creating false alerts
|
||||||
check_url "prometheus.serguzim.me/-/healthy"
|
check_url "prometheus.serguzim.me" "/-/healthy"
|
||||||
check_url "registry.serguzim.me/account/sign-in"
|
check_url "registry.serguzim.me" "/account/sign-in"
|
||||||
check_url "rss.serguzim.me"
|
check_url "rss.serguzim.me"
|
||||||
#check_url "serguzim.me" # disabled because it keeps creating false alerts
|
#check_url "serguzim.me" # disabled because it keeps creating false alerts
|
||||||
check_url "tick.serguzim.me"
|
check_url "tick.serguzim.me"
|
||||||
|
@ -42,7 +47,8 @@ check_url "www.reitanlage-oranienburg.de"
|
||||||
|
|
||||||
if [ "$error" = "" ]
|
if [ "$error" = "" ]
|
||||||
then
|
then
|
||||||
curl_hc "$hc_url"
|
curl_hc "$hc_url" >/dev/null
|
||||||
|
echo "ALL GOOD"
|
||||||
else
|
else
|
||||||
curl_hc --data-raw "$error" "$hc_url/fail"
|
curl_hc --data-raw "$services_down$error" "$hc_url/fail" >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,9 +1,17 @@
|
||||||
#!/usr/bin/sh
|
#!/usr/bin/sh
|
||||||
|
|
||||||
set -e
|
|
||||||
cd /opt/ || exit
|
cd /opt/ || exit
|
||||||
|
|
||||||
|
hc_url="https://hc-ping.com/$MAIL_HC_UID"
|
||||||
|
|
||||||
|
alias curl_hc='curl -LA "$USER_AGENT" --retry 3'
|
||||||
|
|
||||||
envsubst < template.msmtprc > /tmp/msmtprc
|
envsubst < template.msmtprc > /tmp/msmtprc
|
||||||
envsubst < mailcheck.template.mail > /tmp/mailcheck.mail
|
envsubst < mailcheck.template.mail > /tmp/mailcheck.mail
|
||||||
|
|
||||||
msmtp -C /tmp/msmtprc -a default "$MAIL_HC_UID@hc-ping.com" < /tmp/mailcheck.mail
|
result=$(msmtp -C /tmp/msmtprc -a default "$MAIL_HC_UID@hc-ping.com" < /tmp/mailcheck.mail 2>&1)
|
||||||
|
if [ "$?" != "0" ]
|
||||||
|
then
|
||||||
|
echo "$result"
|
||||||
|
curl_hc --data-raw "$result" "$hc_url/fail" >/dev/null
|
||||||
|
fi
|
||||||
|
|
|
@ -46,7 +46,6 @@ async def main():
|
||||||
send_ping(False)
|
send_ping(False)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
requests.get(url=healthcheck_url)
|
|
||||||
send_ping(True)
|
send_ping(True)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
Reference in a new issue