icinga2
icinga2 copied to clipboard
Re-notification of OK does not work
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
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
}
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?
The purpose of the
intervalattribute 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'.
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.