Created
September 22, 2016 01:32
-
-
Save tperalta82/c6dbc9f63dac55df6be211b42c6c8703 to your computer and use it in GitHub Desktop.
Simple http-checker
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 | |
WBSRV=$(/usr/bin/timeout 10 /usr/bin/curl --verbose --header 'Host: pornhub.com' 'http://localhost/' -m 10 -f --silent > /dev/null 2>&1) | |
WBSRVSTAT=$? | |
SSTAT=$(/sbin/service httpd status) | |
LRET=$? | |
if [ $WBSRVSTAT -ne 0 ] || [ $LRET -ne 0 ]; then | |
subject="Apache Server Down / Unresponsive"; | |
recipients="yourmom@stripclub.com,slip@knot.com" | |
message="Apache Service is down or not responding, restarting service, if it fails to restart or if you receive this message again in 1 minute, please check with your awesome sysadmins! | |
"$(date) | |
/usr/sbin/sendmail "$recipients" << EOF | |
subject:$subject | |
from:$from | |
$message | |
EOF | |
/sbin/service httpd restart | |
echo "ERR" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment