Include timeperiod not working?

With the holiday season approaching, I was preparing our time periods in Icinga. After all these years, I found the include/exclude option only this doesn’t seems to work like I expected.

We’ve a timeperiod object called “Officehours” and an object “OutsideOfficeHours”. Between office hours we get voice notifications on our SIP phones and outside the office hours we get voice notifications on our cellphones.

Now I created a new timeperiod object “Holidays” with the range “december 07 = 14:00-14:30”. I excluded the “holidays” object in “officehours” and include “holidays” in the “OutsideOfficeHours” object. I triggered a critical state on one of our hosts, but we didn’t get any notification.

The API shows that the exclude is working fine, because the value “is_inside” is false for officehours. But “is_inside” is also false for OutsideOfficeHours.

Can somebody explain me why this isn’t working?

Thanks!

Icinga2 version: r2.13.1-1
OS: Ubuntu Focal (20.04)

API output:

       {
            "attrs": {
                "__name": "holidays",
                "active": true,
                "display_name": "TimePeriod Holidays",
                "excludes": [],
                "ha_mode": 0,
                "includes": [],
                "is_inside": true,
                "name": "holidays",
                "original_attributes": null,
                "package": "_etc",
                "paused": true,
                "prefer_includes": true,
                "ranges": {
                    "december 24": "08:45-12:00,13:30-17:30",
                    "december 25": "08:45-12:00,13:30-17:30",
                    "december 7": "14:00-14:30",
                    "january 1": "08:45-12:00,13:30-17:30"
                },
                "segments": [
                    {
                        "begin": 1638882000,
                        "end": 1638883800
                    }
                ],
                "source_location": {
                    "first_column": 1,
                    "first_line": 10,
                    "last_column": 28,
                    "last_line": 10,
                    "path": "/etc/icinga2/conf.d/timeperiods.conf"
                },
                "templates": [
                    "holidays",
                    "legacy-timeperiod"
                ],
                "type": "TimePeriod",
                "update": {
                    "arguments": [
                        "tp",
                        "begin",
                        "end"
                    ],
                    "deprecated": false,
                    "name": "Internal#LegacyTimePeriod",
                    "side_effect_free": false,
                    "type": "Function"
                },
                "valid_begin": 1638878122.137225,
                "valid_end": 1638968348.182877,
                "vars": null,
                "version": 0,
                "zone": ""
            },
            "joins": {},
            "meta": {},
            "name": "holidays",
            "type": "TimePeriod"
        },
       {
            "attrs": {
                "__name": "outsideworkinghours",
                "active": true,
                "display_name": "TimePeriod Outside working hours",
                "excludes": [],
                "ha_mode": 0,
                "includes": [
                    "holidays"
                ],
                "is_inside": false,
                "name": "outsideworkinghours",
                "original_attributes": null,
                "package": "_etc",
                "paused": true,
                "prefer_includes": true,
                "ranges": {
                    "friday": "07:00-08:45,12:00-13:30,17:30-23:00",
                    "monday": "07:00-08:45,12:00-13:30,17:30-23:00",
                    "saturday": "07:00-23:00",
                    "sunday": "07:00-23:00",
                    "thursday": "07:00-08:45,12:00-13:30,17:30-23:00",
                    "tuesday": "07:00-08:45,12:00-13:30,17:30-23:00",
                    "wednesday": "07:00-08:45,12:00-13:30,17:30-23:00"
                },
                "segments": [
                    {
                        "begin": 1638856800,
                        "end": 1638863100
                    },
                    {
                        "begin": 1638874800,
                        "end": 1638880200
                    },
                    {
                        "begin": 1638894600,
                        "end": 1638914400
                    },
                    {
                        "begin": 1638943200,
                        "end": 1638949500
                    },
                    {
                        "begin": 1638961200,
                        "end": 1638966600
                    },
                    {
                        "begin": 1638981000,
                        "end": 1639000800
                    }
                ],
                "source_location": {
                    "first_column": 1,
                    "first_line": 35,
                    "last_column": 39,
                    "last_line": 35,
                    "path": "/etc/icinga2/conf.d/timeperiods.conf"
                },
                "templates": [
                    "outsideworkinghours",
                    "legacy-timeperiod"
                ],
                "type": "TimePeriod",
                "update": {
                    "arguments": [
                        "tp",
                        "begin",
                        "end"
                    ],
                    "deprecated": false,
                    "name": "Internal#LegacyTimePeriod",
                    "side_effect_free": false,
                    "type": "Function"
                },
                "valid_begin": 1638856800,
                "valid_end": 1639000800,
                "vars": null,
                "version": 0,
                "zone": ""
            },
            "joins": {},
            "meta": {},
            "name": "outsideworkinghours",
            "type": "TimePeriod"
        },
        {
            "attrs": {
                "__name": "officehours",
                "active": true,
                "display_name": "TimePeriod Office Hours",
                "excludes": [
                    "holidays"
                ],
                "ha_mode": 0,
                "includes": [],
                "is_inside": false,
                "name": "officehours",
                "original_attributes": null,
                "package": "_etc",
                "paused": true,
                "prefer_includes": true,
                "ranges": {
                    "friday": "08:45-12:00,13:30-17:30",
                    "monday": "08:45-12:00,13:30-17:30",
                    "thursday": "08:45-12:00,13:30-17:30",
                    "tuesday": "08:45-12:00,13:30-17:30",
                    "wednesday": "08:45-12:00,13:30-17:30"
                },
                "segments": [
                    {
                        "begin": 1638863100,
                        "end": 1638874800
                    },
                    {
                        "begin": 1638880200,
                        "end": 1638882000
                    },
                    {
                        "begin": 1638883800,
                        "end": 1638894600
                    },
                    {
                        "begin": 1638949500,
                        "end": 1638961200
                    },
                    {
                        "begin": 1638966600,
                        "end": 1638981000
                    }
                ],
                "source_location": {
                    "first_column": 1,
                    "first_line": 20,
                    "last_column": 31,
                    "last_line": 20,
                    "path": "/etc/icinga2/conf.d/timeperiods.conf"
                },
                "templates": [
                    "officehours",
                    "legacy-timeperiod"
                ],
                "type": "TimePeriod",
                "update": {
                    "arguments": [
                        "tp",
                        "begin",
                        "end"
                    ],
                    "deprecated": false,
                    "name": "Internal#LegacyTimePeriod",
                    "side_effect_free": false,
                    "type": "Function"
                },
                "valid_begin": 1638863100,
                "valid_end": 1638981000,
                "vars": null,
                "version": 0,
                "zone": ""
            },
            "joins": {},
            "meta": {},
            "name": "officehours",
            "type": "TimePeriod"
        },

