Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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