我计划使用下面的configuration在我的生产服务器上启用Monit。 我对Monit来说是全新的,想要听取其他人的提示,或者是否有其他指令,我应该考虑根据您的经验来加强我的监控脚本。
我的服务器是CentOS 5.6。
谢谢!
#httpd---- check process httpd with pidfile /var/run/httpd.pid group apache start program = "/etc/init.d/httpd start" stop program = "/etc/init.d/httpd stop" if failed host 127.0.0.1 port 80 protocol http then restart if cpu > 60% for 2 cycles then alert if cpu > 80% for 5 cycles then restart if 5 restarts within 5 cycles then timeout #mysqld---- check process mysqld with pidfile /var/run/mysqld/mysqld.pid group mysql start program = "/etc/init.d/mysqld start" stop program = "/etc/init.d/mysqld stop" if failed host 127.0.0.1 port 3306 then restart if cpu > 60% for 2 cycles then alert if cpu > 80% for 5 cycles then restart if 5 restarts within 5 cycles then timeout #postfix---- 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 cpu > 60% for 2 cycles then alert if cpu > 80% for 5 cycles then restart if 5 restarts within 5 cycles then timeout
我在我的Postfix部分中有一个额外的行:
if failed port 25 protocol smtp then restart
根据Apache提供的服务,您可以testing请求(例如, request "/monit_token" )而不是普通的HTTP响应。 请求可以是直接打到你的应用程序的东西,而不仅仅是一个静态文件。 再次,这取决于你在做什么。
既然你在那里有Postfix,你应该考虑如果在Postfixclosures的情况下,Monit警报实际上是如何离开的。 就我而言,我正在set mailserver gmail-smtp-in.l.google.com并将邮件发送到一个gmail帐户,这样我就不依赖我自己的邮件服务器的function来获取警报邮件对我来说。 我也有一个gmailfilter,将警报消息转发到一个短信网关,所以我得到一个文本。
我也有这样的configuration:
check file alerttest with path /.monit_is_running alert [email protected] with reminder on 1440 cycles
没有文件/.monit_is_running所以这个警报总是会每天触发一次。 这是一个monit本身的心跳,所以我知道它正在运行(某种“观察者”的东西)。 这实际上是我从Serverfault上的某个人那里得到的一个想法,但我不记得谁是副手。