Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cdzombak
Created June 11, 2019 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdzombak/d55afe94c58ab84f80195fb2db74f9e4 to your computer and use it in GitHub Desktop.
Save cdzombak/d55afe94c58ab84f80195fb2db74f9e4 to your computer and use it in GitHub Desktop.
Mastodon health checks, run every minute via cron on a separate server
#!/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"
#!/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