Page 1 of 2

CLI import configs mystery

Posted: Wed Sep 11, 2013 12:29 pm
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.

Re: CLI import configs mystery

Posted: Wed Sep 11, 2013 1:09 pm
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

Re: CLI import configs mystery

Posted: Wed Sep 11, 2013 1:25 pm
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)?

Re: CLI import configs mystery

Posted: Wed Sep 11, 2013 2:35 pm
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.

Re: CLI import configs mystery

Posted: Wed Sep 11, 2013 2:45 pm
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

Re: CLI import configs mystery

Posted: Wed Sep 11, 2013 2:49 pm
by lmiltchev
Can you run the following command and show the output?

Code: Select all

ll -R /usr/local/nagios/etc/cfgprep

Re: CLI import configs mystery

Posted: Wed Sep 11, 2013 3:54 pm
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.

Re: CLI import configs mystery

Posted: Wed Sep 11, 2013 4:47 pm
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.

Re: CLI import configs mystery

Posted: Wed Sep 11, 2013 7:18 pm
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
}

Re: CLI import configs mystery

Posted: Thu Sep 12, 2013 12:59 pm
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?