我们有 3 个服务模板,low-priority
和high-priorty
。medium-priorty
低优先级服务附加到联系人组low
,中优先级服务附加到联系人组medium
,高优先级服务附加到联系人组(好吧,您可能明白了)。
低优先级服务不通知,中优先级警报通过电子邮件通知,高优先级警报通过电子邮件和电话通知。但它们目前还没有
我需要做的是指定high-priorty
服务生成的任何警报都应运行通知命令notify-service-by-email
和notify-service-by-phone
。通过阅读文档(以及我对 Nagios 的了解),我知道设置通知命令的唯一方法是service_notification_commands
联系人中的选项,但这意味着每个联系人都需要两个定义,一个用于电话,一个用于电子邮件。我如何让high-priority
服务调用该notify-service-by-phone
命令?
更多信息;
服务模板
;High priority service (Alert by call, 1 min check period)
define service{
name high-priority-service
notifications_enabled 1
normal_check_interval 1
contact_groups high
use generic-service
register 0
}
;Med priority service (Alert by email, 5 min check period)
define service{
name med-priority-service
notifications_enabled 1
normal_check_interval 5
contact_groups medium
use generic-service
register 0
}
;Low priority service (No alert, 10 min check period)
define service{
name low-priority-service
normal_check_interval 10
use generic-service
register 0
}
(generic-service
是 NAGIOS 配置的默认模板,略有调整)
服务
define service{
use high-priority-service
hostgroup_name generic-server-nrpe
service_description SSH
check_command check_ssh
}
联系人组
define contactgroup{
contactgroup_name low
alias Low Priority Notifications
members sam,[...]
}
define contactgroup{
contactgroup_name medium
alias Medium Priority Notifications
members sam,[...]
}
define contactgroup{
contactgroup_name high
alias High Priority Notifications
members sam,[...]
}
联系方式
define contact{
name generic-contact
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r,f,s
host_notification_options d,u,r,f,s
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
register 0
}
define contact{
contact_name sam
use generic-contact
alias Sam
email sam[...]
address1 +44[...]
}
答案1
看来您需要对联系人进行两次定义。一次定义仅通过电子邮件通知,另一次定义通过电子邮件和电话通知。
define contact{
name generic-contact-high
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r,f,s
host_notification_options d,u,r,f,s
service_notification_commands notify-service-by-email,notify-service-by-phone
host_notification_commands notify-host-by-email
register 0
}
define contact{
name generic-contact-med
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r,f,s
host_notification_options d,u,r,f,s
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
register 0
}
您的联系人应根据以下两种类型的联系人进行定义:
define contact{
contact_name sam-high
use generic-contact-high
alias Sam
email sam[...]
address1 +44[...]
}
define contact{
contact_name sam-med
use generic-contact-med
alias Sam
email sam[...]
address1 +44[...]
}