Rationalising .cfg files in Nagios Core

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
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Rationalising .cfg files in Nagios Core

Post by neworderfac33 »

Good afternoon,

I now have a ridiculously large windows.cfg file which I would like to rationalize, with different groups of hosts spread over different .cfg files.

What I'd like to know is, do I have to define the services that will be used by the hosts in EACH .cfg file or can I place them in a separate .cfg file?

For example, say I have windows1.cfg and windows2.cfg, each containing a separate set of hosts, but with both sets of hosts needing to make use of the same services - do I have to define the services in both windows1.cfg and windows2.cfg or can I define them just once in a file called, say, services.cfg (obviously making sure that I add it to /usr/local/nagios/etc/nagios.cfg)?

As always, thanks in advance for your help.

Pete
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Rationalising .cfg files in Nagios Core

Post by eloyd »

You can split them however you want. Especially if you're using the nagios.cfg directive "cfg_dir" to include every *.cfg file in a specific directory. If not, you should use that. Then you can literally make one file per host one file per service one file per anything, and Nagios will just add them.

Generally, we do by host or by service, but Nagios doesn't care what file it read the configuration from. It reads them all and then parses them all at once.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Rationalising .cfg files in Nagios Core

Post by tmcdonald »

I typically tell people that the most important thing is documentation and consistently following it. You can split your configs however you want, and if you ask 10 different people how to do it you can get 10 different answers. But at the end of the day, the best thing you can do is to write it down and make sure that anyone who manages the configs follows that doc.
Former Nagios employee
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Rationalising .cfg files in Nagios Core

Post by neworderfac33 »

Thanks for confirming that, folks - much appreciated.

Pete
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Rationalising .cfg files in Nagios Core

Post by tmcdonald »

Not a problem. Mind if I close this out?
Former Nagios employee
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Rationalising .cfg files in Nagios Core

Post by neworderfac33 »

Yes please! :-)
Locked