1.存在性检测

功能:检测文件或者服务不存在时进行相应的动作,默认是重启

语法:

IF [DOES] NOT EXIST [[<X>] <Y> CYCLES]    THEN     action    [ELSE IF SUCCEEDED [[<X>] <Y> CYCLES] THEN action]

action的相关动作:ALERT告警  、RESTART 重启 、START 启动、 STOP关闭、EXEC 执行命令、 UNMONITOR 不监控

例子:

check process named with pidfile /var/run/named.pid

start program = “/etc/init.d/named start”

stop program  = “/etc/init.d/named stop”

if failed port 53 use type udp protocol dns then restart

if 3 restarts within 5 cycles then timeout

如果53的udp端口不通,就重启

2.资源检测

功能:检测对象的指标是否达到某个值,然后进行相应的动作

语法:

IF  resource  operator value [[<X>] <Y> CYCLES]    THEN    action [ELSE IF SUCCEEDED [[<X>] <Y> CYCLES] THEN action]

resource:就是监控的对象,如"CPU", "TOTALCPU", "CPU([user|system|wait])", "MEMORY", "SWAP", "CHILDREN", "TOTALMEMORY", "LOADAVG([1min|5min|15min])".

operator:逻辑判断符号,如 > ,=,< 等

action的相关动作:ALERT告警  、RESTART 重启 、START 启动、 STOP关闭、EXEC 执行命令、 UNMONITOR 不监控

例子:

 check system myhost.mydomain.tld
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
 

3.文件校验码检测

功能:检测文件是否发生变化

例子:

  check file apache_bin with path /usr/local/apache/bin/httpd
if failed checksum and
  expect the sum 8f7f419955cefa0b33a2ba316cba3659 then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor
alert security@foo.bar on {
  checksum, permission, uid, gid, unmonitor
} with the mail-format { subject: Alarm! }
group server
 

4。文件大小检测

check file with path /home/laicb/test.txt  
   if does not exist for 5 cycles then alert  
   if changed size for  1 cycles then alert //如果没有指定,查看服务所对应的会发现是for 5 times within 5cycles
 

5.UID GID检测

check file passwd with path /etc/passwd
      if failed uid root then unmonitor
check file shadow with path /etc/shadow
      if failed gid root then unmonitorv

6.pid文件检测,及运行时间检测

check process myapp with pidfile /var/run/myapp.pid
   start program = "/etc/init.d/myapp start"
   stop program = "/etc/init.d/myapp stop"
   if uptime > 3 days then restart

7。监控磁盘空间

check filesystem datafs with path /dev/sdb1
      group server
      start program  = "/bin/mount /data"
      stop program  =  "/bin/umount /data"
      if failed permission 660 then unmonitor
      if failed uid root then unmonitor
      if failed gid disk then unmonitor
      if space usage > 80 % then alert
      if space usage > 94 % then stop
      if inode usage > 80 % then alert
      if inode usage > 94 % then stop
      alert root@localhost
 

8.icmp检测

check host www.tildeslash.com with address www.tildeslash.com

if failed

icmp type echo count 5 with timeout 15 seconds

then alert

monit检测语法的更多相关文章

  1. 自己写个 Drools 文件语法检查工具——栈的应用之编译器检测语法错误

    一.背景 当前自己开发的 Android 项目是一个智能推荐系统,用到 drools 规则引擎,于我来说是一个新知识点,以前都没听说过的东东,不过用起来也不算太难,经过一段时间学习,基本掌握.关于 d ...

  2. php 批量脚本检测语法错误

    shell 根据参数检测 当前php项目下 的语法错误 #!/bin/bash function getdir(){ for el in `ls $1` do dir_file=$1"/&q ...

  3. C语言-01基础语法

    1)         总结常见文件的拓展名 .c 是C语言源文件,在编写代码的时候创建 .o 是目标文件,在编译成功的时候产生 .out 是可执行文件,在链接成功的时候产生 2)         总结 ...

  4. nagios系列(五)之nagios图形显示的配置及自定义插件检测密码是否修改详解

    nagios图形显示的配置 在服务端安装相关软件 #1.图形显示管理的依赖库 yum install cairo pango zlib zlib-devel freetype freetype-dev ...

  5. 如何借助Monit搭建服务器监控系统?(1)

    许多Linux管理员依赖一种集中式远程监控系统(比如Nagios或Cacti),检查网络基础设施的健康状况.虽然集中式监控系统为管理员在处理许多主机和设备时简化了工作,但专用的监控设备显然成了单一故障 ...

  6. webshell检测方法归纳

    背景 webshell就是以asp.php.jsp或者cgi等网页文件形式存在的一种命令执行环境,也可以将其称做为一种网页后门.黑客在入侵了一个网站后,通常会将asp或php后门文件与网站服务器WEB ...

  7. python基础语法5 函数定义,可变长参数

    函数 1.什么是函数 函数就是一种工具. 可以重复调用 2.为什么要用函数 1.防止代码冗(rong)余 2.代码的可读性差 3.怎么用函数 1.定义函数-->制造工具 2.调用函数--> ...

  8. YAML_16 debug检测

    ansible]# ansible-playbook --syntax-check http.yml  //检测语法 playbook: http.yml ansible]# ansible-play ...

  9. ruby基本语法(1)

    一些学习资源 http://www.codecademy.com/zh/courses/ruby-beginner-en-d1Ylq/0/5?curriculum_id=5059f8619189a50 ...

随机推荐

  1. Codeforces Round #443 (Div. 1) A. Short Program

    A. Short Program link http://codeforces.com/contest/878/problem/A describe Petya learned a new progr ...

  2. Linux命令之rpm篇

    作业五:rpm命令 1)   挂载光盘文件到/media目录 [root@localhost 桌面]# mount /dev/sr0 /media mount: /dev/sr0 写保护,将以只读方式 ...

  3. 爬虫程序获取登录Cookie信息时遇到302,怎么处理

    最近要做个爬虫程序爬爬东西,先搞定登录授权这块,没得源代码,所以只能自行搞定了,按平时的直接发起HttpWebRequest(req)请求,带上用户名密码,好了,然后 HttpWebResponse ...

  4. GMA Round 1 二项式展开

    传送门 二项式展开 求$(2x-y+\frac{3}{x}+4z)^{12}$展开式中不含x的任意非0次幂的项的系数和. 用排列组合的思想,相当于在12个括号里选项出来.先把$2x$和$\frac{3 ...

  5. #define LT(a,b) ((a)<(b))

    就是带参数的宏定义 LT是函数名 (a,b )是参数表((a)<(b))是表达式返回一个布尔类型的值

  6. DBS:TestSys

    ylbtech-DBS:TestSys 1.返回顶部 1. -- ============================================= -- 测试系统 -- 2018-4-12 ...

  7. iOS:类似于网易云音乐的刷新条目显示弹框

    一.介绍 在app中使用刷新控件或者第三方刷新库是最常见的功能,在请求服务器时,获取数据的过程是处于不可见状态的,那么通过这个刷新状态可以给用户以直观的感受,这是增强用户体验的一个相当好的方法.我个人 ...

  8. Android Studio3.0.1集成Git

    1:前提 本机可以根据SSH的方式正常连接git服务器 2:开始配置 file-settings-Version Control 点击右边的+号天添加项目所在目录,VCS类型选择Git 点击 Conf ...

  9. dotnet ef

    dotnet ef migrations add <Name-of-Migration> dotnet ef database update

  10. TensorFlow保存和载入模型

    首先定义一个tf.train.Saver类: saver = tf.train.Saver(max_to_keep=1) 其中,max_to_keep参数设定只保存最后一个参数,默认值是5,即保存最后 ...