monit 监控并自动重启服务
set logfile /home/monit/log/monit.log //monit的日志文件
set alert zhouwei@chinabank.com.cn with reminder on 1 cycle //出现1次错误的时候发报警邮件到指定的邮箱
#set mailserver mail.tildeslash.com, mail.foo.bar port 10025, localhost with tim
eout 15 seconds
set mailserver 10.10.9.109 //设置邮件服务器
allow localhost # Allow localhost to connect //允许本机访问
allow 10.10.8.0/24 //允许此IP段访问
allow admin:nishiwode # Allow Basic Auth //认证的用户名和密码
check system 10.10.8.2
if loadavg (1min) > 4 then alert
if loadavg (5min) > 2 then alert
if memory usage > 75% then alert
if cpu usage (user) > 70% then alert
if cpu usage (system) > 30% then alert
if cpu usage (wait) > 20% then alert
check device data with path /dev/sda2
if space usage > 90% then alert
if inode usage > 85% then alert
if space usage > 85% then alert
if inode usage > 85% then alert
# all rsync
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 protocol ssh then restart
if 5 restarts within 5 cycles then timeout
check process httpd with pidfile /var/run/httpd.pid
group apache
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host 127.0.0.1 port 80
protocol http then restart
if 5 restarts within 5 cycles then timeout
//监控http服务
check process web_lb with pidfile /data/v20/server/web_lb/httpd.pid
start program = "/data/v20/bin/lb.sh" //启动脚本
stop program = "/data/v20/bin/lb_stop.sh" //停止脚本
if failed host 10.10.8.2 port 16101 proto http then restart
if failed host 10.10.8.2 port 16101 proto http for 5 times within 5 cycles t
hen exec "/data/v20/bin/lb_pay.sh"
if failed host 10.10.8.2 port 16102 type TCPSSL proto http then restart
if failed host 10.10.8.2 port 16102 type TCPSSL proto http for 5 times withi
n 5 cycles then exec "/data/v20/bin/lb_pay.sh
# vi /etc/inittab
添加:
mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc
# init -q或者# telinit -q
You can verify that monit is started from /var/log/message log file:
# tail -f /var/log/message
如果正常启动能看到如下输出:
Nov 21 04:39:21 server monit[8759]: Starting monit daemon
Nov 21 04:39:21 server monit[8759]: Monit started
最后可以测试一下,看看是否有让你满意的效果.
本文出自 “风吹云动” 博客,请务必保留此出处http://coolerfeng.blog.51cto.com/133059/50126
monit 监控并自动重启服务的更多相关文章
- zabbix通过curl命令判断web服务是否正常并自动重启服务
zabbix通过curl命令判断web服务是否正常并自动重启服务 主要思路: 通过curl命令获取服务器响应码,如果正常返回200,不正常返回000 具体命令: curl -I -s -w " ...
- windows service自动重启服务
服务一般都能正常的运行,但有时候也会有一些假死现象,比如公司有一考勤服务就因为依赖于硬件厂家的api, 但厂家api运行一段时间后会默名的假死,引起整个服务假死,因为这一假死现象具有不确定性,所以不太 ...
- systemd实践: 依据情况自动重启服务【转】
1.最简单的自动重启范例 [Unit] Description=mytest [Service] Type=simple ExecStart=/root/mytest.sh Restart=alway ...
- tomcat监控,自动重启shell脚本
tomcat监控,自动重启shell脚本如下,取名 monitor_tomcat.sh: #!/bin/sh # func:自动监控tomcat脚本并且执行重启操作 # 获取tomcat进程ID(其中 ...
- Node.js热部署代码,实现修改代码后自动重启服务方便实时调试
写PHP等脚本语言的时候,已经习惯了修改完代码直接打开浏览器去查看最新的效果.而Node.js 只有在第一次引用时才会去解析脚本文件,以后都会直接访问内存,避免重复载入,这种设计虽然有利于提高性能,却 ...
- 监控windows服务,当服务停止后自动重启服务
近期花时间研究了一下windows和linux下某服务停了后自动重启的功能,在网上收集了些资料,并经过测试,在此整理一下.这里介绍的是windows服务的监控,是通过批处理来实现的.本例是监控wind ...
- 【 Zabbix 】nginx监控及故障重启服务
zabbix agentd 端配置: nginx.conf 配置: location /ngx_status { stub_status on; access_log off; allow 10.0. ...
- nodejs之pm2自动重启服务
pm2 start xxx #启动服务器 pm2 list #查看运行状态 pm2 logs #查看日志 pm2 restart xxx #重启应用 pm2 stop xxx #停止应用 监听修改,并 ...
- 【 Zabbix 】— Tomcat监控及故障重启服务
一.监控tomcat原理 zabbix_server开启java poller,zabbix_java开启JavaGateway, 端口为:10052,tomcat JMX开启12345提供性能数据. ...
随机推荐
- 运行python代码报错UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 91: ordinal not in range(128)的解决办法
1.通过搜集网上的资料,自己多次尝试,问题算是解决了,在代码中加上如下几句即可: import sys reload(sys) sys.setdefaultencoding('utf-8') 2.原因 ...
- 一些免费收费api收藏
转载:http://blog.csdn.net/sdjianfei/article/details/53157334 一 .api 1.http://apistore.baidu.com/astore ...
- [日常训练]最大M子段和
Description 在长度为的序列中选出段互不相交的子段,求最大字段和. Input 第一行两个整数. 第二行个整数. Output 一行一个整数表示最大值. Sample Input 5 2 1 ...
- Java中的异常处理:何时抛出异常,何时捕获异常?
今天在看hadoop源码时,想想自己最近在做的那个系统,发现很多异常处理的方式不对,还是按照传统的异常处理方式(即:采用返回值来标识程序出现的异常情况).而hadoop中很多方法的声明是有异常抛出的, ...
- Nodejs系列-01-开篇
1.解决什么问题 1. 并发连接 举个例子,想象一个场景,我们在银行排队办理业务,我们看看下面两个模型. (1)系统线程模型: 这种模型的问题显而易见,服务端只有一个线程,并发请求(用户)到达只能处理 ...
- [IOS Tableview] cell自定义view显示错误问题
问题介绍:按照tableviewcell的tag自定义cell的view显示的时候,会出现拖动时显示错误情况(在Tableview的范围超出屏幕范围需要滑动的情况下). 我做的是一个下载界面,我为了简 ...
- MYSQL入门(三)
索引简介 索引是对数据库表中一个或多个列(例如,employee 表的姓名 (name) 列)的值进行排序的结构.如果想按特定职员的姓来查找他或她,则与在表中搜索所有的行相比,索引有助于更快地获取信息 ...
- python group()
正则表达式中,group()用来提出分组截获的字符串,()用来分组 #!/usr/bin/python import re line = "Cats are smarter than dog ...
- 国家电力项目SSH搭建
SSH项目框架搭建总结: 1.建立Web工程 * 导入需要的jar的包 db:连接数据库的驱动包 hibernate:使用hibernate的jar包 jstl:java的标准标签库 junit:测试 ...
- Processing Images
https://developer.apple.com/library/content/documentation/GraphicsImaging/Conceptual/CoreImaging/ci_ ...