Last active
January 9, 2021 07:32
-
-
Save eksiscloud/b73c32bd34815cd716a779b1d51937e4 to your computer and use it in GitHub Desktop.
Monit conf for Varnish, Redis, Hitch and Postfix
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
| # Varnish | |
| check program varnishpanic with path "/bin/varnishadm panic.show" | |
| if status != 1 then alert | |
| check process varnish with pidfile /var/run/varnish.pid | |
| #start program = "/etc/init.d/varnish start" with timeout 30 seconds | |
| #stop program = "/etc/init.d/varnish stop" | |
| start program = "/usr/bin/systemctl start varnish" with timeout 30 seconds | |
| stop program = "/usr/bin/systemctl stop varnish" | |
| if failed host 127.0.0.1 port 80 protocol http | |
| and request "/monit-zxcvb" | |
| then restart | |
| if 3 restarts within 5 cycles then timeout | |
| # Hitch | |
| check process hitch with pidfile /var/run/hitch.pid | |
| start program = "/usr/bin/systemctl start hitch" with timeout 30 seconds | |
| stop program = "/usr/bin/systemctl stop hitch" | |
| if failed host 127.0.0.1 port 443 type tcpSSL protocol http | |
| and request /index.html with timeout 5 seconds for 2 times within 2 cycles | |
| then restart | |
| if 2 restarts within 2 cycles then timeout | |
| # Redis | |
| check process redis with pidfile /var/run/redis/redis-server.pid | |
| group redis | |
| start program = "/usr/sbin/service redis-server start" with timeout 30 seconds | |
| stop program = "/usr/sbin/service redis-server stop" | |
| if 2 restarts within 3 cycles then timeout | |
| if totalmem > 100 Mb then alert | |
| if children > 255 for 5 cycles then stop | |
| if cpu usage > 95% for 3 cycles then restart | |
| if failed host 127.0.0.1 port 6379 then restart | |
| if 5 restarts within 5 cycles then timeout | |
| # Postfix | |
| check process postfix with pidfile /var/spool/postfix/pid/master.pid | |
| group mail | |
| start program = "/etc/init.d/postfix start" | |
| stop program = "/etc/init.d/postfix stop" | |
| if loadavg(5min) greater than 10 for 8 cycles then stop | |
| if failed host INSERT_THE_RELAY_HOST port 587 | |
| type tcp protocol smtp using tls | |
| with timeout 15 seconds | |
| then alert | |
| if 3 restarts within 5 cycles then timeout | |
| depends on postfix_rc | |
| check file postfix_rc with path /etc/init.d/postfix | |
| group mail | |
| if failed checksum then unmonitor | |
| if failed permission 755 then unmonitor | |
| if failed uid root then unmonitor | |
| if failed gid root then unmonitor | |
Author
Author
monit-zxcvb:
- touch /var/www/html/monit-zxcvb # or something that the site ever-never uses as real URL
- nano /etc/varnish/monit.vcl
- in vcl_recv add this:
if (req.url == "/monit-zxcvb") {
return(synth(200, "OK"));
} - nano /etc/varnish/default.vcl
- add in the beginning but after vcl 4,1; this:
include "/etc/varnish/monit.vcl"; - systemctl restart varnish
Now the url http://domain.tld/monit-zxcvb gives status 200 OK as error by Varnish
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you can't find varnish.pid at /var/run: