`
zyz
  • 浏览: 24232 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

monit linux监控

阅读更多
English | VPS常用软件下载 |美国VPS主机推荐|代购服务|10美元以下VPS|VPS新手指南/教程|留言板|关于VPSer| VPS论坛 | 登录 |VPS侦探Monit - Linux系统进程、文件、目录和设备的监测软件
2011年07月21日 上午 | 作者:VPS侦探

Monit是一款功能非常丰富的进程、文件、目录和设备的监测软件,适用于Linux/Unix平台。 它可以自动修复那些已经停止运作的程序,特使适合处理那些由于多种原因导致的软件错误,同时Monit 包含一个内嵌的 HTTP(S) Web 界面,你可以使用浏览器方便地查看 Monit 所监视的服务器。

Monit官网:http://mmonit.com/monit/

1、安装Monit
CentOS可以到:http://pkgs.repoforge.org/monit/ 下载对应位数rpm包安装。
32位:wget -c http://pkgs.repoforge.org/monit/monit-5.2.5-1.el5.rf.i386.rpm;rpm -ivh monit-5.2.5-1.el5.rf.i386.rpm
64位:wget -c http://pkgs.repoforge.org/monit/monit-5.2.5-1.el5.rf.x86_64.rpm;rpm -ivh monit-5.2.5-1.el5.rf.x86_64.rpm

Debian可以直接:apt-get install monit 安装。

2、修改配置文件
CentOS用RPM包安装的话配置文件在: /etc/monit.conf;Debian apt-get安装的话配置文件在:/etc/monit/monitrc;

下面是一个简单的例子,配置文件中已经包含了大量的例子,可以看配置文件参考。

set daemon  120        #设置检测时间
set logfile /var/log/monit.log        #monit日志
set alert www@vpser.net with reminder on 1 cycle  #出现1次错误的时候发报警邮件到指定的邮箱
set mailserver mail.vpser.net     #设置邮件服务器
set httpd port 2812 and            # 设置http监控页面的端口
     use address 74.207.246.99   # http监控页面的IP
     allow localhost               # 允许本地访问
     allow 123.23.45.0/24           # 允许此IP段访问
     #allow 0.0.0.0/0.0.0.0       # 允许所有IP访问
     allow username:password     #设置访问用户名密码

#检测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 port 22 protocol ssh then restart
   if 5 restarts within 5 cycles then timeout

#检测mysql服务
check process mysql with pidfile /usr/local/mysql/var/vpser.pid
   group database
   start program = "/etc/init.d/mysql start"
   stop program = "/etc/init.d/mysql stop"
   if failed host 127.0.0.1 port 3306 then restart
   if 5 restarts within 5 cycles then timeout

#检测nginx服务
check process nginx with pidfile /usr/local/nginx/logs/nginx.pid
    start program = "/etc/init.d/nginx start"
    stop program  = "/etc/init.d/nginx stop"
    if failed host www.vpser.net port 80 protocol http
       then restart配置中的pid及启动、关闭脚本的路径一定要是全路径,且参数一定要正确否则会造成无法正常检测或正常启动。

看了一下php-fpm貌似用Monit还不是很好监控。

如果添加了http可以直接使用http://ip:2812 进行管理。

3、启动/停止Monit
CentOS:
chkconfig monit on //加入开机启动
/etc/init.d/monit {start|stop|restart|force-reload|syntax}Debian:
编辑:/etc/default/monit 文件,查找 startup=0 ,将0改为1,保存。update-rc.d -f monit defaults
/etc/init.d/monit {start|stop|restart|force-reload|syntax}当然如果使用监控宝服务也不错,只不过免费版的检测间隔长些、对检测的数量有限制。

如有问题欢迎反馈,欢迎到VPS论坛交流。

原创文章,谢绝转载!

>>转载请注明出处:VPS侦探 本文链接地址:http://www.vpser.net/manage/monit.html
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics