icinga2 icon indicating copy to clipboard operation
icinga2 copied to clipboard

Re-notification of OK does not work

Open K0nne opened this issue 1 year ago • 3 comments

Describe the bug

I need to re-send OK states. I looked into the docs and found the notification attribute interval. It works great for every non-OK state, but not for OK itself.

To Reproduce

Configure a notification with "interval" != 0 for every state and observe that it does not work for OK. The docs state no limitation to non-OK states.

Expected behavior

interval should worl for all states.

Screenshots

image

Your Environment

icinga2 2.13.9

Additional context

note:
interval = 30s is only for testing

template Notification "company-service-notification" {
  command = "company-notification"

  interval = 0
  states = [ OK, Warning, Critical, Unknown ]
  types = [ Problem, Recovery, Custom, FlappingStart, FlappingEnd ]

  period = "24x7"

}
apply Notification "company-broker-service" to Service {
  import "company-service-notification"

  user_groups = host.vars.notification.company.groups
  users = host.vars.notification.company.users

  interval = 30s

  vars.service_id = {{

        var service_id = ""

        if (macro("$service.vars.ServiceID$") == "") {
               service_id = 0 # wenn keine service id gesetzt ist
        } else {
               service_id = macro("$service.vars.ServiceID$")
        }

        return service_id

  }}

  vars.notification_ci = "$host.name$"
  vars.notification_key= {{ return "3rd_Icinga2_QS_service_" + macro("$service.name$") + "_" + macro("$host.name$") + "_" + macro("$host.vars.tags$").replace(", ", "_") }}
  vars.notification_text="Notificationtype: $notification.type$ Host: $host.name$ Servicestate: $service.state$ ServiceID: $notification.vars.service_id$ Info: $service.output$ - Date/Time: $icinga.long_date_time$ URL: https://fqdn/icingaweb2/monitoring/host/show?host=$host.name$"

  assign where service.vars.notification.companyServicebroker
  ignore where service.vars.enable_notifications == false
}

K0nne avatar Feb 02 '24 12:02 K0nne

The purpose of the interval attribute is to repeat problem notifications. It also doesn't repeat notifications for the other types given in your config snippet (Custom, FlappingStart, FlappingEnd) either.

I need to re-send OK states.

I really wonder what the use case for this would be. Wouldn't that just indefinitely send notifications if everything is fine?

julianbrost avatar Feb 05 '24 15:02 julianbrost

The purpose of the interval attribute is to repeat problem notifications. It also doesn't repeat notifications for the other types given in your config snippet (Custom, FlappingStart, FlappingEnd) either.

I need to re-send OK states.

I really wonder what the use case for this would be. Wouldn't that just indefinitely send notifications if everything is fine?

Exactly. My use case is to send a fequent 'heartbeat' to an external system every n minutes, reasonable set by 'interval'.

K0nne avatar Feb 05 '24 18:02 K0nne

Quick and ugly hack would be to clone the existing check and invert the result with https://icinga.com/docs/icinga-2/latest/doc/10-icinga-template-library/#negate together with a notification that again negates the message back to OK.

slalomsk8er avatar Feb 06 '24 08:02 slalomsk8er