nagiosnagiosxi

Nagios: how to apply manual changes in services cfg files


I am using NagiosXI 5. I have changed the content of "check_command" in /usr/local/nagios/etc/services/myconfig.cfg. However, this change is not visible in Nagios. I have tried "Apply Configuration" and even restart service nagios on the computer with no success.

EDIT: Oh, I have missed the following note in the beginning of this file. However, I still do not understand what I have to do after preparing the edited version of a (large) cfg file.

--- DO NOT EDIT THIS FILE BY HAND --- 
Nagios CCM will overwrite all manual settings during the next update if you 
would like to edit files manually, place them in the 'static' directory or 
import your configs into the CCM by placing them in the 'import' directory.

Solution

  • In the recent version of Nagios XI (5.8.4) I create/copy new *.cfg file and put it into /usr/local/nagios/etc/import. The click on "Apply Configuration". The file will be moved from /usr/local/nagios/etc/import to /usr/local/nagios/etc/services. The name of the file will not be changed so overwriting the existing configuration files is prevented. The content of the file (new services) will be imported into the internal database. If you make any mistake in the cfg file, the existing configuration will not be changed (the revert mechanism will be used) but your cfg file will be removed from /usr/local/nagios/etc/import. Just have a spare copy somewhere.

    There is no problem if a service with the same name exists in some other cfg file. The existing one will not be changed. You will end with both services active, they will have different "Config Name" parameter.

    If you want to change properties of the existing services (those defined in /usr/local/nagios/etc/services/*.cfg) then copy the corresponding cfg file to import folder, change the content, and do "Apply Configuration". For me, this operation does not change history of the manipulated service.

    I still have to find out how to remove user-defined services (those defined in /usr/local/nagios/etc/services/*.cfg) without GUI.

    All these are completely undocumented features, and the official answer from Nagios is that the user should not touch any cfg files by itself. How on the earth they expect that someone will create and/or adapt 1000+ services by clicking GUI when, for example, he needs to duplicate the system on the second server?