自學Zabbix3.10.2-事件通知Notifications upon events-Actions報警配置
如何配置zabbix報警,也就是zabbix的action配置,action支援如下事件:
- 觸發器事件 - 觸發器狀态在OK和PROBLEM之間變化(本節内容)
- 發現事件
- 自動注冊時間 - 新的用戶端注冊進來
- 内部事件 - item轉變為unsupported狀态,觸發器轉變為unknown狀态
配置action
1. Action建立
點選configuration(配置)->Actions(報警)->選擇事件來源
2. Action配置
參數:
- Name : 唯一的action名字
- Default subject: 報警的預設标題
- Default message: 報警的預設内容
-
Recovery message:是否在問題解決後發送消息。恢複消息,是否在報警恢複正常後發送消息。 Zabbix将“OK”狀态的Trigger認為是一個恢複recovery event。
注意:如果使用了Escalation機制,Recovery event隻會觸發一次。對已Recovery的報警,可以像發出報警的郵件一樣,設定報警标題和内容。
- Enabled:是夠啟用這個action
以下幾點需要注意:
- 自定義的恢複資訊,隻針對Condition,是“Trigger value is PROBLEM”的生效。
- 恢複資訊隻會發送給那些之前收到過關于這個Action報警資訊的人。
- 恢複資訊和Action 依賴PROBLEM生成的Evnet維護同一份ACK狀态。
- 在Recovery資訊中,EVENT.*Macro中的資料,都是基于出問題的Event,而不是Recovery。
- 在Recovery資訊中,EVENT.RECOVERY.* 表示的是出自Recovery event的資料。
Default message詳細内容:
Trigger: {TRIGGER.NAME}
Trigger status: {TRIGGER.STATUS}
Trigger severity: {TRIGGER.SEVERITY}
Trigger URL: {TRIGGER.URL}
Item values:
1. {ITEM.NAME1} ({HOST.NAME1}:{ITEM.KEY1}): {ITEM.VALUE1}
2. {ITEM.NAME2} ({HOST.NAME2}:{ITEM.KEY2}): {ITEM.VALUE2}
3. {ITEM.NAME3} ({HOST.NAME3}:{ITEM.KEY3}): {ITEM.VALUE3}
Original event ID: {EVENT.ID}
3. 條件conditions配置
Type Of calculation:各種條件之間的關系,包含AND、OR 以及AND/OR,如上圖是AND關系,同時要滿足以上機器不在維護狀态以及觸發器值為PROBLEM才會觸發報警的動作。
Condition type | Supported operators | Description |
Application | = like not like | 限定application = 名字與application中的名字完全一緻 like - 名字包含 not like - 名字不包含 |
Host group | = <> | Host是否屬于一個Host group = - event belongs to this host group. <> - event does not belong to this host group. |
Template | = <> | Trigger是否屬于一個Template = - event belongs to a trigger inherited from this template. <> - event does not belong to a trigger inherited from this template. |
Host | = <> | Host是否是某一個Template = - event belongs to this host. <> - event does not belong to this host. |
Trigger | = <> | 觸發的trigger是否是某一個Trigger = - event is generated by this trigger. <> - event is generated by any other trigger, except this one. |
Trigger name | like not like | Trigger名字是否和一個字元串比對 like - event is generated by a trigger, containing this string in the name. Case sensitive. not like - this string cannot be found in the trigger name. Case sensitive. Note: Entered value will be compared to trigger name with all macros expanded. |
Trigger severity | = <> >= <= | Trigger的嚴重等級範圍 = - equal to trigger severity <> - not equal to trigger severity >= - more or equal to trigger severity <= - less or equal to trigger severity |
Trigger value | = | Trigger是OK還是PROBLEM = - equal to trigger value (OK or PROBLEM) |
Time period | in not in | Event生成的時間是否屬于某一個範圍 in - event time is within the time period. not in - event time is not within the time period. See Time period specification page for description of the format. |
Maintenance status | in not in | Host是否在Maintenance狀态,如果Trigger中有多個Host,至少其中一個是(或者不是)Maintenace狀态 in - host is in maintenance mode. not in - host is not in maintenance mode. Note: If several hosts are involved in the trigger expression, the condition matches if at least one of the hosts is/is not in maintenance mode. |
4. operations配置
此處沒有報警的動作,當你滿足了報警條件也沒有任何意義,因為你不執行任何報警的操作,那還要action做什麼,對吧?話說回來,每個action都必須配置operations。
Parameter | Description |
Default operation step duration | 最小60秒,例如,設定了1小時,則表明執行了一個操作,要等待一個小時,才會執行下一個操作 |
Action operations | Steps - 報警更新的時候,會按照step的順序來執行 Details - 操作類型和目标。從zabbix2.2開始,會顯示在發送資訊時的medial type(e-mail,SMS,Jabber,etc)使用者的名字也會顯示。 Start in - 在event發生後多久執行 Duration (sec) - 顯示的是step的持續時間,如果step使用了預設的'持續時間',那麼顯示default Action - 顯示的是兩個标簽"edit","remove",用來編輯和移除operation的操作 |
Operation details | |
step | 在escalation的過程中的執行計劃 From - 從哪一步執行開始 To - 到哪一步執行結束 (0=無窮, 執行将不被限制) Step duration - 每一步持續時間 (0=使用上面預設的). 可以在同一個步驟中,進行多個操作,如果這些操作有多個duration,那麼會選擇最短的那個生效 |
Operation type | 有如下2種: Send message - 給使用者發送資訊 Remote command - 執行遠端指令 對于discovery事件和auto-registration事件,可以在這裡選擇更多的操作 |
Operation type: send message | |
Send to user groups | 可以添加選擇User groups |
Send to users | 添加選擇使用者 |
Send only to | 發送的消息是定義好的media type |
Default message | 如果選擇,預設消息格式将被使用 |
Subject | Subject of the custom message. The subject may contain macros. |
Message | The custom message. The message may contain macros. |
Operation type: remote command | |
Target list | Select current host, other hosts or host groups as targets to execute the command on. |
Type | Select the command type: IPMI - execute an IPMI command Custom script - execute a custom set of commands. You can select to execute the command on Zabbix agent or Zabbix server. SSH - execute an SSH command Telnet - execute a Telnet command Global script - execute one of the global scripts defined in Administration→Scripts. |
Commands | Enter the command(s). |
Conditions | Condition for performing the operation: Not ack - only when the event is unacknowledged Ack - only when the event is acknowledged. |
圖檔上的step說的可能不是很明白,表示階段,1表示第一次報警,如果2表示第二次報警。action operations可以添加多個,如下: