Hi,
We’ve witnessed an unexpected behavior for some notifications that should be sent during a timeperiod constructed with “includes”.
Basically, the included timeperiods and the “prefer_includes” attribute don’t seem to have any effect. The included timeperiods don’t override (or complement) what’s in the main timeperiod.
icinga2 --version
expand
icinga2 - The Icinga 2 network monitoring daemon (version: r2.11.2-1)
Copyright (c) 2012-2020 Icinga GmbH (https://icinga.com/)
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl2.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
System information:
Platform: Debian GNU/Linux
Platform version: 9 (stretch)
Kernel: Linux
Kernel version: 4.9.0-11-amd64
Architecture: x86_64
Build information:
Compiler: GNU 6.3.0
Build host: runner-LTrJQZ9N-project-298-concurrent-0
Application information:
General paths:
Config directory: /etc/icinga2
Data directory: /var/lib/icinga2
Log directory: /var/log/icinga2
Cache directory: /var/cache/icinga2
Spool directory: /var/spool/icinga2
Run directory: /run/icinga2
Old paths (deprecated):
Installation root: /usr
Sysconf directory: /etc
Run directory (base): /run
Local state directory: /var
Internal paths:
Package data directory: /usr/share/icinga2
State path: /var/lib/icinga2/icinga2.state
Modified attributes path: /var/lib/icinga2/modified-attributes.conf
Objects path: /var/cache/icinga2/icinga2.debug
Vars path: /var/cache/icinga2/icinga2.vars
PID path: /run/icinga2/icinga2.pid
Config example
expand
object HostGroup "critical" {
}
object Host "crit_vm" {
import "generic-host"
groups = [ "critical" ]
address = "123.123.123.123"
}
object UserGroup "on_call_guys" {
}
object User "the_warrior" {
import "generic-user"
groups = [ "on_call_guys" ]
types = [ Problem ] // problems only
enable_notifications = true
}
object TimePeriod "on_call_period" {
includes = [ vacations" ]
prefer_includes = true
ranges = {
"monday" = "00:00-8:00,21:00-24:00"
"tuesday" = "00:00-8:00,21:00-24:00"
"wednesday" = "00:00-8:00,21:00-24:00"
"thursday" = "00:00-8:00,21:00-24:00"
"friday" = "00:00-8:00,21:00-24:00"
"saturday" = "00:00-24:00"
"sunday" = "00:00-24:00"
}
}
object TimePeriod "vacations" {
ranges = {
"july 30" = "00:00-24:00"
"july 31" = "00:00-24:00"
"august 3" = "00:00-24:00"
"august 4" = "00:00-24:00"
"august 5" = "00:00-24:00"
"august 6" = "00:00-24:00"
"august 7" = "00:00-24:00"
}
}
apply Notification "on_call_notification" to Host {
command = "notification-sms"
user_groups = [ "on_call_guys" ]
interval = 0 // no re-notification
period = "on_call_period"
types = [ Problem ] // problems only
states = [ Down ] // down only
assign where "critical" in host.groups
}
What happened
On July 30 (which was a thursday), we made a test. At 17:00 we shut down a critical host.
The main timeperiod stipulates that on thursday, notification should not be sent before 21:00.
On the other hand, the included timeperiod stipulates that on July 30, the notification should always be sent, regardless of the time.
The result of the test is that no notification was sent.
We tried adding the “july 30” directly in the ranges of the main timeperiod, nothing changed.
The notification was sent only when commenting out the “thursday” range and placing “july 30” directly in the ranges.
The question
Was the configuration correct in the first place ?
If yes, then I guess there’s some kind of bug.
If not, then how can we achieve what we’re trying to do ? eg: send notifications only outside of working hours, with the possibility to send notifications regardless of the hour on certain dates.
Cheers
(Incidentally, I’m on vacation starting today, I’ll be back in a week, so don’t feel insulted if I don’t answer in the meantime. Also, note that we did our test in a rush, so we may have missed something. I’ll do more test when I come back.)