簡易死亡チェッカー
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
#!/bin/bash | |
set -eu | |
TARGET_HOST="監視するホスト" | |
PROWL_APIKEY="Prowlトークン" | |
PROWL_APPNAME="deadchecker" | |
hostAlive() { | |
ping -t 1 $TARGET_HOST > /dev/null 2>&1 | |
echo $? | |
} | |
prowlNotify() { | |
curl -X POST -d 'apikey='"$PROWL_APIKEY"'&application='$PROWL_APPNAME'&priority=-1&event='"$1"'' https://api.prowlapp.com/publicapi/add | |
} | |
prowlNotify "起動開始" | |
sleep 30 | |
prowlNotify "チェックを開始" | |
while true; do | |
if [ $( hostAlive || true ) -ne 0 ]; then | |
prowlNotify "通信できません" | |
fi | |
sleep 60 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment