monit介绍和配置
1.介绍
monit监控和管理进程、程序、文件、目录和Unix系统的文件的工具。可以进行自动维护和修理,在错误的情况下执行有意义的因果关系的行动。比如,某个进程没有运行启动它;没有响应重启它;占用太多资源停止该进程等等。也可以用来监控文件、目录或系统文件的变化,如时间戳的改变,检验和的改变或大小的改变
2.安装:(需先装epel源)
yum install monit -y
3.配置
3.1 monit 的配置文件monit.conf
set daemon 30 监控检查的时间间隔
set logfile syslog 默认日志为syslog,还可以设置为自定义路径下的文件
set pidfile /var/run/monit.pid 设置pid文件的位置
set idfile /var/.monit.id 设置监控项目唯一ID的文件位置 默认在$HOME/.monit.id
set statefile /var/.monit.state 默认存储每个周期内monitorinig 状态的文件
set mailserver mail.bar.baz 主的邮件服务器
backup.bar.baz port 10025 备的邮件服务器
set mail-format { 设置邮件告警的格式
from: monit@$HOST
subject: monit alert -- $EVENT $SERVICE
message: $EVENT Service $SERVICE
Date: $DATE
Action: $ACTION
Host: $HOST
Description: $DESCRIPTION
Your faithful employee,
Monit
}
set alert sysadm@foo.bar 设置接收告警的邮箱
以上是全局的配置,具体的services监控语法后面会介绍
3.2 进程监控
在 /etc/monit.d/下创建 nginx ,,并重启monit。内容如下
check process nginx with pidfile /usr/local/xywy/nginx/run/nginx.pid
start program = "/usr/local/xywy/nginx/sbin/nginx" with timeout 30 seconds
stop program = "/usr/local/xywy/nginx/sbin/nginx -s stop"
3.3 监控文件
在/etc/monit.d/下创建monit_test ,并重启monit,内容如下
check file monit.conf path /etc/monit.conf
group system
if changed sha1 checksum
then exec "/usr/local/bin/monit -c /etc/monit.conf reload"
3.4 监控文件设备
check device VAR_LOG with path /var/log
if space usage > 85% then alert check filesystem tmpfs with path /var
if space usage > 80% then alert
下面是配置综合案例
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.vpsee.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.vpsee.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
3.5 monit命令使用
-c 指定配置文件
-d 后台运行
-l 指定logfile
-p 指定pid file
-s 指定statefile
<wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">
monit介绍和配置的更多相关文章
- 03_MyBatis基本查询,mapper文件的定义,测试代码的编写,resultMap配置返回值,sql片段配置,select标签标签中的内容介绍,配置使用二级缓存,使用别名的数据类型,条件查询ma
1 PersonTestMapper.xml中的内容如下: <?xmlversion="1.0"encoding="UTF-8"?> < ...
- python学习第二讲,pythonIDE介绍以及配置使用
目录 python学习第二讲,pythonIDE介绍以及配置使用 一丶集成开发环境IDE简介,以及配置 1.简介 2.PyCharm 介绍 3.pycharm 的安装 二丶IDE 开发Python,以 ...
- Monit安装与配置
Monit安装与配置 monit 监控并自动重启服务 官方文档
- OSPF协议介绍及配置 (上)
OSPF协议介绍及配置 (上) 一.OSPF概述 回顾一下距离矢量路由协议的工作原理:运行距离矢量路由协议的路由器周期性的泛洪自己的路由表,通过路由的交互,每台路由器都从相邻的路由器学习到路由,并且加 ...
- x-pack 功能介绍及配置传输层安全性(TLS / SSL)
x-pack 功能介绍及配置传输层安全性(TLS / SSL) 学习了:https://blog.csdn.net/wfs1994/article/details/80411047
- mysql多实例介绍及配置
mysql多实例介绍及配置 1.mysql多实例介绍 1.1 什么是mysql多实例 mysql多实例就是在一台机器上开启多个不同的服务端口(如:3306,3307),运行多个MySQL服务进程,通过 ...
- 13.LAMP架构介绍及配置
LAMP架构介绍及配置 LAMP简介与概述 LAMP概述 LAMP架构是目前成熟的企业网站应用模式之一,指的是协同工作的一整套系统和相关软件,能够提供动态Web站点服务及其应用开发环境. LAMP是一 ...
- Rsync原理介绍及配置应用
1.前言 基于LAN或WAN的网络应用之间进行数据传输或者同步非常普遍,比如远程数据镜像.备份.复制.同步,数据下载.上传.共享等等.对此,最简单.直接的做法是对数据进行完全复制.然而,数据在网络上来 ...
- 日志组件logback的介绍及配置使用方法
一.logback的介绍 Logback是由log4j创始人设计的又一个开源日志组件.logback当前分成三个模块:logback-core,logback- classic和logback-acc ...
随机推荐
- Java 集合总体框架介绍
Java集合是java提供的工具包,包含了常用的数据结构:集合.链表.队列.栈.数组.映射等.Java集合工具包位置是java.util.*Java集合主要可以划分为4个部分:List列表.Set集合 ...
- Java第一课
1.引入Java虚拟机原因?过程:源文件--编译器(使用javac命令)-----二进制的字节码文件(平台无关)--解释器(使用Java命令)-----可执行文件结论:Java中的跨平台是通过[JVM ...
- Oracle数据库访问其他用户下的表,不加表所属的用户名的实现方法
一. 问题: 如何实现在Oracle数据库中访问其他用户的表时不需加表所属的用户名 二. 举例: Oracle里面的用户A,要访问用户B的表需要带用户B的前缀,如访问用户B的 TEST表,需要这样访问 ...
- JQ02
JQ02 1.css操作 .css(属性名,属性值)://要有双引号 修改单个样式,若要修改多个,需采用以下方式: 以对象为参数 它还可以获取样式: .css("属性名") 若元素 ...
- Node + Selenium使用小结
可参考网上的步骤进行操作.例如这篇文章:https://wangheng3751.github.io/2018/01/17/selenium/ 1.安装Node.js,去官网下载最新版本的Node.j ...
- pycharm 注册码/License server 2017年最新
两种方法: 1.选License server激活,输入:http://idea.imsxm.com 2.2017年激活码 时效1年BIG3CLIK6F-eyJsaWNlbnNlSWQiOiJCSUc ...
- PPTP服务端与客户端 修改默认PPTP默认端口1723
linux pptp服务端:我们在Linux下建立的pptpd端口号默认是1723,有时候这个端口并不是那么的好用,不是麽?所以服务端修改端口号比较简单 修改 /etc/services 文件查找 1 ...
- js-工具函数
/** * 将文件大小转换成 ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],单位 * @param bytes * @returns */ ...
- [Vuex] Create a Vuex Store using TypeScript
A Vuex store centralizes the state of your app, making it easy to reason about your state flow. In t ...
- 对Faster R-CNN的理解(3)
2.2 边框回归 边框回归使用下面的几个公式: xywh是预测值,带a的是anchor的xywh,带*的是GT Box的xywh,可以看作是anchor经过一定的变换回归到附近的GT Box.