首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Apache、MySQL和后缀的Monit配置

问Apache、MySQL和后缀的Monit配置
EN

Server Fault用户
提问于 2012-08-24 03:03:34
回答 1查看 3.2K关注 0票数 0

我计划用下面的配置在生产服务器上启用Monit。我对Monit完全陌生,我想听听别人的提示,或者如果有其他指令,我应该考虑根据您的经验来支持我的监控脚本。

我的服务器是CentOS 5.6。

谢谢!

代码语言:javascript
复制
#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
EN

回答 1

Server Fault用户

回答已采纳

发布于 2012-08-24 03:34:12

我在后缀部分为monit增加了一行:

代码语言:javascript
复制
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网关,所以我得到了一个文本。

我也有类似的配置:

代码语言:javascript
复制
check file alerttest with path /.monit_is_running
  alert xxx@gmail.com with reminder on 1440 cycles

没有文件/.monit_is_running,因此此警报通常每天触发一次。这是monit本身的心跳,所以我知道它在运行(一种“谁监视观察者”的东西)。事实上,这是我从服务器故障上得到的一个想法,但我不记得是谁突然想到的。

票数 5
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/420636

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档