3

I have set up icinga2 to monitor a few services with different intervals, so one service might be checked every 10 seconds. If it gives a critical error I will receive a notification, but I will receive it every 10 seconds if the error persists, or until I acknowledge it. I just want to receive it once for each state change. Then maybe after a specified time again, but it is not that important.

Here is my config:

This is more or less the standard template.conf, but I have added the "interval=0s", because I read that it should prevent notifications from being sent multiple times.

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"
}

And here is the part of the notification.conf that includes the template:

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
}
Rohlik
  • 1,286
  • 19
  • 28
ecrag
  • 31
  • 2
  • Are you getting repeating CRITICAL notifications or are you getting RECOVERY notifications as well? – cflinspach Jun 18 '18 at 18:35
  • is there any config, with an "interval"-definition, that you load? This could overwrite the "interval"-definition of you "mail-service-notification"-configuration? you can search for it by changing into the icinga-directory (using the terminal) and using the command `grep -r "interval"` (recursively searching for any occurance of "interval" in every file) – MacMartin Jun 22 '18 at 10:13
  • I only get repeating CRITICAL, no WARNING, RECOVERY or OK, these will be sent once. – ecrag Jun 26 '18 at 06:58
  • Also I have some other configs using interval, generic-host/server in templates.conf, but for notifications I only have the one listed above. – ecrag Jun 26 '18 at 07:01

1 Answers1

1

I think you had a typo. It should work if you set interval = 0 (not "interval = 0s")

After that change you must restart the icinga service.

MacMartin
  • 2,366
  • 1
  • 24
  • 27