Skip to content

Instantly share code, notes, and snippets.

@abdul
Created September 16, 2016 17:32
Show Gist options
  • Save abdul/a3df70d4379f62a0b202d20c6631a83e to your computer and use it in GitHub Desktop.
Save abdul/a3df70d4379f62a0b202d20c6631a83e to your computer and use it in GitHub Desktop.
monit http check
## http-check
check program http-check with path "/etc/monit/http-check.sh"
start program = "/etc/init.d/php5-fpm start"
stop program = "/etc/init.d/php5-fpm stop"
if status !=0 then alert
if status !=0 then restart
if 5 restarts within 5 cycles then timeout
#!/bin/bash
# source: /etc/monit/bin/http-check.sh
url="http://www.example.com"
response=$(curl -s -o /dev/null -I -w "%{http_code}" $url)
if [ "$response" = "500" ]
then
exit 1
else
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment