USE directive not supported in timeperiod definition?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
mrtexasfreedom
Posts: 19
Joined: Tue Apr 12, 2011 6:31 pm

USE directive not supported in timeperiod definition?

Post by mrtexasfreedom »

I'm trying to follow the guide for setting up on-call rotations. It provides great sample timeperiod definitions. In our installation of Nagios Core 3.2.3, whenever I attempt to create a timeperiod definition with 'USE', I get a config file error on the nagios restart.

The on-call rotation timeperiod example:

Code: Select all

define timeperiod{

	timeperiod_name		john-oncall

	use			weekdays	; Include weekdays

	exclude			holidays	; Exclude holiday dates/times defined elsewhere

	}
If I copy-and-paste the above text into my timeperiods.cfg file and attempt to restart nagios (service nagios restart), I get the standard config error:

Code: Select all

Running configuration check... CONFIG ERROR!  Restart aborted.  Check your Nagios configuration.
In my file, I changed out 'weekdays' for '24x7' so the above definition would be referring to another existing timeperiod defined earlier in the file.

The object definition docs don't include 'USE' in the timeperiod definition:

Code: Select all

define timeperiod{
timeperiod_name	timeperiod_name
alias	alias
[weekday]	timeranges
[exception]	timeranges
exclude	[timeperiod1,timeperiod2,...,timeperiodn]
   	}

My question is, has 'USE' been depricated in the timeperiod definitions?

-- mtf
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: USE directive not supported in timeperiod definition?

Post by mguthrie »

If "use" has been deprecated for timeperiods, it would be news to be as well.

Can you post the full output from the verification command, along with the full config that is causing the error?
mrtexasfreedom
Posts: 19
Joined: Tue Apr 12, 2011 6:31 pm

Re: USE directive not supported in timeperiod definition?

Post by mrtexasfreedom »

You helped me out immensely. I was completely unaware of the 'verification' command and hadn't been seeing the error messages that specified what part of my config files were botched. Using the verification command helped me pinpoint the problem here. For the benefit of future visitors to this thread, I'll clarify the problem and solution.


Within timeperiods.cfg, there are example definitions. Not all of them use the same fields in their format. For example, 24x7 is missing the 'name' field:

Code: Select all

define timeperiod{
        timeperiod_name 24x7
        alias           24 Hours A Day, 7 Days A Week
        sunday          00:00-24:00
        monday          00:00-24:00
        tuesday         00:00-24:00
        wednesday       00:00-24:00
        thursday        00:00-24:00
        friday          00:00-24:00
        saturday        00:00-24:00
        }
While workhours has the name field:

Code: Select all

define timeperiod{
        name            workhours
        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
        }
Two problems I was running into here:

1. You cannot reference multiple time periods within a contact
as in:

Code: Select all

        host_notification_period        workhours,24x7
        service_notification_period     workhours,24x7
You have to create a custom time period that combines the multiple time periods, then reference that in your contact definition.

From timeperiods.cfg:

Code: Select all

define timeperiod{
        name            scott_oncall
        timeperiod_name scott_oncall
        alias           Scott on call
        use workhours,my_monday,second_weekend
        }
From contacts.cfg:

Code: Select all

define contact{
        contact_name                    Scott
        use                             generic-contact
        alias                           Scott Edwards
        email                           sedwards@company.com
        service_notification_options    c,r
        host_notification_period        scott_oncall
        service_notification_period     scott_oncall
        }

2. When referencing a defined time period in contacts.cfg file or timeperiods.cfg, you have to use the 'name' value. The 'timeperiod_name' cannot be used. If the 'name' isn't present in the definition, as is the case with 24x7, you have to add it.

Finally, here's the verification syntax I used on our Fedora Nagios install:

Code: Select all

/usr/local/nagios/bin/nagios -v /etc/nagios/nagios.cfg
Thanks a lot!

mtf
Locked