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  

 



相關文章
相關標籤/搜索