Nagios XI - Automation from Script Issue with Offloaded DB

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
User avatar
chicjo01
Posts: 194
Joined: Tue Jul 28, 2015 2:52 pm

Nagios XI - Automation from Script Issue with Offloaded DB

Post by chicjo01 »

Background:
I have remote databases servers for NagiosQL and Nagios
A script builds the config file from LDAP groups to populate contacts (If successful, will expand to hosts and hostgroups)
Config files are being written to /usr/local/nagios/etc/import
Cronjob executes /usr/local/nagiosxi/scripts/reconfigure_nagios.sh (Currently Disabled, while working on issue)

Problem:
When attempting to import config files either through /usr/local/nagiosxi/scripts/reconfigure_nagios.sh or web interface "Import Config Files" the config data gets added to the local NagiosQL database and not the remote database. Additionally, the contacts.cfg file does not get updated with the data.

Steps Taken:
1) Run the ADScanner Script (Pulls LDAP Data and build Config File in /usr/local/nagios/etc/import)
2) cd /usr/local/nagiosxi/scripts/
3) ./reconfigure_nagios.sh
4) grep -i chick /usr/local/nagios/etc/contacts.cfg (data does not found)
5) Check Configure -> Core Config Manager -> Contacts

Example of Config Created from LDAP:

Code: Select all

define contact {
	contact_name		SchicJo00
	alias		Schick, John
	email		[email protected]
	host_notification_period		24x7
	service_notification_period	24x7
	host_notifications_enabled		1
	service_notifications_enabled	1
	host_notification_options		d,u,r,s
	service_notification_options	w,u,c,r,s
	host_notification_commands	notify-host-by-email
	service_notification_commands	notify-service-by-email
	_useScript		ADScanner
	use		generic-contact
}
Output from Reconfigure_Nagios:

Code: Select all

./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=xxxxxx&password=xxxxxx' -O nagiosql.login--2015-09-29 11:00:06--  http://localhost/nagiosxi/includes/components/ccm/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘nagiosql.login’

    [ <=>                                   ] 11,254      --.-K/s   in 0.01s   

2015-09-29 11:00:07 (1.12 MB/s) - ‘nagiosql.login’ saved [11254]

LOGIN SUCCESSFUL!
IMPORTING CONFIG FILES...URL: http://localhost/nagiosxi/includes/components/ccm/
Array
(
    [0] => SchicJo00.cfg
)
IMPORTING /usr/local/nagios/etc/import/SchicJo00.cfg
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/SchicJo00.cfg' -O nagiosql.import.monitoring
--2015-09-29 11:00:07--  http://localhost/nagiosxi/includes/components/ccm/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘nagiosql.import.monitoring’

    [  <=>                                  ] 15,230      19.6KB/s   in 0.8s   

2015-09-29 11:00:09 (19.6 KB/s) - ‘nagiosql.import.monitoring’ saved [15230]

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=xxxxxx&password=xxxxxxx' -O nagiosql.login--2015-09-29 11:00:10--  http://localhost/nagiosxi/includes/components/ccm/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘nagiosql.login’

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

2015-09-29 11:00:11 (1.27 MB/s) - ‘nagiosql.login’ saved [11254]

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-09-29 11:00:11--  http://localhost/nagiosxi/includes/components/ccm/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘nagiosql.export.monitoring’

    [  <=>                                  ] 14,108       551B/s   in 26s     

2015-09-29 11:00:37 (551 B/s) - ‘nagiosql.export.monitoring’ saved [14108]

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...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
	Checked 8 services.
	Checked 1 hosts.
	Checked 1 host groups.
	Checked 0 service groups.
	Checked 2 contacts.
	Checked 2 contact groups.
	Checked 118 commands.
	Checked 8 time periods.
	Checked 0 host escalations.
	Checked 0 service escalations.
Checking for circular paths...
	Checked 1 hosts
	Checked 0 service dependencies
	Checked 0 host dependencies
	Checked 8 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check
RET: 0

Output from NagiosQL (Localhost):

Code: Select all

MariaDB [nagiosql]> select id, contact_name from tbl_contact;
+----+--------------+
| id | contact_name |
+----+--------------+
|  1 | nagiosadmin  |
|  2 | John Schick   |
|  3 | tom          |
+----+--------------+
3 rows in set (0.05 sec)
Output from NagiosQL (Remote):

Code: Select all

MySQL [nagiosql]> select id, contact_name from tbl_contact;
+----+--------------+
| id | contact_name |
+----+--------------+
|  1 | nagiosadmin  |
+----+--------------+
1 row in set (0.02 sec)
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Nagios XI - Automation from Script Issue with Offloaded

Post by lmiltchev »

What are the steps you took to offload the NagiosQL? Can you provide us with a link to a document/tutorial that you followed?
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
chicjo01
Posts: 194
Joined: Tue Jul 28, 2015 2:52 pm

Re: Nagios XI - Automation from Script Issue with Offloaded

Post by chicjo01 »

lmiltchev wrote:What are the steps you took to offload the NagiosQL? Can you provide us with a link to a document/tutorial that you followed?
I used the documentation from the exchange to offload the MySQL DB to remote servers.
https://assets.nagios.com/downloads/nag ... Server.pdf

Additional Notes, which are missing from document for Offloading NDOUtils MySQL database.
- I found the NDOUtils MySQL database has a hardcode stuck in the Nagios Code somewhere.
-- Problem: Using a different username then the defaulted "ndoutils"
-- Impact: The Views in NagiosXI do not display the host or service data, instead displays:
  • SQL: SQL Error [ndoutils] : Table 'nagiosql.nagios_programstatus' doesn't exist
-- Work Around: The username on the remote server need to be the default "ndoutils" (Password can be different)
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Nagios XI - Automation from Script Issue with Offloaded

Post by ssax »

Are you on XI 5 yet? If not, you might want to setup a test server with it on there and try it out for this (maybe it can be done with the new API).

I will take a look at the code tomorrow and try to hunt down where this occurs, I took a cursory glance but couldn't find what I was looking for.
User avatar
chicjo01
Posts: 194
Joined: Tue Jul 28, 2015 2:52 pm

Re: Nagios XI - Automation from Script Issue with Offloaded

Post by chicjo01 »

ssax wrote:Are you on XI 5 yet? If not, you might want to setup a test server with it on there and try it out for this (maybe it can be done with the new API).

I will take a look at the code tomorrow and try to hunt down where this occurs, I took a cursory glance but couldn't find what I was looking for.
Thank you and please let me know what you uncover when you take a closer look.

I will see if I can setup a test environment for XI 5.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Nagios XI - Automation from Script Issue with Offloaded

Post by lmiltchev »

chicjo01, are you trying to create "contacts only" (for notification purposes) or you are trying to create "xi users" (who can log in web interface)?
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
chicjo01
Posts: 194
Joined: Tue Jul 28, 2015 2:52 pm

Re: Nagios XI - Automation from Script Issue with Offloaded

Post by chicjo01 »

lmiltchev wrote:chicjo01, are you trying to create "contacts only" (for notification purposes) or you are trying to create "xi users" (who can log in web interface)?
Contact Only for Notification Purposes.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Nagios XI - Automation from Script Issue with Offloaded

Post by tmcdonald »

I will be moving this into the Nagios XI forum since this is a Nagios XI question.

Also, I would agree with going to XI 5. The API works beautifully and is the supported method. I have also looked at the import code and can't find why this is happening, so we'll need to either dig deeper or ask the devs to take a look.
Former Nagios employee
User avatar
chicjo01
Posts: 194
Joined: Tue Jul 28, 2015 2:52 pm

Re: Nagios XI - Automation from Script Issue with Offloaded

Post by chicjo01 »

tmcdonald wrote:I will be moving this into the Nagios XI forum since this is a Nagios XI question.

Also, I would agree with going to XI 5. The API works beautifully and is the supported method. I have also looked at the import code and can't find why this is happening, so we'll need to either dig deeper or ask the devs to take a look.
Thank you and if you find any new information on it. I would suggest updating or creating a DOC for the exchange. When I get NagiosXI 5 up and working and convert over the script to use the API. I will let you know of my findings.
User avatar
Nagios Support
Posts: 36
Joined: Thu Sep 04, 2014 12:16 pm

Re: Nagios XI - Automation from Script Issue with Offloaded

Post by Nagios Support »

Thank you and if you find any new information on it. I would suggest updating or creating a DOC for the exchange. When I get NagiosXI 5 up and working and convert over the script to use the API. I will let you know of my findings.
Sure. Let us know how it went. Meanwhile, we will do some more digging into this and get back to you as soon as we have a possible solution.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked