目的
需要实时监控进程的状态,可以从页面重启进程,集中监控所有主机的进程
安装
1,安装包下载
Mmonit https://mmonit.com/dist/mmonit-3.5.1-linux-x64.tar.gz
Monit https://mmonit.com/monit/dist/monit-5.3.1.tar.gz
2,部署Mmonit
1> 安装mysql
传送门 https://blog.espnlol.com/?p=82
2>安装mmonit
tar xvzf mmonit-3.5.1-linux-x64.tar.gz mv mmonit-3.5.1 /usr/local ln -s /usr/local/mmonit-3.5.1/ /usr/local/mmonit mysql –u root –p password:****** mysql>create database mmonit; mysql> GRANT ALL ON mmonit.* to mmonit@localhost identified by 'mmonit'; mysql>quit cd /usr/local/mmonit/db mysql -u mmonit mmonit -p < mmonit-schema.mysql
3>配置mmonit
vi /usr/local/mmonit/conf/server.xml <Connector address="*" port="8099" processors="5" /> 更改web端口 使用mysql数据库,其他注释掉 <Realm url="mysql://mmonit:mmonit@127.0.0.1:3306/mmonit" minConnections="1" maxConnections="100" reapConnections="1000" />
4>启动服务
先将系统日期变更为2011年6月6日
date 060610002011
然后启动服务
/usr/local/mmonit/bin/mmonit start
然后将系统时间还原即可
ntpdate 3.centos.pool.ntp.org
写入启动项
echo “/usr/local/mmonit/bin/mmonit start”>>/etc/rc.d/rc.local
3,部署monit
1>安装monit
tar xf monit-5.3.1.tar.gz cd monit-5.3.1 ./configure --prefix=/usr/local/monit --with-openssl=/usr/local/ssl --enable-threads make make install cd /usr/local/monit mkdir etc cd etc mkdir monit.d vi monitrc set daemon 60 # check services at 1-minute intervals set logfile syslog facility log_daemon set idfile /var/.monit.id set statefile /var/.monit.state set eventqueue basedir /var/monit # set the base directory where events will be stored slots 100 # optionally limit the queue size set mmonit http://monit:monit@127.0.0.1:8099/collector set httpd port 2812 and use address 0.0.0.0 # only accept connection from localhost allow 127.0.0.1 # allow localhost to connect to the server and allow admin:monit # require user 'admin' with password 'monit' check system sysload if loadavg (1min) > 20 then alert if loadavg (5min) > 30 then alert if memory usage > 75% then alert if swap usage > 25% then alert if memory usage > 75% then alert if swap usage > 25% then alert if cpu usage (user) > 70% then alert if cpu usage (system) > 30% then alert if cpu usage (wait) > 20% then alert group server check filesystem root_space with path /dev/vda1 if space usage > 80% for 5 times within 15 cycles then alert check filesystem data_space with path /dev/vdb if space usage > 80% for 5 times within 15 cycles then alert group server include /usr/local/monit/etc/monit.d/*
2>配置
更改monitrc权限为600
chmod 600 /usr/local/monit/etc/monitrc
在/usr/local/monit/etc/monit.d下创建相应服务监控配置文件
例:nginx监控文件为nginx
echo "/usr/local/monit/bin/monit -c /usr/local/monit/etc/monitrc" >>/etc/rc.d/rc.local /usr/local/monit/bin/monit -c /usr/local/monit/etc/monitrc
4,验证与监控
1)查看mmonit web页面
http://ip:8099
默认用户admin 默认密码swordfish(自行更改)
查看各monit监控主机状态正常
5,过期重启
登陆到M/Monit – Admin-General
将时间修改到过期前,重启之后,在恢复时间即可