Nagios - Configuration

In the previous chapter, we have seen the installation of Nagios. In this chapter, let us understand its configuration in detail.

The configuration files of Nagios are located in /usr/local/nagios/etc. These files are shown in the screenshot given below −

Nagios configuration

Let us understand the importance of each file now −


This is the main configuration file of Nagios core. This file contains the location of log file of Nagios, hosts and services state update interval, lock file and status.dat file. Nagios users and groups on which the instances are running are defined in this file. It has path of all the individual object config files like commands, contacts, templates etc.


By default, the CGI configuration file of Nagios is named cgi.cfg. It tells the CGIs where to find the main configuration file. The CGIs will read the main and host config files for any other data they might need. It contains all the user and group information and their rights and permissions. It also has the path for all frontend files of Nagios.


You can define $USERx$ macros in this file, which can in turn be used in command definitions in your host config file(s). $USERx$ macros are useful for storing sensitive information such as usernames, passwords, etc.

They are also handy for specifying the path to plugins and event handlers - if you decide to move the plugins or event handlers to a different directory in the future, you can just update one or two $USERx$ macros, instead of modifying a lot of command definitions. Resource files may also be used to store configuration directives for external data sources like MySQL.


external data sources

The configuration files inside objects directory have are used to define commands, contacts, hosts, services etc.


This config file provides you with some example command definitions that you can refer in host, service, and contact definitions. These commands are used to check and monitor hosts and services. You can run these commands locally on a Linux console where you will also get the output of the command you run.


define command {
   command_name check_local_disk
   command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$

define command {
   command_name check_local_load
   command_line $USER1$/check_load -w $ARG1$ -c $ARG2$

define command {
   command_name check_local_procs
   command_line $USER1$/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$


This file contains contacts and groups information of Nagios. By default, one contact is already present Nagios admin.


define contact {
   contact_name nagiosadmin
   use generic-contact
   alias Nagios Admin

define contactgroup {
   contactgroup_name admins
   alias Nagios Administrators
   members nagiosadmin


This config file provides you with some example object definition templates that are referred by other host, service, contact, etc. definitions in other config files.


This config file provides you with some example timeperiod definitions that you can refer in host, service, contact, and dependency definitions.