В debian jessie я настроил monit для проверки HAproxy
конкретные переадресации портов и перезапустить его в случае неудачи:
check process haproxy with pidfile /run/haproxy.pid
group www-data
start program = "/bin/systemctl start haproxy.service"
stop program = "/bin/systemctl stop haproxy.service"
if failed port 8080 protocol http request "/checker" then restart
if failed port 8081 protocol http request "/checker" then restart
if failed port 8082 protocol http request "/checker" then restart
if 8 restarts within 8 cycles then unmonitor
Я знаю, что можно настроить noalert email
в частности check
Окружающая среда. Интересно, можно ли сделать то же самое для конкретных if
в пределах того же check
. В этом конкретном случае я хотел бы, чтобы monit предупреждал меня, только если проверка включена. port 8082
не удалось, но не для других 2.
Я пробовал добавить что-то вроде этого:
check process haproxy with pidfile /run/haproxy.pid
group www-data
start program = "/bin/systemctl start haproxy.service"
stop program = "/bin/systemctl stop haproxy.service"
if 8 restarts within 8 cycles then unmonitor
check host site-a with address localhost
noalert email@address
depends haproxy
if failed port 8080 protocol http request "/checker" then exec "/usr/bin/monit restart haproxy"
check host site-b with address localhost
noalert email@address
depends haproxy
if failed port 8081 protocol http request "/checker" then exec "/usr/bin/monit restart haproxy"
check host site-c with address localhost
depends haproxy
if failed port 8082 protocol http request "/checker" then exec "/usr/bin/monit restart haproxy"
Эта конфигурация работает, но мне нужно exec monit
как внешняя программа, и мне интересно, есть ли способ сделать это прямо в if construct
в пределах того же check
. Если я использую следующее, monit
запустится без жалоб, но не учитывает noalert
проинструктировать:
check process haproxy with pidfile /run/haproxy.pid
group www-data
start program = "/bin/systemctl start haproxy.service"
stop program = "/bin/systemctl stop haproxy.service"
if failed port 8080 protocol http request "/checker" then
restart
noalert email@address
if failed port 8081 protocol http request "/checker" then
restart
noalert email@address
if failed port 8082 protocol http request "/checker" then restart
if 8 restarts within 8 cycles then unmonitor
Любая идея?
С уважением