原文链接:http://www.chenweiliang.com/cwl-160.html
##
陈沩亮博客示例monit配置文件,说明:
1. 域名以www.UFO.org.in为例。
2. 后面带xxx的均是举例用的名字,需要根据自己的需要修改。
##
################################################## #############################
Monit control file
################################################## #############################
#
检查周期,默认为2分钟,对于网站来说有点长,可以根据需要自行调节,这改成30秒。
set daemon 30
日志文件
set logfile /var/log/monit.log
#
邮件通知服务器
#
#set mailserver mail.example.com
set mailserver localhost
#
通知邮件的格式设置,下面是默认格式供参考
#
Monit by default uses the following alert mail format:
##
–8<–
From: monit@$HOST # sender
Subject: monit alert — $EVENT $SERVICE # subject
##
$EVENT Service $SERVICE
#
Date: $DATE
Action: $ACTION
Host: $HOST # body
Description: $DESCRIPTION
#
Your faithful employee,
monit
–8<–
##
You can override the alert message format or its parts such as subject
or sender using the MAIL-FORMAT statement. Macros such as $DATE, etc.
are expanded on runtime. For example to override the sender:
#
简单的,这只改了一下发送人,有需要可以自己修改其它内容。
set mail-format from: admin@xxxx
设置邮件通知接收者。建议发到gmail,方便邮件过滤。
set alert xxx@xxxx
set httpd port 2812 and #设置http监控页面的端口
use address http://www.ufo.org.in # http监控页面的IP或域名
##allow localhost # 允许本地访问
allow 203.82.90.239 # 允许指定IP访问
allow user:password # 访问用户名密码
################################################## #############################
Services
################################################## #############################
#
系统整体运行状况监控,默认的就可以,可以自己去微调
#
系统名称,可以是IP或域名
#check system http://www.ufo.org.in
if loadavg (1min) > 4 then alert
if loadavg (5min) > 2 then alert
if memory usage > 75% then alert
if cpu usage (user) > 70% then alert
if cpu usage (system) > 30% then alert
if cpu usage (wait) > 20% then alert
可选的ssl端口的监控,如果有的话
if failed port 443 type tcpssl protocol http
with timeout 15 seconds
then restart
#
监控apache
#
check process apache with pidfile /usr/local/apache/logs/httpd.pid
start program = “/etc/init.d/httpd start”
stop program = “/etc/init.d/httpd stop”
if failed host http://www.ufo.org.in port 80 protocol http then restart
if 3 restarts within 5 cycles then timeout
group server
#
#监控mysql(1)
#
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
start program = “/etc/init.d/mysqld start”
stop program = “/etc/init.d/mysqld stop”
if failed host localhost port 3306 for 3 times within 4 cycles then alert
#若在四个周期内,三次 3306(我的Mysql)端口都无法连通,则邮件通知
if 5 restarts within 5 cycles then timeout
欢迎转载《如何设置monit.conf文件?monit配置文件示例说明》
陈沩亮版权所有,转载请注明出处链接:http://www.chenweiliang.com/cwl-160.html
网站地址:http://www.chenweiliang.com/
您还在探索飞碟ufo之谜吗?不如现在就去下载《来自外星人的讯息》电子书了解et外星人与人类的起源真相吧!
陈沩亮博客
没有评论:
发表评论