我计划用下面的配置在生产服务器上启用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发布于 2012-08-24 03:34:12
我在后缀部分为monit增加了一行:
if failed port 25 protocol smtp then restart根据Apache提供的内容,您可以在请求(例如request "/monit_token")上进行测试,而不是普通的HTTP响应。请求可以是直接命中应用程序的东西,而不仅仅是静态文件。再说一次,这取决于你在做什么。
因为您有后缀,所以您应该考虑Monit警报是如何在后缀关闭的情况下从盒子中发出的。在我的例子中,我正在执行一个set mailserver gmail-smtp-in.l.google.com并将邮件发送到一个gmail帐户,这样我就不会依赖我自己的邮件服务器的功能来向我发出警告邮件。我也有一个gmail过滤器,它将把警报消息转发到一个SMS网关,所以我得到了一个文本。
我也有类似的配置:
check file alerttest with path /.monit_is_running
alert xxx@gmail.com with reminder on 1440 cycles没有文件/.monit_is_running,因此此警报通常每天触发一次。这是monit本身的心跳,所以我知道它在运行(一种“谁监视观察者”的东西)。事实上,这是我从服务器故障上得到的一个想法,但我不记得是谁突然想到的。
https://serverfault.com/questions/420636
复制相似问题