Service configuration files

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
xlin125
Posts: 172
Joined: Mon Jan 19, 2015 6:01 pm

Service configuration files

Post 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.
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Service configuration files

Post 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
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
xlin125
Posts: 172
Joined: Mon Jan 19, 2015 6:01 pm

Re: Service configuration files

Post 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!
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Service configuration files

Post 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?
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
xlin125
Posts: 172
Joined: Mon Jan 19, 2015 6:01 pm

Re: Service configuration files

Post by xlin125 »

Yes, it really helped. Thank you!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Service configuration files

Post 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!
Former Nagios employee
Locked