Page 1 of 3

Using time periods with services checks

Posted: Thu Nov 29, 2012 4:59 am
by Frédéric GRANAT
Hi,
Here are the characteristics of my nagiosxio environement :
Linux version 2.6.18-308.13.1.el5 ([email protected]) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-52))
/usr/bin/file: ELF 32-bit LSB executable, Intel 80386
Manual install of NagiosXI

I want to check backupexec jobs and I use check_be.exe (for further informations see http://exchange.nagios.org/directory/Pl ... ck/details)
for example, my job is planned each first monday of the month, so I want to check it each tuesday following that day.
I created a Time Period having these characteristics

define timeperiod {
timeperiod_name mercredi_suivant_premier_mardi
alias Mercredi suivant le premier Mardi du mois
wednesday 00:00-24:00
use periode_mardi1_mardi2
}


define timeperiod {
timeperiod_name periode_mardi1_mardi2
alias jour compris entre le 1er Mardi du mois et le second
name periode_mardi1_mardi2
tuesday 1 - tuesday 2 00:00-24:00
}

I created a service template :

define service {
name sauvegardes_premier_mardi
service_description Supervise les sauvegardes du premier Mardi du mois
display_name sauvegardes_premier_mardi
servicegroups Sauvegardes
use generic_sauvegardes
check_period mercredi_suivant_premier_mardi
notifications_enabled 0
register 0

}

define service {
name generic_sauvegardes
is_volatile 0
max_check_attempts 3
check_interval 5
retry_interval 1
active_checks_enabled 1
passive_checks_enabled 1
obsess_over_service 1
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
notification_period 24x7
notifications_enabled 1
contact_groups all
failure_prediction_enabled 1
register 0
}

At the end I created a service using the template sauvegardes_premier_lundi

define service {
host_name W2K8-SRVBACKUP.cg.ahp
service_description BackupExec [EXPORT]-System State Check
use sauvegardes_premier_mardi
check_command check_nrpe!check_export_system_state
register 1
}

I apply that service on nagiosxi, the check appears but it says that "Service check is pending... Check is scheduled for 2012-12-04 00:00:00"
Whereas it shoud be planned on 2012-12-05 (the wednesday following the first tuesday).
Do you have any explanation ?

Regards,

Frederic

Re: Using time periods with services checks

Posted: Thu Nov 29, 2012 7:52 am
by scottwilkerson
In the timeperiod mercredi_suivant_premier_mardi you have a line

Code: Select all

use periode_mardi1_mardi2
This is going to include the times in periode_mardi1_mardi2 which is tuesday

Re: Using time periods with services checks

Posted: Thu Nov 29, 2012 8:44 am
by Frédéric GRANAT
Hi,

But I also precised in my Time period definition :
wednesday 00:00-24:00

So that should be on wednesday and between tuesday 1 and tuesday 2, isn't it ?

Rgds,

Frederic

Re: Using time periods with services checks

Posted: Thu Nov 29, 2012 10:15 am
by scottwilkerson
no, it would add both of them (even though they overlap)

Re: Using time periods with services checks

Posted: Thu Nov 29, 2012 10:24 am
by Frédéric GRANAT
Perfect,
So how could I define a Time Period on wednesday following the first tuesday of the month ?

Rgds,

Frederic

Re: Using time periods with services checks

Posted: Thu Nov 29, 2012 1:06 pm
by scottwilkerson

Code: Select all

define timeperiod {
timeperiod_name mercredi_suivant_premier_mardi
alias Mercredi suivant le premier Mardi du mois
tuesday 1 - wednesday  1 00:00-24:00
exclude mardi
}

define timeperiod {
timeperiod_name mardi
alias mardi
tuesday 00:00-24:00
}

Re: Using time periods with services checks

Posted: Fri Nov 30, 2012 3:26 am
by Frédéric GRANAT
Does it work when the first wednesday of the month is before the first tuesday of the month ?

Rgds,

Frederic

Re: Using time periods with services checks

Posted: Fri Nov 30, 2012 8:08 am
by scottwilkerson
It should because this

Code: Select all

tuesday 1 - wednesday  1 00:00-24:00
means from the first Tuesday until the first Wednesday

Then we exclude Tuesday

Re: Using time periods with services checks

Posted: Fri Nov 30, 2012 8:28 am
by Frédéric GRANAT
If wednesday 1 is after tuesday 1, the lenght of the period is 2 days, if you exclude tuesday, the period is the wednesday following the first tuesday : that's correct for me.
If wednesday 1 is before tuesday 1, the lenght of the periode is 7 days, if you exclude tuesday, the checks will occur during 6 days : that doesn't match with my need.

If your method doesn't work in that particular case, don't you have another way to solve the problem ?

Rgds,

Frederic

Re: Using time periods with services checks

Posted: Fri Nov 30, 2012 9:37 am
by scottwilkerson
The method I posted should be correct.

The other scenerio you posted would be

Code: Select all

wednesday  1 - tuesday 1 00:00-24:00
If if fact you find it doesn't work, I do have another option and it would look like this

Code: Select all

define timeperiod {
timeperiod_name mercredi_suivant_premier_mardi
alias Mercredi suivant le premier Mardi du mois
day 2 - 8 00:00-24:00
exclude everything_but_mardi
}

define timeperiod {
timeperiod_name everything_but_mardi
alias everything_but_mardi
monday 00:00-24:00
tuesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
sunday 00:00-24:00
}