Nagios Core Configuration - nagios.cfg, cgi.cfg, resource.cfg

In the case that you have followed steps mentioned at installation of the Nagios Core document at this web page it is located at:
“/opt/nagios-<VERSION>/etc/nagios.cfg”
“/opt/nagios-<VERSION>/etc/cgi.cfg”
“/opt/nagios-<VERSION>/etc/resource.cfg”

Preface

Nagios Core is using several configuration files that have direct or indirect definition of the relation to each other.

In this document I would like to describe the functionality of the main configuration files used at Nagios Core. On another hand I think that it is pointless to copy the whole official documentation from Nagios project in to tis document. According to this I will try to find the balance between information that can help to understand how it is working and pointing to official documentation.

The main configuration file of Nagios Core is called “nagios.cfg”. In the case that you have followed steps mentioned at installation of the Nagios Core document at this web page it is located at “/opt/nagios-<VERSION>/etc/nagios.cfg” .

Mentioned configuration file will be used at start of Nagios Core demon. It is including the configuration of Nagios Core, as well it is possible to define additional files that can provide particular configuration used at Nagios Core.

According to this it is common to split the configuration across several files. It is possible to create file system hierarchy that will provide the possibility to logical grouping of the configuration objects.

In the case that you are going to do any configuration change.

Please:
- Backup the file before you will change it. In case that you will need to do roleback it really hand.
- After you has done the change validate the configuration integrity with:

cfg_dir (split the configuration)

In the case that you are looking for way how to logical order the configuration across the file system without defining each configuration file. This is one of the main parameter that can help you.

With help of “cfg_dir”used at “nagios.cfg”config file, it is possible to configure multiple folders where it is possible to store configuration of Nagios Core. This will prevent the need to define each configuration file with “cfg_file” parameter.

All configuration files need to have

name in“*.cfg”format. It mean that Nagios Core will take in to account only files that are using suffix “.cfg”, located at the defined directory.

In the case that you would like to build a hierarchical structure like:

It is possible to build this hierarchy direct at file system like directory structure. In this case it will be enough to configure “cfg_dir” variable with the path to the top of the file system hierarchy “Customer”. In case like this Nagios Core will take recursively all included folders and directories to look for files with suffix “.cfg” to include then in to Nagios Core configuration.

date_format

Nagios Core is using as default the US format of the time. In some cases it is too confusing for the peoples that are using this tool. According to this it is sometime better to change it to another format.

User/Group

In UX world each process has his owner and owner group. Based on this it is possible to restrict access rights to some resources at OS level.

Nagios Core is using as well definition of User and Group that will be used for running Nagios Core demon. According to this all files and directories that need to be accessible for Nagios Core demon need to belong to the right user and group.

enable_notifications

In the case that you are building a failover Nagios Core infrastructure. It is handy to know that it is possible to enable/disable to send any notification out of Nagios Core with one parameter at “nagios.cfg” file.

In the case that you can not reload the configuration from config files. It is possible to use as well “nagios.cmd”for updating the configuration on flay. Any way this is not topic of this document. I will describe it at different document.

Passive Monitoring

In case that you are going to integrate Nagios Core with another tools. That are able to send unsolicited messages to Nagios Core to change the status of monitored object. It is required to enable this at “nagios.cfg” configuration file.

To enable passive monitoring it is required to configure this parameters:

This is one of the main reason that Nagios Core is used at so many monitoring tools. As it is too easy to do integration of Nagios Core.

This is the reason that you do not really need any agent on monitored device, as in the case that you have SSH access to Nagios Core monitoring server you can forward all interesting messaged directly to the Nagios Core from monitored server.

Any way this is not topic of this document, as well it is not really common to use it in this way.

Event Broker

Nagios Core is able to integrate additional components. In this way it is possible to integrate Nagios Core with several different tools. One of the integration way is to use Nagios Core Event Broker (called as well NEB).

In this way the Nagios Core will share operational status with another application. In this way it is possible to integrate for example MySQL backend for Nagios Core.

In the “cgi.cfg” configuration file it is possible to configure parameters related to Nagios Core Web GUIand CGI scripts. In most case you will not really need to change it. On another hand in the case that you would like to play with your Nagios Core web interface here are the configuration parameters.

In the case that you have followed steps mentioned at installation of the Nagios Core document at this web page it is located at “/opt/nagios-<VERSION>/etc/cgi.cfg”.

use_authentication

Ignore Contact configuration

At each Host or Service related configuration it is possible to specify who can see the status of the particular object.

In case that you are using one administrator account that need to see all configured objects it is possible to enable it at this please to see all objects of Nagios Core (even it was not declared as a contact for particular object).

refresh_rate

This option allows you to specify the refresh rate in seconds of various CGIs (status, statusmap, extinfo, and outages).

Example:

# grep refresh_rate cgi.cfg
refresh_rate=90

result_limit

This option allows you to specify the default number of results displayed on the status.cgi. This number can be adjusted from within the UI after the initial page load. Setting this to 0 will show all results.

Example:

# grep result_limit cgi.cfg
result_limit=100

resource.cfg

The “resource.cfg” configuration file is including all paths (on file system) that are used at Nagios Core. It is possible to define 32 different paths.

In the case that you have followed steps mentioned at installation of the Nagios Core document at this web page it is located at “/opt/nagios-<VERSION>/etc/resource.cfg”.