Skip to content

Instantly share code, notes, and snippets.

@matchy256
Last active July 24, 2018 15:51
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matchy256/4314970 to your computer and use it in GitHub Desktop.
Save matchy256/4314970 to your computer and use it in GitHub Desktop.
wget を使った Web 死活監視スクリプト
#!/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
@matchy256
Copy link
Author

新しいバージョンのwgetが -nv を指定すると -S がちゃんと動かないので直した

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment