Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to check a service 24x7, but want to check certain thresholds only during business hours. I could use check_period, but that would mean that the services aren't checked outside business hours. Alternatively I could use notification_period, but that will mean that when the notification_period starts, any alerts will be sent then, and I don't want that.

Is there any way of achieving this with Nagios 3 (actually I'm using icinga)?

share|improve this question
You want the check thresholds to be dynamic depending on time? – Khaled Dec 2 '10 at 16:48
yes, that'd be good too – damas Dec 2 '10 at 16:55
"[W]hen the notification_period starts, any alerts will be sent then, and I don't want that." That is not my understanding how Nagios works. When the notification_period starts, the next alert will be sent only after notification_interval has passed. – Mark Wagner Dec 2 '10 at 18:18
What are the "thresholds" your talking about? Do you want ` max_check_attempts` to be dynamic? Or do you want the check command return code ('OK', 'WARNING', 'CRITICAL') to vary depending on time of day? E.g., load during business hours is OK below 10, otherwise it is OK below 5. – Mark Wagner Dec 2 '10 at 18:28
@embobo: From the book "Nagios 2nd Edition": "Outside the specified time period, Nagios suppresses possible messages but does not simply discard them. It places the messages in a queue and sends them as soon as the notification period begins." – damas Dec 3 '10 at 9:16
up vote 1 down vote accepted

I can think of two ways to do this: (a) use an external command to change the check command (Nagios calls this "adaptive monitoring") or (b) split the service into two with different check commands and periods.

I'll use check_load as and example with these (skeletal) service and command definitions:

 define service{
   name          load
   host_name     foohost
   check_command check_load!1,1,1!2,2,2
   ... (all other options)

 define command{
   name         check_load
   command_line $USER1$/check_load -w $ARG1$ -c $ARG2$

For (a) suppose you wish to change these values at 8pm return them at 8am. In cron add

 0 20 * * * /some/path/change_load_check 3,3,3 4,4,4
 0  8 * * * /some/path/change_load_check 1,1,1 2,2,2

where change_load_check is


now=`date +%s`


/bin/printf "[%lu] CHANGE_SVC_CHECK_COMMAND;foohost;load;check_load!$W!$C\n" \
  $now > $commandfile

You need to have external commands enabled.

For (b) you would take the original service, turn it into a template, and create two new services that specify different periods and check commands like so:

 define service{
   name          load_template
   host_name     foohost
   ... (all other options)
   register      0

 define service{
   name                load_workhours
   use                 load_template
   check_period        workhours
   notification_period workhours
   check_command       check_load!1,1,1!2,2,2

 define service{
   name                load_offhours
   use                 load_template
   check_period        offhours
   notification_period offhours
   check_command       check_load!3,3,3!4,4,4
share|improve this answer
thorough answer, thanks – damas Dec 7 '10 at 10:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.