我已设置icinga2来监视具有不同间隔的一些服务,因此可能每10秒检查一次一项服务。如果出现严重错误,我将收到一条通知,但是如果错误仍然存在,或者直到我确认之前,我将每10秒收到一次通知。我只想为每个状态更改接收一次。然后也许再过指定的时间,但这并不重要。
这是我的配置:
这或多或少是标准template.conf,但是我添加了“interval = 0s”,因为我读到它应该防止多次发送通知。
template Notification "mail-service-notification" {
command = "mail-service-notification"
interval = 0s
states = [ OK, Critical ]
types = [ Problem, Acknowledgement, Recovery, Custom,
FlappingStart, FlappingEnd,
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
vars += {
notification_logtosyslog = false
}
period = "24x7"
}
这是notification.conf中包含模板的部分:
object NotificationCommand "telegram-service-notification" {
import "plugin-notification-command"
command = [ SysconfDir + "/icinga2/scripts/telegram-service-notification.sh" ]
env = {
NOTIFICATIONTYPE = "$notification.type$"
SERVICEDESC = "$service.name$"
HOSTNAME = "$host.name$"
HOSTALIAS = "$host.display_name$"
HOSTADDRESS = "$address$"
SERVICESTATE = "$service.state$"
LONGDATETIME = "$icinga.long_date_time$"
SERVICEOUTPUT = "$service.output$"
NOTIFICATIONAUTHORNAME = "$notification.author$"
NOTIFICATIONCOMMENT = "$notification.comment$"
HOSTDISPLAYNAME = "$host.display_name$"
SERVICEDISPLAYNAME = "$service.display_name$"
TELEGRAM_BOT_TOKEN = TelegramBotToken
TELEGRAM_CHAT_ID = "$user.vars.telegram_chat_id$"
}
}
apply Notification "telegram-icingaadmin" to Service {
import "mail-service-notification"
command = "telegram-service-notification"
user_groups = [ "icingaadmins" ]
assign where host.name
}
最佳答案
我想你有错字了。
如果您设置interval = 0
(不是“interval = 0 s ”),它应该可以工作
更改之后,您必须重新启动icinga服务。
关于icinga2 - Icinga2通知状态更改仅一次,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50871100/