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
#!/bin/sh
now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'
W=$1
C=$2
/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
}