Конфигурационному файлу можно дать любое имя, главное — он должен находиться в директории /etc/monit/conf.d/. Файлы подключаются в /etc/monit/monitrc.
mcedit /etc/monit/conf.d/lemp-external
В конфигурационном файле задается проверка ICMP ответа и доступности по HTTP/HTTPS. Если 5 проверок подряд показывают, что ответа нет — формируется alert.
check host example.com with address example.com
if failed icmp type echo for 5 times within 5 cycles
then alert
if failed port 80 protocol httpfor 5 times within 5 cycles
then alert
if failed port 443 type tcpSSL protocol http for 5 times within 5 cycles
then alert
Проверка DNS:
check host ns1.example.com with address ns1.example.com
if failed port 53 type udp protocol dns
then alert
Проверка SMTP:
check host smtp.example.com with address smtp.example.com
if failed port 25 type tcp protocol smtp then alert
Проверка URL
check host example.com with address example.com
if failed
port 443 type tcpSSL protocol http
request "/contacts"
for 5 times within 5 cycles
then alert
После внесения изменений нужно проверить синтаксис
monit -tесли ошибок нет — перезапустить службу
/etc/init.d/monit restart
Мониторинг можно приостанавливать и возобновлять
monit unmonitor all
monit monitor allЧитайте также про Monit Gui — веб-интерфейс, через который можно выполнять настройки.