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
}
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)
Code: Select all
MySQL [nagiosql]> select id, contact_name from tbl_contact;
+----+--------------+
| id | contact_name |
+----+--------------+
| 1 | nagiosadmin |
+----+--------------+
1 row in set (0.02 sec)