主機通知選項 host_notification_options
| 代碼 | 觸發條件 |
| d | 主機 DOWN 狀態 |
| u | 主機 UNREACHABLE 狀態 |
| r | 主機恢復 (UP 狀態) |
| f | 主機開始/停止抖動 |
| s | 排程停機開始/結束 |
| n | 不接收任何主機通知 |
服務通知選項 service_notification_options
| 代碼 | 觸發條件 |
| w | 服務 WARNING 狀態 |
| u | 服務 UNKNOWN 狀態 |
| c | 服務 CRITICAL 狀態 |
| r | 服務恢復 (OK 狀態) |
| f | 服務開始/停止抖動 |
| n | 不接收任何服務通知 |
常用推薦配置
# 主機:故障、不可達、恢復
host_notification_options: d,u,r
# 服務:警告、未知、嚴重、恢復
service_notification_options: w,u,c,r
配置範例
define contact {
contact_name admin
host_notification_options d,u,r
service_notification_options w,u,c,r
host_notification_period 24x7
service_notification_period 24x7
host_notification_commands notify-host-by-email
service_notification_commands notify-service-by-email
email admin@example.com
}
進階調整建議
- 關鍵服務:加上
f 監控抖動狀態
- 非核心時段:使用
notification_period 限制通知時間
- 升級通知:配合
escalations 實現分級告警
- 抑制通知:善用
host_dependencies, service_dependencies 避免風暴
Nagios 狀態代碼對照
| 服務狀態 | 代碼 | 主機狀態 | 代碼 |
| OK | 0 | UP | 0 |
| WARNING | 1 | DOWN | 1 |
| UNKNOWN | 2 | UNREACHABLE | 2 |
| CRITICAL | 3 | | |
精準配置通知選項,能有效減少告警疲勞,確保關鍵事件第一時間觸達負責人。