皇室小萌狐,张国明是什么人,燕子专列
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
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
相关文章:
-
-
-
应用系统分布式构建运维
应用系统分布式构建运维 1+x初级,项目四 部署主从数据库 基础环境安装 准备两台主机 修改主机名 # hostnamectl set-hos...
[阅读全文]
-
-
Linux环境变量
在bash shell中,环境变量分为两类: 全局变量 局部变量 全局环境变量 全局环境变量对于shell会话和所有生成的子shell都是可见的。例如 ...
[阅读全文]
-
-
-
初步进入Linux世界
初步进入Linux世界 一、Linux目录介绍 1.树型目录结构 Linux文件系统采用了多级目录的树型层次结构管理文件。树型结构的最上层是根目录,用/...
[阅读全文]
-
Linux常用命令(详细)
Linux常用命令 一、控制台相关命令 控制台命令就是指通过字符界面输入的可以操作系统的命令。我们现在要了解的是基于Linux操作系统的基本控制台命令。...
[阅读全文]
-
-
网友评论