Page 1 of 1

Service configuration files

Posted: Wed Jun 10, 2015 4:24 pm
by xlin125
When adding a service on the Nagios Web Interface, a serviec configuration file is created in
/usr/local/nagios/etc/services directory. A comment in this file warns "DO NOT EDIT THIS FILE BY HAND" and says that "Nagios CCM will overwrite all manual settings during the next update if you would like to edit files manually". My questions are:
1) when adding a service on the Nagios Web GUI, besides a service configuration file is created in
/usr/local/nagios/etc/services directory, is this service configuration information also stored in the mySQL database or PostgreSQL database?
2) Where does Nagios CCM get the "original" (service) configuration settings to overwrite all the manual setting changes?
3) What causes Nagios CCM to run and overwrite all the manual setting changes? When I click "Save Configuration" or by some kind of mechanism within Nagios CCM?

Thank you in advance.

Re: Service configuration files

Posted: Wed Jun 10, 2015 4:29 pm
by jolson
1) when adding a service on the Nagios Web GUI, besides a service configuration file is created in
/usr/local/nagios/etc/services directory, is this service configuration information also stored in the mySQL database or PostgreSQL database?
To clarify - when you make changes in the Web GUI, those changes are stored in a MySQL database. When you 'Apply Configuration', your changes are then written out into flat files in the /usr/local/nagios/etc/services directory (among other directories).
2) Where does Nagios CCM get the "original" (service) configuration settings to overwrite all the manual setting changes?
From the mentioned MySQL database.
3) What causes Nagios CCM to run and overwrite all the manual setting changes? When I click "Save Configuration" or by some kind of mechanism within Nagios CCM?
When applying configuration, if Nagios notices a change between what is stored in the database and what is stored in a flat file, the flat file is erased and replaced by a newly generated flat file.

If you want to define configurations by hand, you may do so in the static directory. https://assets.nagios.com/downloads/nag ... ios-XI.pdf

Re: Service configuration files

Posted: Wed Jun 10, 2015 5:04 pm
by xlin125
Thanks for the quick response and very helpful inforation/inside on how things work regarding adding/changing services.

You mentioned that "When you 'Apply Configuration', your changes are then written out into flat files in the /usr/local/nagios/etc/services directory (among other directories)." What other diretories are the changes to a service written to?

Where are those alarm thresholds saved and "checked" to trigger an alarm/event if the thresholds are exceeded and alarm condition is met when the Nagios XI receives the status data from a Nagios agent (say NRPE)? In the service configuration or in my SQL database?

Thanks for your time and help!

Re: Service configuration files

Posted: Wed Jun 10, 2015 7:05 pm
by Box293
xlin125 wrote: You mentioned that "When you 'Apply Configuration', your changes are then written out into flat files in the /usr/local/nagios/etc/services directory (among other directories)." What other diretories are the changes to a service written to?
# OBJECTS EXPORTED FROM NAGIOSQL
cfg_file=/usr/local/nagios/etc/contacttemplates.cfg
cfg_file=/usr/local/nagios/etc/contactgroups.cfg
cfg_file=/usr/local/nagios/etc/contacts.cfg
cfg_file=/usr/local/nagios/etc/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/commands.cfg
cfg_file=/usr/local/nagios/etc/hostgroups.cfg
cfg_file=/usr/local/nagios/etc/servicegroups.cfg
cfg_file=/usr/local/nagios/etc/hosttemplates.cfg
cfg_file=/usr/local/nagios/etc/servicetemplates.cfg
cfg_file=/usr/local/nagios/etc/servicedependencies.cfg
cfg_file=/usr/local/nagios/etc/serviceescalations.cfg
cfg_file=/usr/local/nagios/etc/hostdependencies.cfg
cfg_file=/usr/local/nagios/etc/hostescalations.cfg
cfg_file=/usr/local/nagios/etc/hostextinfo.cfg
cfg_file=/usr/local/nagios/etc/serviceextinfo.cfg
cfg_dir=/usr/local/nagios/etc/hosts
cfg_dir=/usr/local/nagios/etc/services
xlin125 wrote:Where are those alarm thresholds saved and "checked" to trigger an alarm/event if the thresholds are exceeded and alarm condition is met when the Nagios XI receives the status data from a Nagios agent (say NRPE)? In the service configuration or in my SQL database?
These are defined per service, it all depends on how the plugin works and what it's checking.

A service that checks if a process is running might return a critical if it was not running, so there's no defining a threshold here.

Here's an example of the Nagios XI check for localhost disk space. Warn at 20% free and critical at 15% free. These values are in $ARG1$ and $ARG2$.
Selection_088.png
And here's that same config when it's written to a flat config file:

Code: Select all

define service {
	host_name			localhost
	service_description		Root Partition
	use				local-service
	check_command			check_local_disk!20%!10%!/
	register			1
	}	

It's not actually Nagios that checks the thesholds, it's the plugin that is run that determines what exit code it returns to Nagios and hence Nagios does something based on that exit code. Have a read of this:

https://nagios-plugins.org/doc/guidelines.html#AEN78

Does this help?

Re: Service configuration files

Posted: Fri Jun 12, 2015 3:51 pm
by xlin125
Yes, it really helped. Thank you!

Re: Service configuration files

Posted: Mon Jun 15, 2015 9:41 am
by tmcdonald
Great to hear!

I'll be closing this thread now, but feel free to open another if you need anything in the future!