免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2404 | 回复: 5
打印 上一主题 下一主题

系统监控利器---monit [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-05-18 10:22 |只看该作者 |倒序浏览
本帖最后由 jinxl560 于 2010-05-18 10:31 编辑

Monit 是用于对系统中的进程、文件、目录、以及设备等进行监视和管理的工具。当你所指定的server宕机或者没有反应,monit会将该进程杀死并重启该server。并通过邮件进行通知。Monit 包含一个内嵌的 HTTP(S) Web 界面,你可以使用浏览器方便地查看 Monit 所监视的服务器。
如图:



Monit的官方网站: http://www.mmonit.com
下面将介绍monit在CentOS5.3上的安装和配置:
download:http://mmonit.com/monit/dist/monit-5.1.1.tar.gz
shell >  tar xzvf monit-5.1.1.tar.gz
shell> cd monit-5.*
shell>./configure
shell>make
shell> make install
shell> rm /etc/monitrc
shell> cp monitrc /etc/
在inittab文件中添加下面这句话,使init守护monit进程!!
shell> vi /etc/inittab
mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc
现在安装完成了,是不是超简单!!
接下来就是配置了!!
Monitrc文件###############################################################################set daemon  120        #设置monit检查的间隔时间,单位是秒!!
set logfile syslog facility log_daemon  #用syslog来记录log   

set logfile /var/logs/monit.log #设置日志路径

set idfile /var/.monit.id #设置PID文件的位置

set mailserver  192.168.0.21,               # primary mailserver  邮件服务器的IP

set mail-format { from: monit@test.com }  #设置你的邮件从哪个账号发出

set alert phoneNumber@139.com                     #发到我的139邮箱,用139邮箱是因为139有一个邮件到达通知功能

set httpd port 2812 and                                                #设置monit监听的端口号     

use address 192.168.0.21   # 设置monit服务器的IP,可以让你方便的http访问     

allow admin:pass      #设置用户名和密码################################################################################# Services  ################################################################################监控服务器的磁盘使用情况   

check device system with path /dev/mapper/VolGroup00-LogVol00      

  if space usage > 85% for 5 times within 15 cycles then alert      

  if space usage > 95% then stop         

  if inode usage > 85% then alert

  if inode usage > 95% then stop

######################################################
#sshd   监控sshd进程

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

start program "/etc/init.d/sshd start"        

stop  program "/etc/init.d/sshd stop"        

if failed host 127.0.0.1 port 22  then restart      


if 5 restarts within 5 cycles then timeout


#######################################################
#cron       监控crontab进程

check process cron with pidfile /var/run/crond.pid        

group system        

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

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

if 5 restarts within 5 cycles then timeout        depends on cron_rc
############################################################################################################
#scripts   监控nginx的日志切割脚本文件

check file cut_nginx_log.sh with path /scripts/cut_nginx_log.sh      

group scripts        

if failed checksum then unmonitor        

if failed permission 755 then unmonitor      

if failed uid root then unmonitor        

if failed gid root then unmonitor

#############################################################################################################
#systemfile                监控passwd文件和group文件

check file passwd with path /etc/passwd        

group system        

if failed checksum then unmonitor        

if failed permission 644 then unmonitor        

if failed uid root then unmonitor      

if failed gid root then unmonitor

check file group with path /etc/group        

group system        

if failed checksum then unmonitor        

if failed permission 644 then unmonitor        

if failed uid root then unmonitor        

if failed gid root then unmonitor

############################################################################################################
# 监控本机的25,110端口号

check host localhost with address 127.0.0.1        

if failed port 25  with timeout 15 seconds then exec "/usr/bin/qmailctl restart"        

if failed port 110 protocol pop with timeout 15 seconds then exec "/usr/bin/vpopmailctl restart"

基本的配置就是这样子,剩下的就是根据各自的实际情况进行修改!!!,配置好从浏览器登录查看下是否成功,接下来就是轻松的喝喝茶,逛逛论坛了!! 哈哈


本文出自“叁二伍”博客,请务必保留此出处 http://wibb.info/archives/96

论坛徽章:
0
2 [报告]
发表于 2010-05-18 11:00 |只看该作者
我们最早的时候用monit,最后还是改用cacti了

论坛徽章:
34
亥猪
日期:2015-03-20 13:55:11戌狗
日期:2015-03-20 13:57:01酉鸡
日期:2015-03-20 14:03:56未羊
日期:2015-03-20 14:18:30子鼠
日期:2015-03-20 14:20:14丑牛
日期:2015-03-20 14:20:31辰龙
日期:2015-03-20 14:35:34巳蛇
日期:2015-03-20 14:35:56操作系统版块每日发帖之星
日期:2015-11-06 06:20:00操作系统版块每日发帖之星
日期:2015-11-08 06:20:00操作系统版块每日发帖之星
日期:2015-11-19 06:20:00黄金圣斗士
日期:2015-11-24 10:43:13
3 [报告]
发表于 2010-05-18 13:36 |只看该作者
还是习惯命令行~

论坛徽章:
0
4 [报告]
发表于 2010-05-19 15:34 |只看该作者
cacti的话在服务失败的时候不会自动重启。

论坛徽章:
0
5 [报告]
发表于 2010-05-19 15:34 |只看该作者
回复 3# vermouth


    你指的是通过crontab来进行对进程的监控吗?

论坛徽章:
34
亥猪
日期:2015-03-20 13:55:11戌狗
日期:2015-03-20 13:57:01酉鸡
日期:2015-03-20 14:03:56未羊
日期:2015-03-20 14:18:30子鼠
日期:2015-03-20 14:20:14丑牛
日期:2015-03-20 14:20:31辰龙
日期:2015-03-20 14:35:34巳蛇
日期:2015-03-20 14:35:56操作系统版块每日发帖之星
日期:2015-11-06 06:20:00操作系统版块每日发帖之星
日期:2015-11-08 06:20:00操作系统版块每日发帖之星
日期:2015-11-19 06:20:00黄金圣斗士
日期:2015-11-24 10:43:13
6 [报告]
发表于 2010-05-19 15:42 |只看该作者
用几个常用的状态命令,crontab 定时调用。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP