Icingaweb2 meets timeperiod

api
icingaweb2
timeperiod
#1

Hello,

my aim is to check a host only during the office hours.

At first a created a timeperiod at the IcingaDirector. Then I added the new host to the Icinga Director.

After that I modifed the host configuration, with an api call to set check_period.
curl -s -k -X "POST" "https://localhost:5665/v1/objects/hosts/COOKIE-HOST.example.com" -H "Accept: application/json" -H "Content-Type: application/json charset=utf-8" -u root:COOKIEPASSWORD -d '{ "attrs":{ "check_period":"OfficeTime"}}'

The Icinga2 Director have a problem (and me too:grin:) to accept the timeperiod configuration and check the host and all the services outside the office hours and send notification as well.

There’re not much information about timeperiod in connection with icingaweb2.

Have this something to do with this PR?

Many thanks in advance!

(Aflatto) #2

Hello

Can you share the output of the Object definition ?

icinga2 Object list --type Host --name COOKIE-HOST.example.com

That will allow us to see what the definition of the host is and if the time period was associated

#3
  % declared in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/example.com/hosts.conf', lines 130:1-130:39
  * __name = "COOKIE-HOST.example.com"
  * action_url = ""
  * address = "10.1.33.7"
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/example.com/hosts.conf', lines 134:5-134:29
  * address6 = ""
  * check_command = "hostalive"
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/director-global/host_templates.conf', lines 72:5-72:31
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/example.com/host_templates.conf', lines 4:5-4:31
  * check_interval = 30
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/director-global/host_templates.conf', lines 74:5-74:24
  * check_period = ""
  * check_timeout = 10
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/director-global/host_templates.conf', lines 76:5-76:23
  * command_endpoint = ""
  * display_name = "COOKIE-HOST"
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/example.com/hosts.conf', lines 133:5-133:35
  * enable_active_checks = true
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/director-global/host_templates.conf', lines 78:5-78:31
  * enable_event_handler = true
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/director-global/host_templates.conf', lines 80:5-80:31
  * enable_flapping = false
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/director-global/host_templates.conf', lines 81:5-81:27
  * enable_notifications = true
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/director-global/host_templates.conf', lines 77:5-77:31
  * enable_passive_checks = true
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/director-global/host_templates.conf', lines 79:5-79:32
  * enable_perfdata = true
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/director-global/host_templates.conf', lines 82:5-82:26
  * event_command = ""
  * flapping_threshold = 0
  * flapping_threshold_high = 30
  * flapping_threshold_low = 25
  * groups = [ "Cookies" ]
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/example.com/hosts.conf', lines 136:5-136:29
  * icon_image = ""
  * icon_image_alt = ""
  * max_check_attempts = 6
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/director-global/host_templates.conf', lines 73:5-73:28
  * name = "COOKIE-HOST.example.com"
  * notes = "total important"
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/example.com/hosts.conf', lines 135:5-135:38
  * notes_url = ""
  * package = "director"
  * retry_interval = 30
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/director-global/host_templates.conf', lines 75:5-75:24
  * source_location
    * first_column = 1
    * first_line = 130
    * last_column = 39
    * last_line = 130
    * path = "/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/example.com/hosts.conf"
  * templates = [ "COOKIE-HOST.example.com", "Satellit Children - example.com", "Satellit Children (with agent)" ]
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/example.com/hosts.conf', lines 130:1-130:39
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/example.com/host_templates.conf', lines 1:0-1:49
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/director-global/host_templates.conf', lines 71:1-71:60
  * type = "Host"
  * vars
    * Icinga2_Agent = true
      % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/director-global/host_templates.conf', lines 84:5-84:29
      % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/example.com/host_templates.conf', lines 5:5-5:29
    * Linux_Distribution = "Ubuntu"
      % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/director-global/host_templates.conf', lines 85:5-85:38
      % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/example.com/host_templates.conf', lines 6:5-6:38
    * Operating_System = "Linux"
      % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/director-global/host_templates.conf', lines 86:5-86:35
      % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/example.com/host_templates.conf', lines 7:5-7:35
    * SSH = true
      % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/director-global/host_templates.conf', lines 87:5-87:19
      % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/example.com/host_templates.conf', lines 8:5-8:19
  * volatile = false
    % = modified in '/var/lib/icinga2/api/packages/director/42-long-ID-String-3rdf-23da/zones.d/director-global/host_templates.conf', lines 83:5-83:20
  * zone = "example.com"
#4

I solved the problem by another way.
I set a ScheduledDowntime. The downtime blocked the notifications, but you can see it at the icinga dashboard.:eyes::roll_eyes:

(Aflatto) #5

if you look at the output, you can see that the timeperiod is not defined for the host, so the API call was not successful as you thought.