CLI import configs mystery

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
tompotter
Posts: 7
Joined: Fri Aug 30, 2013 1:34 pm

CLI import configs mystery

Post by tompotter »

Running automated config import via CLI. Seems to run without error but no hosts in dashboard. This is a fresh install.

Deployed Nagios XI AMI (EC2) in Amazon: nagiosxi appliance 1.2
CentOS release 6.3
Nagios XI 2012R2.3

I am parsing host data from EC2 API to create host config files. I have 2 temp folders. One I write host config files to. The second I run xiprepimport.php against each file to generate a new file in temp folder 2. I then copy those files into /usr/local/nagios/etc/import/. Change directory to /usr/local/nagiosxi/scripts an run reconfigure_nagios.sh

-- Auth works
-- All files are processed without error returning “nagiosql.import.monitoring” saved for each file.
-- /usr/local/nagios/etc/import/ is now empty
-- Files are visible in dashboard at CCW/Tools/Configuration Import (but shows all files that are in the second temp folder, not /usr/local/nagios/etc/import/).
-- Restarting nagios manually, still no new configs
-- Logged into DB. No new hosts in tbl_host in nagiosql database
-- Enabled query logging on MySql. I'm seeing, with no errors:

Code: Select all

INSERT INTO `tbl_host` SET `name` = 'app01-stage_int_pdx_ourdomain_com',`alias` = 'app01-stage.int.pdx.ourdomain.com',`display_name` = '(pdx-stage) app01-stage',`address` = '10.101.0.164',  `config_id`=1, `active`='1', `last_modified`=NOW()
-- Reviewing output from reconfigure_nagios.sh shows no errors. Exit 0.
-- /verify.php --no-check-certificate --post-data 'writeMonitoring=Go' -O nagiosql.export.monitoring WRITE CONFIGS SUCCESSFUL!
-- Config File Permissions Check comes back as Okay.

So it looks like the config is being submitted to the database, but when I query the database, nothing is there. And no new hosts in UI. No new config files generated from DB. I don't know if something is cleaning these up after submitting, or some weird MySQL issue. In any event, I cannot get new configs into Nagios XI via API.
tompotter
Posts: 7
Joined: Fri Aug 30, 2013 1:34 pm

Re: CLI import configs mystery

Post by tompotter »

Ewww... looky what I found

[error] [client 127.0.0.1] script '/usr/local/nagiosxi/html/admin/import.php' not found or unable to stat

[root@mon01a-pre httpd]# ls -la /usr/local/nagiosxi/html/admin/import.php
ls: cannot access /usr/local/nagiosxi/html/admin/import.php: No such file or directory
[root@mon01a-pre httpd]# find /usr/ | grep import.php
/usr/local/nagiosxi/tools/xiprepimport.php
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: CLI import configs mystery

Post by lmiltchev »

/usr/local/nagiosxi/tools/xiprepimport.php
Yes, this is the path to the "xiprepimport.php" script.

The following two documents are the "official" steps, you need to follow in order to import config files to XI. It seems you didn't follow these documents closely...

http://assets.nagios.com/downloads/nagi ... p_Tool.pdf

http://assets.nagios.com/downloads/nagi ... nto_XI.pdf

Did you copy all of the individual files from the 2nd tmp folder to the import directory or you copied the whole tmp directory (directory itself)?
Be sure to check out our Knowledgebase for helpful articles and solutions!
tompotter
Posts: 7
Joined: Fri Aug 30, 2013 1:34 pm

Re: CLI import configs mystery

Post by tompotter »

I have both those docs and have followed their instructions. I copied each file into the import directory, not the entire directory.
1) raw cfg file I generated (very minimal)
2) process those files one at a time and save their output into a separate directory using XI's prep tool
3) copy each of those files into the import directory
4) cd to and run reconfigure script.
tompotter
Posts: 7
Joined: Fri Aug 30, 2013 1:34 pm

Re: CLI import configs mystery

Post by tompotter »

I spun up a new server and checked the boot logs. There was a reference to some script trying to download http://assets.nagios.com/downloads/nagi ... est.tar.gz which failed. The import.php file thats missing appears to be in this package. So who knows what else potentially is going to fail. I'm going to start over from scratch and see if this missing install on first boot is causing the issue
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: CLI import configs mystery

Post by lmiltchev »

Can you run the following command and show the output?

Code: Select all

ll -R /usr/local/nagios/etc/cfgprep
Be sure to check out our Knowledgebase for helpful articles and solutions!
tompotter
Posts: 7
Joined: Fri Aug 30, 2013 1:34 pm

Re: CLI import configs mystery

Post by tompotter »

92 files, only host config files. Example:
-rw-rw-r-- 1 apache nagios 1565 Sep 11 14:04 app01-dev1_int_pdx_obscured_com.cfg

Thats 92 in cfgprep. The 1st temp folder is a sub folder of cfgprep.

Keep in mind this is Nagios XI's prebaked AMI for Amazon. Not a source install.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: CLI import configs mystery

Post by sreinhardt »

Actually if you are using our ami instance, it is a source based install from our latest tarball. Was there any more detail on why the assets download was failing? It certainly should not be the case.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
tompotter
Posts: 7
Joined: Fri Aug 30, 2013 1:34 pm

Re: CLI import configs mystery

Post by tompotter »

I saw that in the EC2 log, but when I went back the logs had been written over.
I installed a new instance. Same issue.

-- copied 1 file into import dir. file installed
-- copied 5 files into import dir. No change.
-- did a recursive grep on host that installed and found it here:
/usr/local/nagios/etc/hosts/.cfg

This is odd. Maybe writing all configs to same file (.cfg), which is missing the filename, and maybe over-writing itself? Still, database only has one host (and localhost)

Here's an example of one file I'm copying into the import folder. tpl-host-dev is already configured and in the dashboard.
My POC is going to fall through!

Code: Select all

define host{
name    app01-stage_int_pdx_hidden_com
use tpl-host-dev
alias          app01-stage.int.pdx.hidden.com
display_name    pdx-stage-app01-stage
address     10.101.0.164
}
Last edited by slansing on Thu Sep 12, 2013 9:17 am, edited 1 time in total.
Reason: Please edit your previous post to add information/questions if you are the last poster.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: CLI import configs mystery

Post by sreinhardt »

Do you have the template that is being used by that host in the nagios configuration or database already, or is it attempting to be imported with the host file. One issue that I have found, is that often groups and templates that are being imported with the hosts\services will not exist yet and so the host\service will not be imported as it references something not yet available. Could this be the case?
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked