nagios3 config file default and override handling

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
jfkw
Posts: 5
Joined: Wed Nov 23, 2016 12:55 am

nagios3 config file default and override handling

Post by jfkw »

Questions re: nagios3 config file parser behavior, so I can better mange nagios config under version control:

Do all nagios3 config files allow redefinition of config defaults using last-seen-wins?

Do all default config directives need to be present in /etc/nagios* to have effect? Or are they defined under the packaged nagios source files?

I use nagios3-3.5.1.dfsg-2.1ubuntu1 on ubuntu 16.04.

Thanks.
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: nagios3 config file default and override handling

Post by dwhitfield »

From what repo did you install Nagios? If it is not ours, then you are probably better off talking to the package maintainer.
jfkw
Posts: 5
Joined: Wed Nov 23, 2016 12:55 am

Re: nagios3 config file default and override handling

Post by jfkw »

Thanks, This package nagios3-3.5.1.dfsg-2.1ubuntu1 on ubuntu 16.04 is from the ubuntu repository.

Perhaps I can restate my questions more clearly to focus on nagios config file semantics and not packaging.

1. If a directive appears in a default nagios config file, e.g.

Code: Select all

In /etc/nagios3/nagios.cfg:
cfg_dir=/etc/nagios3/conf.d
Can I leave that in directive as is, then override it with a different value for cfg_dir later in the file or included files?

If so, Is redefinition-allowed, last-seen-wins the rule 100% throughout nagios?

2. If for example cfg_dir was not defined in any of those files under /etc, are there inherent nagios defaults for settings like cfg_dir?

If so, do all critical settings have defaults?

Some software has default config under /etc which consists entirely of commented settings illustrating the inherent defaults. I'm wondering if Nagios has the same.

Thanks.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: nagios3 config file default and override handling

Post by rkennedy »

I'll try my best to answer this for the Nagios related parts, but some of it actually is package related since it has been changed.
Can I leave that in directive as is, then override it with a different value for cfg_dir later in the file or included files?

If so, Is redefinition-allowed, last-seen-wins the rule 100% throughout nagios?
I'm not sure exactly what you're asking here, but I'll try to explain.

cfg_dir= can be called to as many different times as you wanted. You could set up your nagios.cfg like this (where ... represents other parts of the config file) -

Code: Select all

...
cfg_dir=/etc/nagios3/conf.d/hosts/
cfg_dir=/etc/nagios3/conf.d/services/
...
This would tell Nagios to look for configurations in both the /etc/nagios3/conf.d/hosts/ and /etc/nagios3/conf.d/services/ for any object definitions. You could also change this to something like -

Code: Select all

...
cfg_dir=/path/to/my/dir/hosts/
...
The only important thing is that the user running nagios can access the files here.
2. If for example cfg_dir was not defined in any of those files under /etc, are there inherent nagios defaults for settings like cfg_dir?
No. As for settings have defaults, and others don't - this is a pretty broad question so I'm not sure how to answer it further.
Some software has default config under /etc which consists entirely of commented settings illustrating the inherent defaults. I'm wondering if Nagios has the same.
The package you mentioned is configured for /etc/nagios3/, where as our default core installs actually use the /usr/local/nagios/ path. This gets into not knowing completely what paths are being used. Core can be compiled however you want, and you can change up the paths as needed. See this guide for a source install instructions - https://support.nagios.com/kb/article.p ... ategory=58
Former Nagios Employee
Locked