Multiple timeperiods/retry intervals for a host/service?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
gestabrooks
Posts: 1
Joined: Wed Jul 27, 2016 1:30 pm

Multiple timeperiods/retry intervals for a host/service?

Post by gestabrooks »

Hi All,

I've been tasked to see if I can configure our NagiosXI instance to have a different check_interval or retry interval based on the time of day.

Essentially during business hours they want everything to be the standard 5 minute check, 1 min retry, 1 max check attempt handling of checks/notifications,
but after hours they do not want any alert sent until a service has failed for at least 15 minutes.

I can't see a simple way to accomplish this and was hoping someone out there might have tried something like this before.


Thanks for any help/suggestions :)
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Multiple timeperiods/retry intervals for a host/service?

Post by lmiltchev »

The only way I can see this being accomplished is to set up two separate checks. One could be using the "workhours" timeperiod, the other one - a custom ("off-work" hours) timeperiod. During normal business hours, you could be checking the service every 5 min. During "off-work" hours, you could be checking this service less frequently, i.e. every 15 min. Here's an example:

Code: Select all

define service {
	host_name			localhost
	service_description		Current Users - business hours
	use				local-service
	check_command			check_local_users!2!5!!!!!!
	max_check_attempts		1
	check_interval			5
	retry_interval			1
	check_period			workhours
	register			1
	}	

define service {
	host_name			localhost
	service_description		Current Users - offwork hours
	use				local-service
	check_command			check_local_users!2!5!!!!!!
	max_check_attempts		1
	check_interval			15
	retry_interval			1
	check_period			offworkhours
	register			1
	}

define timeperiod {
	timeperiod_name               		workhours
	alias                         		Normal Work Hours
	monday                        		09:00-17:00
	tuesday                       		09:00-17:00
	wednesday                     		09:00-17:00
	thursday                      		09:00-17:00
	friday                        		09:00-17:00
	}

define timeperiod {
	timeperiod_name               		offworkhours
	alias                         		Off Work Hours
	saturday                      		00:00-24:00
	monday                        		00:00-08:59,17:01-23:59
	tuesday                       		00:00-08:59,17:01-23:59
	wednesday                     		00:00-08:59,17:01-23:59
	thursday                      		00:00-08:59,17:01-23:59
	friday                        		00:00-08:59,17:01-23:59
	sunday                        		00:00-24:00
	}
Hope this helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Multiple timeperiods/retry intervals for a host/service?

Post by rkennedy »

Built in, this isn't going to be possible. The only ways to really accomplish this that I could see are going to be -
1. Two different XI servers, running the same configuration, with the different options selected.
2. Two services setup for every single one.
3. Having one 'master template' that applies to all your services, that you change each day.
Former Nagios Employee
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Multiple timeperiods/retry intervals for a host/service?

Post by gormank »

I imagine this could be done w/ a bit of scripting and the new API, but an old time and blindingly simple way would be to define a pair of host template files w/ different values.

Have cron copy one into /usr/local/nagios/etc/import/ at the right time, then run the reconfig script from the right dir. Then at the right time another similar cron job copies the other to import and reconfigures.
Do the same w/ a pair of service templates.

This should take an hour or so to set up.

The reconfig imports the values, updates the templates, and applies the changes.
Of course, you need to update all your hosts and services to use templates, but that too can be done via an import, and probably better via the API.

Examples templates

Code: Select all

define host {
       name                                     base_host
       alias                                    Template containing notification and check intervals. Used by templates
       check_command                            check_ping!3000.0,80%!5000.0,100%!!!!!!
       max_check_attempts                       4
       check_interval                           5
       retry_interval                           1
       check_period                             24x7
       event_handler_enabled                    1
       flap_detection_enabled                   1
       process_perf_data                        1
       retain_status_information                1
       retain_nonstatus_information             1
       notification_interval                    60
       notification_period                      24x7
       first_notification_delay                 15
       register                                 0

}

Code: Select all

define service {
       name                                     base_service
       service_description                      Base service sourced by others
       display_name                             Base template for most templates
       is_volatile                              0
       max_check_attempts                       4
       check_interval                           5
       retry_interval                           1
       active_checks_enabled                    1
       passive_checks_enabled                   1
       check_period                             24x7
       parallelize_check                        1
       obsess_over_service                      0
       check_freshness                          0
       event_handler_enabled                    1
       flap_detection_enabled                   1
       process_perf_data                        1
       retain_status_information                1
       retain_nonstatus_information             1
       notification_interval                    60
       first_notification_delay                 15
       notification_period                      24x7
       notification_options                     w,c,u,
       register                                 0

}
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Multiple timeperiods/retry intervals for a host/service?

Post by mcapra »

Thanks @gormank!

@gestabrooks let us know if there's further questions.
Former Nagios employee
https://www.mcapra.com/
Locked