以前、CentOS5でいろいろなMonitについての記事を書きましたが、
今回はCentOS6で、インストールと初期設定(auditd/crond/ntpd/rsyslog/sshd/postfix)を再度行いました。
インストールは下記の通りです。
# yum -y install monit # chkconfig monit on # mkdir /var/monit
/etc/monit.confは下記のようにデーモンとログの設定のコメントを外しておきます。
... set daemon 120 # check services at 2-minute intervals ... set logfile syslog facility log_daemon ...
/etc/monit.d以下のファイルは下記の通りです。
▼ auditd.conf
# cat /etc/monit.d/auditd.conf check process auditd with pidfile /var/run/auditd.pid start program = "/etc/init.d/auditd start" stop program = "/etc/init.d/auditd stop" if 5 restarts within 5 cycles then timeout
▼ crond.conf
# cat /etc/monit.d/crond.conf check process crond with pidfile /var/run/crond.pid start program = "/etc/init.d/crond start" stop program = "/etc/init.d/crond stop" if 5 restarts within 5 cycles then timeout
▼ ntpd.conf
# cat /etc/monit.d/ntpd.conf check process ntpd with pidfile /var/run/ntpd.pid start program = "/etc/init.d/ntpd start" stop program = "/etc/init.d/ntpd stop" if 5 restarts within 5 cycles then timeout
▼ rsyslog.conf
# cat /etc/monit.d/rsyslog.conf check process rsyslog with pidfile /var/run/syslogd.pid start program = "/etc/init.d/rsyslog start" stop program = "/etc/init.d/rsyslog stop" if 5 restarts within 5 cycles then timeout
▼ sshd.conf
# cat /etc/monit.d/sshd.conf check process sshd with pidfile /var/run/sshd.pid start program = "/etc/init.d/sshd start" stop program = "/etc/init.d/sshd stop" if failed port 22 protocol ssh then restart if 5 restarts within 5 cycles then timeout
▼ postfix.conf
# cat /etc/monit.d/postfix.conf check process postfix with pidfile /var/spool/postfix/pid/master.pid start program = "/etc/init.d/postfix start" stop program = "/etc/init.d/postfix stop" if failed port 25 protocol smtp then restart if 5 restarts within 5 cycles then timeout
最後に下記で開始です。
# /etc/init.d/monit start