Failing to import from Host configuration file (Bulk Import)

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
kmartaus
Posts: 12
Joined: Wed Jan 29, 2014 7:25 pm

Failing to import from Host configuration file (Bulk Import)

Post by kmartaus »

Hi,
We are having a trouble importing host configuration file. We have created host configuration files and placed it under /usr/local/nagios/etc/import/ folder. And then we tried to run ./reconfigure_nagios.sh from /usr/local/nagiosxi/scripts/ folder. The script shows that the configuration file successfully imported and restart the nagios. But when I check the host in the Nagios XI gui and nagios database, it doesn't exist. These are new hosts (they don't exist in nagios) and we tried to import them as a bulk configuration. The problem seems to be exist in our both production and test environment.

But if we copy a existing hosts configuration file under ../etc/import and import it after making small changes to it, the changes seems to be applied in the Nagios.

I checked the logs and it doesn't give any errors where it is failing. It used to work before. But since then we have upgraded the Nagios to 2014R1.4 and mysql server to (mysql Ver 14.14 Distrib 5.6.20,)
System Details
----------------
CentOS Linux release 6.0 (Final)
Kernel \r on an \m

==================================
Nagios Virtual Machine Information
==================================
And database is on SUSE Linux Enterprise Server 11 SP1


here is the example of host configuration file:

Code: Select all

define host {
        host_name                  kwtvmm004
        use                             srv-test-template
        alias                           kwtvmm004
        address                       kwtvmm004
        hostgroups                  srv-c-windows-test
        icon_image                 win_server.png
        parents                       kvmlgagx001,kvmlgagx002
        register                      1
        }

All the template, service, parent host are already defined in the nagios.


Here is the output of the ./reconfigure_nagios.sh

Code: Select all

kapnxi001:/usr/local/nagiosxi/scripts # ./reconfigure_nagios.sh
URL: http://localhost/nagiosxi/includes/components/ccm/
CMDLINE
/usr/bin/wget --save-cookies nagiosql.cookies --keep-session-cookies http://localhost/nagiosxi/includes/components/ccm/ --no-check-certificate --post-data 'submit=Login&hidelog=true&loginSubmitted=true&username=nagiosxi&password=<password-defined-here>' -O nagiosql.login--2015-01-30 09:49:45--  http://localhost/nagiosxi/includes/components/ccm/
Resolving localhost... 127.0.0.1
Connecting to localhost|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: “nagiosql.login”

    [ <=>                                                                                    ] 11,662      --.-K/s   in 0.02s

2015-01-30 09:49:46 (598 KB/s) - “nagiosql.login” saved [11662]

