Created
June 11, 2019 17:27
-
-
Save cdzombak/d55afe94c58ab84f80195fb2db74f9e4 to your computer and use it in GitHub Desktop.
Mastodon health checks, run every minute via cron on a separate server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -u | |
NOW=$(date +"%F %T %Z") | |
OK= | |
if curl -s https://a2mi.social/api/v1/streaming/health | grep -c OK > /dev/null ; then | |
OK="1" | |
else | |
OK="0" | |
fi | |
LASTSTATUS_FILE="$HOME/.mastodon-streaming-api-check-status" | |
if ! grep -c "$OK" "$LASTSTATUS_FILE" >/dev/null ; then | |
if [[ "$OK" == "1" ]]; then | |
echo "a2mi.social streaming API recovered at $NOW" | mailx -s "[a2mi.social] Streaming API - Recovered" chris@dzombak.com | |
else | |
echo "a2mi.social streaming API was not OK at $NOW" | mailx -s "[a2mi.social] Streaming API - ALERT" chris@dzombak.com | |
fi | |
fi | |
echo "$OK" > "$LASTSTATUS_FILE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -u | |
NOW=$(date +"%F %T %Z") | |
OK= | |
if curl -s https://a2mi.social/api/v1/instance | grep -c "Hi there\!" > /dev/null ; then | |
OK="1" | |
else | |
OK="0" | |
fi | |
LASTSTATUS_FILE="$HOME/.mastodon-instance-api-check-status" | |
if ! grep -c "$OK" "$LASTSTATUS_FILE" >/dev/null ; then | |
if [[ "$OK" == "1" ]]; then | |
echo "a2mi.social web instance API recovered at $NOW" | mailx -s "[a2mi.social] Website - Recovered" chris@dzombak.com | |
else | |
echo "a2mi.social web instance API was not OK at $NOW" | mailx -s "[a2mi.social] Website - ALERT" chris@dzombak.com | |
fi | |
fi | |
echo "$OK" > "$LASTSTATUS_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment