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提供性能数据. ...
随机推荐
- 简进祥===AFNetWorking 下载视频文件
获取沙盒中的Documents地址的代码. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUs ...
- python3 异常处理
什么是异常 Python用异常对象(exception object)来表示异常情况.遇到错误会引发异常,如果异常对象未被处理或者捕捉,程序就会用回溯(traceback)终止执行. Raise语句: ...
- java项目的划分方式:模块优先还是层优先?
I've seen and had lots of discussion about "package by layer" vs "package by feature& ...
- 【BZOJ-1391】order 最小割 + 最大全闭合图
1391: [Ceoi2008]order Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 1334 Solved: 405[Submit][Statu ...
- bzoj3262: 陌上花开(树套树)
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...
- dedeCMS /data/mysql_error_trace.php DB error raised PHP Code Injection Via /include/dedesql.class.php Log FIle Without Access Validation
目录 . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 dedecms采用面向对象封装的方式实现了功能操作的模块集中化,例如对于数据库管理 ...
- MYSQLDUMP参数详解
mysqldump客户端可用来转储数据库或搜集数据库进行备份或将数据转移到另一个SQL服务器(不一定是一个MySQL服务器).转储包含创建表和/或装载表的SQL语句. 如果你在服务器上进行备份,并且表 ...
- codevs 1051 接龙游戏(栈模拟)
传送门 Description 给出了N个单词,已经按长度排好了序.如果某单词i是某单词j的前缀,i->j算一次接龙(两个相同的单词不能算接龙). 你的任务是:对于输入的单词,找出最长的龙. I ...
- ffmpeg]ffmpeg使用参数的中文说明
基本选项: -formats 输出所有可用格式 -f fmt 指定格式(音频或视频格式) -i filename 指定输入文件名,在linux下当然也能指定:0.0(屏幕录制)或摄像头 -y 覆盖已有 ...
- 【Alpha版本】冲刺-Day7
队伍:606notconnected 会议时间:11月15日 会议总结 张斯巍(433) 今天安排:上传界面设计 完成度:95% 明天计划:回收站界面设计 遇到的问题:无 感想:从一开始界面风格就要确 ...