LOGIN SUCCESSFUL!
IMPORTING CONFIG FILES...URL: http://localhost/nagiosxi/includes/components/ccm/
Array
(
    [0] => kwtvmm004.cfg
)
IMPORTING [color=#BF0000]/usr/local/nagios/etc/import/kwtvmm004.cfg[/color]
CMDLINE:
/usr/bin/wget --load-cookies=nagiosql.cookies http://localhost/nagiosxi/includes/components/ccm/ --no-check-certificate --post-data 'cmd=admin&type=import&importsubmitted=true&chbOverwrite=1&selImportFile[]=/usr/local/nagios/etc/import/kwtvmm004.cfg' -O nagiosql.import.monitoring
--2015-01-30 09:49:46--  http://localhost/nagiosxi/includes/components/ccm/
Resolving localhost... 127.0.0.1
Connecting to localhost|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: “nagiosql.import.monitoring”

    [  <=>                                                                                   ] 684,901      666K/s   in 1.0s

2015-01-30 09:49:47 (666 KB/s) - “nagiosql.import.monitoring” saved [684901]

SETUID ROOT OK
RESETTING PERMS
URL: http://localhost/nagiosxi/includes/components/ccm/
CMDLINE
/usr/bin/wget --save-cookies nagiosql.cookies --keep-session-cookies http://localhost/nagiosxi/includes/components/ccm/ --no-check-certificate --post-data 'submit=Login&hidelog=true&loginSubmitted=true&username=nagiosxi&password=<password-defined-here>' -O nagiosql.login--2015-01-30 09:49:48--  http://localhost/nagiosxi/includes/components/ccm/
Resolving localhost... 127.0.0.1
Connecting to localhost|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: “nagiosql.login”

    [ <=>                                                                                    ] 11,662      --.-K/s   in 0.008s

2015-01-30 09:49:48 (1.36 MB/s) - “nagiosql.login” saved [11662]

LOGIN SUCCESSFUL!
URL: http://localhost/nagiosxi/includes/components/ccm/
CMDLINE:
/usr/bin/wget --load-cookies=nagiosql.cookies http://localhost/nagiosxi/includes/components/ccm/ --no-check-certificate --post-data 'cmd=apply&type=writeConfig' -O nagiosql.export.monitoring
--2015-01-30 09:49:48--  http://localhost/nagiosxi/includes/components/ccm/
Resolving localhost... 127.0.0.1
Connecting to localhost|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: “nagiosql.export.monitoring”

    [                     <=>                                                                ] 14,514      6.13K/s   in 19s

2015-01-30 09:50:07 (775 B/s) - “nagiosql.export.monitoring” saved [14514]

WRITE CONFIGS SUCCESSFUL!
OUTPUT:
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...
Warning: Duplicate definition found for service 'SNMP Traps' on host 'kzplnkap101' (config file '/usr/local/nagios/etc/services/fst-p-snmp-trap.cfg', starting on line 14)
Warning: Duplicate definition found for service 'SNMP Traps' on host 'kzplnkap104' (config file '/usr/local/nagios/etc/services/fst-p-snmp-trap.cfg', starting on line 14)
Warning: Duplicate definition found for service 'SNMP Traps' on host 'kzplnkap102' (config file '/usr/local/nagios/etc/services/fst-p-snmp-trap.cfg', starting on line 14)
Warning: Duplicate definition found for service 'SNMP Traps' on host 'kzplnkap103' (config file '/usr/local/nagios/etc/services/fst-p-snmp-trap.cfg', starting on line 14)
Warning: Duplicate definition found for service 'SNMP Traps' on host 'kzplnkdx001' (config file '/usr/local/nagios/etc/services/fst-p-snmp-trap.cfg', starting on line 14)
   Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
Warning: Service 'Ping Dummy' on host 'kauto400' has no default contacts or contactgroups defined!
Warning: Service 'Ping Dummy' on host 'kwpkdw001' has no default contacts or contactgroups defined!
Warning: Service 'Ping Dummy' on host 'kwpkdw002' has no default contacts or contactgroups defined!
Warning: Service 'Ping Dummy' on host 'kwpkdw003' has no default contacts or contactgroups defined!
Warning: Service 'Ping Dummy' on host 'kwpkdw004' has no default contacts or contactgroups defined!
Warning: Service 'Ping Dummy' on host 'kwpkdw005' has no default contacts or contactgroups defined!
Warning: Service 'Ping Dummy' on host 'kwpkdw01' has no default contacts or contactgroups defined!
Warning: Service 'Ping Dummy' on host 'sy5' has no default contacts or contactgroups defined!
Warning: Service 'Ping Dummy' on host 'sy8' has no default contacts or contactgroups defined!
        Checked 11868 services.
Warning: Host 'kauto400' has no default contacts or contactgroups defined!
Warning: Host 'kutnrc001' has no default contacts or contactgroups defined!
Warning: Host 'kvmlgrpdu14l' has no default contacts or contactgroups defined!
Warning: Host 'kvmlgrpdu22L' has no default contacts or contactgroups defined!
Warning: Host 'kwpkdw001' has no default contacts or contactgroups defined!
Warning: Host 'kwpkdw002' has no default contacts or contactgroups defined!
Warning: Host 'kwpkdw003' has no default contacts or contactgroups defined!
Warning: Host 'kwpkdw004' has no default contacts or contactgroups defined!
Warning: Host 'kwpkdw005' has no default contacts or contactgroups defined!
Warning: Host 'kwpkdw01' has no default contacts or contactgroups defined!
Warning: Host 'sy5' has no default contacts or contactgroups defined!
Warning: Host 'sy8' has no default contacts or contactgroups defined!
        Checked 4876 hosts.
        Checked 144 host groups.
        Checked 0 service groups.
        Checked 255 contacts.
        Checked 48 contact groups.
        Checked 152 commands.
        Checked 17 time periods.
        Checked 0 host escalations.
        Checked 0 service escalations.
Checking for circular paths...
        Checked 4876 hosts
        Checked 0 service dependencies
        Checked 0 host dependencies
        Checked 17 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 21
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check
RET: 0
Running configuration check...done.
Stopping nagios: .done.
Starting nagios: done.
Although it is giving some warnings, but that should not stop nagios adding the host. I have also checked in test environment without any warnings, it doesn't add the host.

Also followed the instruction give this documents, but didn't work:

http://assets.nagios.com/downloads/nagi ... ios-XI.pdf
http://assets.nagios.com/downloads/nagi ... p-Tool.pdf


We need help to find out why it is not working anymore?
I tried checking all the logs but no luck. Is there any specific logs I need to check?
How can we fix this?

Regards
Zubair
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Failing to import from Host configuration file (Bulk Imp

Post by abrist »

Could you check the CCM for the host? (it may be disabled)
After importing as suggested in the Importing-Core-Configuration-Files-Into-Nagios-XI doc, does the host appear in the CCM?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
kmartaus
Posts: 12
Joined: Wed Jan 29, 2014 7:25 pm

Re: Failing to import from Host configuration file (Bulk Imp

Post by kmartaus »

The host doesn't appear in the CCM.

it just delete the host.cfg file from the import folder without importing it into Nagios.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Failing to import from Host configuration file (Bulk Imp

Post by lmiltchev »

The order in which you are importing files in Nagios XI is important. We recommend importing files in the following order:

Code: Select all

commands -> timeperiods -> contacttemplates -> contacts -> contactgroups ->
hosttemplates -> hosts -> hostgroups -> servicetemplates -> services -> servicegroups
Have you tried importing all of the configs, associated with the host configuration file first (in the correct order)? Try doing this from the GUI. Check the CCM and the flat files after each import to make sure each step was successful. Let us know if you get stuck on something.
Be sure to check out our Knowledgebase for helpful articles and solutions!
kmartaus
Posts: 12
Joined: Wed Jan 29, 2014 7:25 pm

Re: Failing to import from Host configuration file (Bulk Imp

Post by kmartaus »

Hi,

The hostgroup, timeperiods, contacttemplates, contract, contractgroup etc. all that are mentioned in the host.cfg already exist in Nagios. I have a script which runs over night to check new VM's in Vmware and Active Directory. If it finds a new Host and the host doesn't already exist in the Nagios, it tries to automatically add these new hosts to existing hostsgroup and templates by importing the host.cfg file. I have given a sample of host config files in my earlier post.

Do we still need to import other than host configuration file if they already exist in nagios (commands -> timeperiods -> contacttemplates -> contacts -> contactgroups ->
hosttemplates -> hosts -> hostgroups -> servicetemplates -> services -> servicegroups)?

It was working before but I don't know why it not working now...as it is not throwing any errors in any logs.

We want to automate the process of adding new host in the Nagios by discovering new hosts.

Regards
Zubair
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Failing to import from Host configuration file (Bulk Imp

Post by scottwilkerson »

Lets verify that it is connecting to the correct DB, can you run the following

Code: Select all

cat /usr/local/nagiosxi/html/config.inc.php|grep dbserver
cat /usr/local/nagiosxi/etc/components/ccm_config.inc.php|grep server
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
kmartaus
Posts: 12
Joined: Wed Jan 29, 2014 7:25 pm

Re: Failing to import from Host configuration file (Bulk Imp

Post by kmartaus »

HI,

Here is the output of the commands.

kapnxi001:/usr/local/nagiosxi/scripts # cat /usr/local/nagiosxi/html/config.inc.php|grep dbserver
$cfg['dbserver']='localhost'; // this setting is no longer used - use settings below
"dbserver" => 'localhost',
"dbserver" => 'kupndb001',
"dbserver" => 'kupndb001',
kapnxi001:/usr/local/nagiosxi/scripts # cat /usr/local/nagiosxi/etc/components/ccm_config.inc.php|grep server
"server" => "kupndb001",

dbserver should be kupndb001. As you can see above in the /usr/local/nagiosxi/html/config.inc.php, one of the dbserver is configured as localhost. do you think this could be the reason? We didn't touch this file at all.

The timestamp on the file suggest that it may happen at the time when we did Nagios upgrade to 2014R.4.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Failing to import from Host configuration file (Bulk Imp

Post by abrist »

We need to see a bit more information (You may want to obfuscate passwords):

Code: Select all

cat /usr/local/nagiosxi/html/config.inc.php|grep -5 dbserver
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
kmartaus
Posts: 12
Joined: Wed Jan 29, 2014 7:25 pm

Re: Failing to import from Host configuration file (Bulk Imp

Post by kmartaus »

Hi,
Here is the output of the command. Password is obfuscate.

Code: Select all

			
// force http/https
$cfg['use_https']=false;  // determines whether cron jobs and other scripts will force the use of HTTPS instead of HTTP

// default server, db, connection settings
$cfg['dbtype']=''; // this setting is no longer used - use settings below
$cfg['dbserver']='localhost'; // this setting is no longer used - use settings below

// db-specific connection information
$cfg['db_info']=array(
        "nagiosxi" => array(
                "dbtype" => 'pgsql',
                "dbserver" => 'localhost',
                "user" => 'nagiosxi',
                "pwd" => 'xxxxx',
                "db" => 'nagiosxi',
                "dbmaint" => array(             // variables affecting maintenance of db
                        "max_commands_age" => 480, // max time (minutes) to keep commands
--
                        "repair_interval" => 0, // time (in minutes) between db repair runs
                        ),
                ),
        "ndoutils" => array(
                "dbtype" => 'mysql',
                "dbserver" => 'kupndb001',
                "user" => 'nagios',
                "pwd" => 'xxxxx',
                "db" => 'nagios',
                "dbmaint" => array(             // variables affecting maintenance of ndoutils db

--
                        "repair_interval" => 0, // time (in minutes) between db repair runs
                        ),
                ),
        "nagiosql" => array(
                "dbtype" => 'mysql',
                "dbserver" => 'kupndb001',
                "user" => 'nagiosql',
                "pwd" => 'xxxxx',
                "db" => 'nagiosql',
                "dbmaint" => array(             // variables affecting maintenance of db
                        "max_logbook_age" => 480, // max time (minutes) to keep log book records
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Failing to import from Host configuration file (Bulk Imp

Post by scottwilkerson »

We need to make sure your XI server can resolve the hostname kupndb001

Code: Select all

ping kupndb001
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked