Skip to content

Instantly share code, notes, and snippets.

@tperalta82
Created September 22, 2016 01:32
Show Gist options
  • Save tperalta82/c6dbc9f63dac55df6be211b42c6c8703 to your computer and use it in GitHub Desktop.
Save tperalta82/c6dbc9f63dac55df6be211b42c6c8703 to your computer and use it in GitHub Desktop.
Simple http-checker
#!/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