monit配置文件

监控模式:(MONITRING MODE)app

Monit支持三种监控模式,post

active--Monitj监控一个服务,为了防止一系列问题,Monit会执行以及发送警报,中止,启动,重启,这是一个缺省的模式ui

passive--MOnit监控一个服务,不会尝试去修复这个问题,但仍是会发送警报spa

manual--Monit监控进入active模式,经过monit的控制,好比在控制台执行命令,好比 Monit start sybase.net

 

  (Monit will call sybase's start method and enable monitoring)

 

 

ALERT MESSAGESrest

Monit会发送一个邮件提醒,在下列状况code

 

o A service timed out
 o A service does not exist
 o A service related data access problem
 o A service related program execution problem
 o A service is of invalid object type
 o A program status failed
 o A icmp problem
 o A port connection problem
 o A resource statement match
 o A file checksum problem
 o A file size problem
 o A file/directory timestamp problem
 o A file/directory/filesystem permission problem
 o A file/directory/filesystem uid problem
 o A file/directory/filesystem gid problem
 o An action is done per administrator's request

 

Monit 会发送一个警报只要被监控对象发生了改变,这些对象包括orm

 

 

 o Monit started, stopped or reloaded
 o A file checksum changed
 o A file size changed
 o A file content match
 o A file/directory timestamp changed
 o A filesystem mount flags changed
 o A process PID changed
 o A process PPID changed

 

 

警报状态有两种形式server

Global -- common for all services对象

local -- per service

在没一种形式下你均可以发送多个警报状态,换句话说你能够发懊恼过不一样的邮件到不一样的地址

Setting a global alert statement

{

   若是在监控服务发生了改变,Monit将会发送一个警报到全局列表的全部的接受者,下面是全局警报的语法

   SET ALERT mail-address [[NOT]{EVENTS}]  [MAIL-FORMAT {mail-format}] [REMINDER number]

   简单使用:set alert foo@bar

  EVENTS,MAIL-FORMAT,REMINDER看下面使用用法

 Setting a local alert statement

 每个服务能够有他本身的接收列表

ALERT mail-address [[NOT]{EVENTS}]  [MAIL-FORMAT {mail-format}] [REMINDER number]

没有了SET就成了局部的了

或者NOALERT  mail-address

若是你只想接受某些服务的某些警报信息的话,好比你只想接受timeout或者nonexist事件,那么你能够这么写

 

check process myproc with pidfile /var/run/my.pid
   alert foo@bar only on { timeout, nonexist } 
   ...

 

 

你能够指定除去某些事件外发送警报信息,好比你想监听全部时间除了instance事件,那么你能够这么写

 

 check system myserver
   alert foo@bar but not on { instance } 
   ...

 

至关于

 

 

  alert foo@bar on { action
                      checksum
                      connection
                      content
                      data
                      exec
                      fsflags
                      gid
                      icmp
                      invalid
                      nonexist
                      permission
                      pid
                      ppid
                      resource
                      size
                      status
                      timeout
                      timestamp
                      uid
                      uptime }

 

一个instance事件是指Monit程序启动或者中止

 

你也能够根据事件的不一样来发送给不一样的邮件

 

 alert foo@bar { nonexist, timeout, resource, icmp, connection }
 alert security@bar on { checksum, permission, uid, gid }
 alert manager@bar

 

能够在邮件过滤器中使用的事件以下:

 

action,checksum, connection, content, data, exec, fsflags, gid, icmp,instance, invalid, nonexist, permission, pid, ppid, resource, size, status, timeout, timestamp, uid, uptime

 

你能够使用

 

noalert appadmin@bar来进行不接受警报的邮箱

 

 

 

set alert foo@bar
 
 check process myfoo with pidfile /var/run/myfoo.pid
   ...
 check process mybar with pidfile /var/run/mybar.pid
   alert foo@bar only on { timeout }

 

 
$EVENT  
  
     A string describing the event that occurred. The values are  
     fixed and are:  
  
     Event:    | Failure state:           | Success state:                
     -------------------------------------------------------------------  
     ACTION    | "Action done"            | "Action done"                 
     CHECKSUM  | "Checksum failed"        | "Checksum succeeded"          
     CONNECTION| "Connection failed"      | "Connection succeeded"        
     CONTENT   | "Content failed",        | "Content succeeded"  
     DATA      | "Data access error"      | "Data access succeeded"       
     EXEC      | "Execution failed"       | "Execution succeeded"         
     FSFLAG    | "Filesystem flags failed"| "Filesystem flags succeeded"  
     GID       | "GID failed"             | "GID succeeded"               
     ICMP      | "ICMP failed"            | "ICMP succeeded"              
     INSTANCE  | "Monit instance changed" | "Monit instance changed not"  
     INVALID   | "Invalid type"           | "Type succeeded"              
     NONEXIST  | "Does not exist"         | "Exists"                      
     PERMISSION| "Permission failed"      | "Permission succeeded"        
     PID       | "PID failed"             | "PID succeeded"  
     PPID      | "PPID failed"            | "PPID succeeded"  
     RESOURCE  | "Resource limit matched" | "Resource limit succeeded"    
     SIZE      | "Size failed"            | "Size succeeded"              
     STATUS    | "Status failed"          | "Status succeeded"              
     TIMEOUT   | "Timeout"                | "Timeout recovery"            
     TIMESTAMP | "Timestamp failed"       | "Timestamp succeeded"         
     UID       | "UID failed"             | "UID succeeded"               
     UPTIME    | "Uptime failed"          | "Uptime succeeded"  
  
    $SERVICE  
  
     The service entry name in monitrc  
  
    $DATE  
  
     The current time and date (RFC 822 date style).  
  
    $HOST  
  
     The name of the host Monit is running on  
  
    $ACTION  
  
     The name of the action which was done. Action names are fixed  
     and are:http://write.blog.csdn.net/postedit/9564261  
  
     Action:  | Name:  
     --------------------  
     ALERT    | "alert"  
     EXEC     | "exec"  
     RESTART  | "restart"  
     START    | "start"  
     STOP     | "stop"  
     UNMONITOR| "unmonitor"  
  
    $DESCRIPTION  
  
     The description of the error condition  

 



相关文章
相关标签/搜索