timeperiods.conf:

object TimePeriod "holidays" {
  display_name = "TimePeriod Holidays"
  ranges = {
    "january 1"     = "08:45-12:00,13:30-17:30"
    "december 24"   = "08:45-12:00,13:30-17:30"
    "december 25"   = "08:45-12:00,13:30-17:30"
  }
}

object TimePeriod "officehours" {
  excludes = [ "holidays" ]
  display_name = "TimePeriod Office Hours"
  ranges = {
    "monday"    = "08:45-12:00,13:30-17:30"
    "tuesday"   = "08:45-12:00,13:30-17:30"
    "wednesday" = "08:45-12:00,13:30-17:30"
    "thursday"  = "08:45-12:00,13:30-17:30"
    "friday"    = "08:45-12:00,13:30-17:30"
  }
}

object TimePeriod "outsideworkinghours" {
  includes = [ "holidays" ]
  display_name = "TimePeriod Outside working hours"
  ranges = {
    "monday"    = "07:00-08:45,12:00-13:30,17:30-23:00"
    "tuesday"   = "07:00-08:45,12:00-13:30,17:30-23:00"
    "wednesday" = "07:00-08:45,12:00-13:30,17:30-23:00"
    "thursday"  = "07:00-08:45,12:00-13:30,17:30-23:00"
    "friday"    = "07:00-08:45,12:00-13:30,17:30-23:00"
    "saturday"  = "07:00-23:00"
    "sunday"    = "07:00-23:00"
  }
}

As a rule it seems to be important for notification rules to not overlap in terms of time periods, during which they are active; if rules address the same hosts/services, contacts, time periods it’s our experience (Icinga 2.10) that “last one applied wins”!

You seem to have paid attention to that, so…

What also helps with understanding why notifications aren’t triggering is to temporarily (!) switch on the “debuglog” feature, and then locate the exact moment a test notification was or should have been triggered. Usually the descriptions in the log are helpful.

Of course, you should also pay attention to all warnings you get on deployment (or when you “switch in” your configuration). These warnings often indicate potential problem areas, where APPLY’s didn’t quite “reach” your objects… :wink: