とりあえず,以下のような感じで監視は可能
/etc/monit.d/mydns.conf
check process mydns with pidfile /var/run/mydns.pid start program = "/etc/init.d/mydns start" stop program = "/etc/init.d/mydns stop" if failed port 53 type udp then restart if 5 restarts within 5 cycles then timeout
port を監視しているだけなので,port は開いているけど,
反応が返ってこないという場合が考えられるので,いまいち.
調べたら,monit は DNS のプロトコルを理解できるようなので,
以下のように,protocol を指定.
check process mydns with pidfile /var/run/mydns.pid start program = "/etc/init.d/mydns start" stop program = "/etc/init.d/mydns stop" if failed port 53 use type udp protocol dns then restart if 5 restarts within 5 cycles then timeout
これだと,
[JST Oct 16 16:54:35] error : 'mydns' failed protocol test [DNS] at INET[localhost:53] via UDP
という風に,エラーが出る.
DNS protocol test は BIND 以外だめらしい.
- Monit
http://mmonit.com/monit/
- monit を使ってみた [2009-10-16-1]