monit mysql_monit安装配置

环境centos5(32bit),monit-5.17.1,下载地址 https://bitbucket.org/tildeslash/monit/downloads/

1、tar zxvf monit-5.17.1-linux-x86.tar.gz

2、cp monit-5.17.1/conf/monitrc /etc/

3、chmod 0700 /etc/monitrc

4、vi /etc/monitrc

set daemon  30   ##设置30秒检查一次

set logfile /var/log/messages  ##设置日志文件

set httpd port 2812 and

use address X.X.X.X

allow 0.0.0.0/0.0.0.0

allow admin:123456

设置访问及monit监听端口,允许登录ip,页面登录用户名密码

check system 127.0.0.1

if loadavg (1min) > 4 then alert

if loadavg (5min) > 2 then alert

if cpu usage > 90% for 10 cycles then alert

if memory usage > 50% then alert

if swap usage > 25% then alert

设置监控本地CPU内存等信息

check process xinetd with pidfile /var/run/xinetd.pid

start program = "/etc/init.d/xinetd start"

stop program = "/etc/init.d/xinetd stop"

if changed pid then alert

根据PID监控进程,服务死掉后自动重启

check process mysql matching "/usr/bin/mysql"

start program = "/etc/init.d/mysql start"

stop program = "/etc/init.d/mysql stop"

check process h5 with MATCHING h5

start program = "/usr/local/bin/h5 > /var/log/h5.log &" with timeout 10 seconds

stop program = "/bin/ps -ef |grep h5|grep -v "grep" |awk '{print $2}'|xargs kill -9" with timeout 10 seconds

if failed port 8081 for 3 cycles then restart

监听进程的另一种方式

还有监听文件等等,就不写了。

主要关注的告警功能

set mailserver smtp.163.com port 25    ##设置邮件服务器及端口,这里使用的163邮件服务器

username 发件人有限 password “发件人邮箱密码”

set mail-format {

from: shibo46@163.com

subject: monit alert -- $EVENT $SERVICE

message: $EVENT Service $SERVICE

Date: $DATE

Action: $ACTION

Host: $HOST

Description: $DESCRIPTION

Your faithful employee,

Monit

}

#设置邮件发送内容

set alert XXXX@163.com  #设置收件人邮箱,多个收件人写多行

配置好后执行monit程序启动 monit-5.17.1/bin/monit

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值