资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

怎么用Monit监测Linux服务器

这篇文章主要介绍“怎么用Monit监测Linux服务器”,在日常操作中,相信很多人在怎么用Monit监测Linux服务器问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”怎么用Monit监测Linux服务器”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

为企业提供成都网站建设、网站建设、网站优化、网络营销推广、竞价托管、品牌运营等营销获客服务。创新互联拥有网络营销运营团队,以丰富的互联网营销经验助力企业精准获客,真正落地解决中小企业营销获客难题,做到“让获客更简单”。自创立至今,成功用技术实力解决了企业“网站建设、网络品牌塑造、网络营销”三大难题,同时降低了营销成本,提高了有效客户转化率,获得了众多企业客户的高度认可!

monit用 Monit 监测 linux 服务器
Monit 是一个用来监测系统状态的工具,不但可以用来监视进程、服务、文件、目录、文件系统,还可以在服务 down 掉的时候自动重启服务或者当某个进程占用过多的资源的时候自动停掉进程,并且支持 Email 报警功能、远程服务器监测、web 管理界面等,功能很多很强大。vpsee 用 monit 来监测多个 VPS 和独立服务器,如果某个 VPS down 了、某个服务器资源紧张,就能第一时间知道,而且某个服务停了的话可以自动重启服务。

安装 monit
在 CentOS 下安装和配置文件:

代码如下:


# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
# rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm
# yum install monit
# vi /etc/monit.conf


配置 monit
修改 monit 的配置文件,/etc/monit.conf(CentOS)或者 /etc/monit/monitrc(Debian),每隔120秒检查一次系统,如果 httpd/MySQL/sshd 服务停掉了就重新启动相应服务。对于 httpd 服务器,当发现 CPU/MEM 占用过大、loadavg 太高时就执行相应的报警、重启服务指令。如果使用 Email 报警功能,需要配置 Email 地址、邮件服务器等信息:

代码如下:


set daemon 120
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
check process mysql with pidfile /var/run/mysqld/mysqld.pid
group database
start program = “/etc/init.d/mysqld start”
stop program = “/etc/init.d/mysqld stop”
if failed host 127.0.0.1 port 3306 then restart
if 5 restarts within 5 cycles then timeout
check process nginx with pidfile /var/run/nginx.pid
start program = “/etc/init.d/nginx start”
stop program = “/etc/init.d/nginx stop”
if failed host www.yanghengfei.com port 80 protocol http
then restart
check process php_cgi with pidfile /var/run/php_cgi.pid
start program = “/etc/init.d/php_cgi start”
stop program = “/etc/init.d/php_cgi stop”
if failed host 127.0.0.1 port 9000 then restart
if 5 restarts within 5 cycles then timeout
check process apache with pidfile /var/run/httpd.pid
group www
start program = “/etc/init.d/httpd start”
stop program = “/etc/init.d/httpd stop”
if failed host www.yanghengfei.com port 8080 protocol http
then restart
if cpu is greater than 80% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if totalmem > 512 MB for 5 cycles then restart
if children > 200 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if 3 restarts within 5 cycles then timeout


更多详细信息可以参考配置文件,里面注释写得很详细。

启动 monit
在 CentOS 下启动并加入到系统启动脚本:

代码如下:


# /etc/init.d/monit start
# /sbin/chkconfig monit on

到此,关于“怎么用Monit监测Linux服务器”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!


文章标题:怎么用Monit监测Linux服务器
网站网址:http://cdkjz.cn/article/pgpjgi.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220