Created
December 16, 2016 12:28
-
-
Save kayo-tozaki/2d81be1ae23bf564e5b13efd3e4bab03 to your computer and use it in GitHub Desktop.
get website status and send alert mail
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
| LANG=ja_JP.utf8 | |
| CURL_DATA=`curl --connect-timeout 30 -vvvv http://<your.website.url> 2>&1 ` | |
| IF_DATA=`echo $CURL_DATA | grep "HTTP/1.1 200 OK"` | |
| SENDER=`cat mail_flag` | |
| DATE=`date +"%Y/%m/%d %H:%M:%S"` | |
| if [ -n "$IF_DATA" ]; then | |
| if [ "$SENDER" = "2" ]; then | |
| echo -e "$DATE\n$CURL_DATA" | col -b | mailx -s 'Recovery' <send_alart@mail.address> | |
| SENDER=1 | |
| fi | |
| else | |
| if [ "$SENDER" = "1" ]; then | |
| echo -e "$DATE\n$CURL_DATA" | col -b | mailx -s 'Problem' <send_alart@mail.address> | |
| SENDER=2 | |
| fi | |
| fi | |
| echo $SENDER > mail_flag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment