Setup Nagios Monitoring – The Easy Way Part 3

In the first two parts of this guide we’ve installed Nagios 3 onto an Ubuntu server. We’ve restructured the layout of the configuration files so that they are more manageable. In this step we will look at time periods and how to configure them.

Time periods are used just that, a schedule that defines when things should or should not happen. Typical time periods defined in Nagios include:

  • 24x7 – All the time, from 00:00 to 23:59 Monday to Sunday.
  • Work Hours – 09:00 to 17:00 Monday to Friday.
  • After Hours – All the time outside of the work hours.
  • Never – Empty schedule with no times defined.

These time periods are used in a few places. Firstly they can be used to determine when host and service checks occur. For example we may want critical production servers to be monitored 24x7 but only want non critical servers monitored during business hours.

The second major place they are used is to determine when contacts should be alerted that problems have occurred. For example we may send alerts to an administrators email group during business hours but send an alert via SMS after work hours.

In the /etc/nagios3/timeperiods folder we’ll create four different time periods:

  • /etc/nagios3/timeperiods/24x7.cfg
  • /etc/nagios3/timeperiods/never.cfg
  • /etc/nagios3/timeperiods/afterhours.cfg
  • /etc/nagios3/timeperiods/workhours.cfg

First we’ll start by defining the 24x7 time period. Create the file /etc/nagios3/timeperiods/24x7.cfg as shown below:

# This defines a timeperiod where all times are valid for checks,
# notifications, etc. The classic "24x7" support nightmare. :-)

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

Next we’ll create the never time period as shown below:

# Here is a slightly friendlier period during work hours
define timeperiod{
timeperiod_name never
alias Never



Now we’ll create the afterhours definition:

# The complement of workhours
define timeperiod{
timeperiod_name nonworkhours
alias Non-Work Hours
sunday 00:00-24:00
monday 00:00-09:00,17:00-24:00
tuesday 00:00-09:00,17:00-24:00
wednesday 00:00-09:00,17:00-24:00
thursday 00:00-09:00,17:00-24:00
friday 00:00-09:00,17:00-24:00
saturday 00:00-24:00

And finally we’ll create the workhours definition:

# Here is a slightly friendlier period during work hours
define timeperiod{
timeperiod_name workhours
alias Standard 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


These four time period definitions should cover most smaller IT shops. If you need another time period definition it’s as simple as creating a new text file in the /etc/nagios3/timeperiods folder and define the time periods accordingly.

So we’ve finished defining the time periods, in the next blog post we’ll look at defining contacts in Nagios which will make use of the time periods we’ve defined here.





Popular posts from this blog

Monitoring Raspberry Pi Performance Using Cacti

Using NAGIOS to Check the Physical Memory Available on a Windows Host

Error 2738 Occurs When Installing An MSI Package