Page 1 of 1

Nagios XI Import Inactive Hosts

Posted: Thu Feb 12, 2015 2:43 pm
by toodaly
I'm trying to monitor hosts and services that will leave one Nagios XI server and join another one. When they are active, I can see them in /usr/local/nagios/etc/hosts and /usr/local/nagios/etc/services. When I deactivate them in CCM and apply, they are no longer in /usr/local/nagios/etc/hosts and /usr/local/nagios/etc/services. Is there any way to import hosts and services that default as inactive (visible in CCM) and then activate them using CCM when they are being monitored by a Nagios XI server?

Re: Nagios XI Import Inactive Hosts

Posted: Thu Feb 12, 2015 4:19 pm
by abrist
How are you importing the hosts?

Re: Nagios XI Import Inactive Hosts

Posted: Thu Feb 12, 2015 5:07 pm
by toodaly
Following the procedure outlined in "Automated Host Management In Nagios XI"
Placing .cfg files (each one has a host defined with its associated services) into /usr/local/nagios/etc/import.
Running /usr/local/nagiosxi/scripts/reconfigure_nagios.sh

Re: Nagios XI Import Inactive Hosts

Posted: Fri Feb 13, 2015 10:56 am
by abrist
Well, here is one method, though it will cause all imported objects to be set to "inactive" at first. One thing to note is that this may effect wizards as well.
Edit the following file:

Code: Select all

/usr/local/nagiosxi/html/includes/components/ccm/classes/import_class.php
Change Line Number #555 From:

Code: Select all

$intActive = 1;
To:

Code: Select all

$intActive = 0;
So that the if statement reads:

Code: Select all

        if (isset($arrImportData['register']) && ($arrImportData['register']['value'] == 0) && ($intIsTemplate != 1)) {
            $intActive = 0;
        } else {
            $intActive = 0;
This change will be overwritten by a Nagios XI upgrade.

Re: Nagios XI Import Inactive Hosts

Posted: Fri Feb 13, 2015 12:31 pm
by toodaly
Thanks for the reply. There are more hosts that should start as active than there are inactive. I'll keep them as all active when I import them. Is there a command line alternative to using the CCM for deactivating the services of a host and then deactivating the host? For example, I use the /usr/local/nagiosxi/scripts/nagiosql_delete_service.php and nagiosql_delete_host.php to remove a host and its associated services.

Re: Nagios XI Import Inactive Hosts

Posted: Fri Feb 13, 2015 12:46 pm
by abrist
toodaly wrote:Is there a command line alternative to using the CCM for deactivating the services of a host and then deactivating the host?
Not a scripted one like the nagiosql scripts. You could run an SQL update query to the object in nagios ql changing the object to inactive.
The issues with this are that after an import (which restarts nagios), the above change would essentially force another nagios restart before they are set to inactive.

Does this make sense?

Re: Nagios XI Import Inactive Hosts

Posted: Fri Feb 13, 2015 1:43 pm
by toodaly
OK. I have no experience with SQL. I'll stick to using the XI GUI unless there's an easy way to extract the information I need.

Using google:
update <table>
set <column>=<inactive keyword>
where <column>=<active keyword>
What does Nagios XI use for host or service <table>, what is the active/inactive <column> (is it different for hosts and services), is the column value 0 or 1 for active or inactive or is there a keyword (i.e. ACTIVE or INACTIVE)?

Again if it gets too complex or if I can easily corrupt the database, I'll stick with the XI GUI.

Thanks.

Re: Nagios XI Import Inactive Hosts

Posted: Fri Feb 13, 2015 1:57 pm
by abrist
toodaly wrote:Again if it gets too complex or if I can easily corrupt the database, I'll stick with the XI GUI.
Honestly, if you do not have experience using sql, I would be wary to help you implement this.

Re: Nagios XI Import Inactive Hosts

Posted: Fri Feb 13, 2015 2:03 pm
by toodaly
OK. Thanks. I'll stick with the XI GUI.

Re: Nagios XI Import Inactive Hosts

Posted: Fri Feb 13, 2015 2:31 pm
by abrist
No problem, I do wish there was an easier way for you.