Last active
July 24, 2018 15:51
-
-
Save matchy256/4314970 to your computer and use it in GitHub Desktop.
wget を使った Web 死活監視スクリプト
This file contains hidden or 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 | |
if [ $# -eq 2 ]; then | |
URL=$1 | |
MAILTO=$2 | |
else | |
echo "usage : $0 check_url alert_mail_address" | |
exit 1 | |
fi | |
TIMEOUT=60 | |
TRYCOUNT=1 | |
SUBJECT="ALERT:Web Server is Fail!!!!" | |
alive=`wget -S --spider -t $TRYCOUNT -T $TIMEOUT $URL 2>&1 | grep -c "200 OK"` | |
if [ $alive == 0 ] ; then | |
echo "$URL is down." | mail -s "$SUBJECT" $MAILTO | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
新しいバージョンのwgetが -nv を指定すると -S がちゃんと動かないので直した