Skip to content

Instantly share code, notes, and snippets.

@mamemomonga
Created November 24, 2022 02:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mamemomonga/3c3f7a1b7ffa9779b0de46e397dc76ae to your computer and use it in GitHub Desktop.
簡易死亡チェッカー
#!/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