我已经设置了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
}
答案 0 :(得分:0)
我认为你有一个错字。
如果您设置interval = 0
(而不是“interval = 0 s ”),它应该有效
更改后,您必须重新启动icinga服务。