Page 1 of 1
Seperate cfg file for hosts in core 4.0.7
Posted: Tue Jul 22, 2014 5:18 am
by tariqondego
Is it possible to have seperate files eg hosts.cfg,service.cfg,hostgroups.cfg etc,on core 4.0.7.?
I have just created a hosts.cfg and defined 'hostTest'.But I keep getting error 'Host hosTest cannot be found',when i restart nagios.
But when I define this host inside locahost.cfg it works ok.
I would like to have separate files for the hosts,services and hostgroups.
Please advise.
Re: Seperate cfg file for hosts in core 4.0.7
Posted: Wed Jul 23, 2014 12:44 am
by Box293
Yes this is possible.
In your nagios.cfg file you need to define the config files, for example:
Code: Select all
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg
cfg_file=/usr/local/nagios/etc/objects/hostgroups.cfg
Re: Seperate cfg file for hosts in core 4.0.7
Posted: Fri Jul 25, 2014 4:11 am
by tariqondego
Thanks alot!
Re: Seperate cfg file for hosts in core 4.0.7
Posted: Fri Jul 25, 2014 6:53 am
by eloyd
You can also use the "cfg_dir" directive to include *.cfg in a particular directory. And you can mix and match. Here's an example:
Code: Select all
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_dir=/usr/local/nagios/etc/my_custom_configs
This means you can put your own commands.cfg and contacts.cfg and hosts.cfg and services.cfg or host_name.cfg in the my_custom_configs directory and Nagios will pick up those config files without having to specify them directly.
Don't need a file anymore (maybe for testing)? "mv my_custom_configs/file.cfg my_custom_configs/file.cfg.xxx" and it will no longer be loaded. XXX can be anything, so long as the file doesn't end in *.cfg