Icinga2 仅在状态更改时通知一次

标签 icinga2

我已将 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 = 0s”),它应该可以工作

更改后,您必须重新启动 icinga 服务。

关于Icinga2 仅在状态更改时通知一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50871100/

相关文章:

linux - icinga2 监控正在运行的 linux 服务

graphite - 从 Icinga2 读取 Graphite 事件

centos - 监控 yum/rpm 包冲突

mysql计算前一行时间戳差异并按多个对象分组

linux - 从 Icinga2 输出中删除 NFS 挂载分区?

redis - Icinga2:在远程主机而不是主机上运行检查

mysql - 如何在 Icinga2 服务器中重新设置数据库配置?

centos - 无法在 CentOS 8 上安装 Icinga Web 2