This is the fourth tip in a series on the open source network monitoring tool Nagios.
In a basic Nagios setup
Default configuration for setting up Nagios notifications
Before learning how to set up these configurations, let's first take a look at the default configuration, which has one contact and one contact group specified in /etc/nagios/objects/contacts.cfg. It appears as follows:
alias Nagios Administration
alias Nagios Administrators
In the default configuration’s current definition, alerting will hardly ever work. To send mail messages to a mailbox, the user must be the owner of the mailbox, and must open it regularly to act upon incoming messages. Much time may pass from when the mail message is sent and when the user acts upon it.
Setting up different time periods for Nagios notifications
By default, all alerts are sent around the clock. You may set up different time periods by creating multiple solutions. You should start from the /etc/nagios/objects/timeperiods file, where time periods are defined. For example, you can add a time period for the evening hours by adding the following text to the file:
alias do not disturb
Using these time periods, you can now set up different user accounts for different time periods and specify different actions to occur for off-hour events. This makes sure that alerts sent in the middle of the night are sent to the right person.
If you have set up multiple user accounts by defining multiple contacts in the contacts.cfg files, and multiple time periods as described in the examples above, you can now configure any host or service to send alerts to a specific person. You could, therefore, create different host definitions with different actions, and notifications would be sent to different people, depending on the time of day. For example, the following text would allow you to run the check-host-alive command only once every 60 minutes at night, and apart from this configuration, you could create an alternative that would do the same every 15 minutes during the day:
This configuration, along with your normal configuration, will allow for night time-specific host monitoring parameters.
Now you’ve learned how to use multiple Nagios contacts and time period definitions to set up customized monitoring. Using these techniques allows you to make sure that the right person receives the right Nagios notifications at the right time of the day. In a later article in this series, you'll learn how to send alerts that are defined as Nagios contacts directly to users’ desktops.
This was first published in January 2011