Skip to content

Instantly share code, notes, and snippets.

@mariodian
Last active November 14, 2021 01:43
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 mariodian/3b8e96e62a0eeb62ba0cf3d45a4e1170 to your computer and use it in GitHub Desktop.
Save mariodian/3b8e96e62a0eeb62ba0cf3d45a4e1170 to your computer and use it in GitHub Desktop.
Check status of systemd services
#!/bin/bash
URL="https://freedomnode.com/server-maintenance"
if [ "`wget -qO- $URL | sed -e 's/<[^>]*>//g' 2> /dev/null`" != "true" ]; then
SERVICES=(bitcoind lnd monerod btcpayserver nbxplorer thunderhub electrs tor nginx)
TITLE="Services alert!"
MESSAGE=""
for SERVICE in "${SERVICES[@]}"
do
STATUS=$(systemctl is-active $SERVICE)
if [ "$STATUS" != "active" ]; then
MESSAGE+="$SERVICE: <font color=\"#DC143C\">$STATUS</font> <br>"
fi
done
echo $MESSAGE
if [ ! -z "$MESSAGE" ];then
pushover "$TITLE" "$MESSAGE"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment