Page 1 of 1
Importing Hosts from Old server to new
Posted: Thu Jul 02, 2015 8:15 pm
by Darth_Panda
I have built a clean install of Nagios Core 4 on Debian 8. I can log in to the web interface so all is good. I have 851 host files that I can import from the old server. I created the hosts folder under /usr/local/nagios/etc but Nagios does not automatically find them. I checked the old nagios.cfg file and found that it is very different to the new default nagios.cfg The old config has a reference to the hosts folder and another;
Code: Select all
cfg_dir=/usr/local/nagios/etc/hosts
cfg_dir=/usr/local/nagios/etc/services
There is also these config file references;
Code: Select all
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/hosttemplates.cfg
cfg_file=/usr/local/nagios/etc/servicetemplates.cfg
cfg_file=/usr/local/nagios/etc/hostgroups.cfg
cfg_file=/usr/local/nagios/etc/contactgroups.cfg
I have tried to edit my new nagios.cfg file with these changes but when I try a Nagios restart I get;
Code: Select all
root@deb8monitor:/home/paul# /etc/init.d/nagios restart
Restarting nagios (via systemctl): nagios.serviceJob for nagios.service failed. See 'systemctl status nagios.service' and 'journalctl -xn' for details.
failed!
Nagios will not start until I change the nagios.cfg back to how it was. There must be a way to get Nagios to include my 851 host files as hosts and start monitoring them. Any ideas?
Re: Importing Hosts from Old server to new
Posted: Thu Jul 02, 2015 9:00 pm
by Box293
When you add
cfg_dir=/usr/local/nagios/etc/hosts to nagios.cfg, run the verify to see what may be the problem:
Code: Select all
/usr/local/nagios/bin/nagios -vvv /usr/local/nagios/etc/nagios.cfg
Re: Importing Hosts from Old server to new
Posted: Thu Jul 02, 2015 9:23 pm
by Darth_Panda
Box293 wrote:When you add cfg_dir=/usr/local/nagios/etc/hosts to nagios.cfg, run the verify to see what may be the problem:
Thanks, now we are getting somewhere. It looks like it does not like 'ONU' as a type of device. All 851 of my devices are ONU's which are a type of fibre modem/router. I now have to figure out a way of moving over the other cfg files so the new Nagios knows what an ONU is. Would you agree?
Code: Select all
root@deb8monitor:/home/paul# /usr/local/nagios/bin/nagios -vvv /usr/local/nagios/etc/nagios.cfg
Nagios Core 4.0.8
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-12-2014
License: GPL
Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/switch.cfg'...
Processing object config directory '/usr/local/nagios/etc/hosts'...
Processing object config file '/usr/local/nagios/etc/hosts/sc2025.cfg'...
Error: Template 'ONU' specified in host definition could not be not found (config file '/usr/local/nagios/etc/hosts/sc2025.cfg', starting on line 14)
Error processing object config files!
***> One or more problems was encountered while processing the config files...
Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.
Re: Importing Hosts from Old server to new
Posted: Thu Jul 02, 2015 10:23 pm
by Box293
Your host defined in sc2025.cfg is using a template called ONU. This will exist in your old configuration files from your old server. If you can't find it, have a look in the existing templates.cfg and duplicate one of those and call it ONU.
Re: Importing Hosts from Old server to new
Posted: Fri Jul 03, 2015 1:29 am
by Darth_Panda
Box293 wrote:Your host defined in sc2025.cfg is using a template called ONU. This will exist in your old configuration files from your old server. If you can't find it, have a look in the existing templates.cfg and duplicate one of those and call it ONU.
MIssion completed. Thanks for all your help. I just kept using the verification command that you supplied and I just kept correcting the hostnames. hostgroups and contatcgroups etc until it was happy. Now I'm happy

. Next step email alerting

.
Re: Importing Hosts from Old server to new
Posted: Fri Jul 03, 2015 1:31 am
by Box293
Great stuff
