Nagios XI Import Inactive Hosts

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
toodaly
Posts: 63
Joined: Wed Jun 19, 2013 3:39 pm

Nagios XI Import Inactive Hosts

Post 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?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios XI Import Inactive Hosts

Post by abrist »

How are you importing the hosts?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
toodaly
Posts: 63
Joined: Wed Jun 19, 2013 3:39 pm

Re: Nagios XI Import Inactive Hosts

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios XI Import Inactive Hosts

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
toodaly
Posts: 63
Joined: Wed Jun 19, 2013 3:39 pm

Re: Nagios XI Import Inactive Hosts

Post 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.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios XI Import Inactive Hosts

Post 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?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
toodaly
Posts: 63
Joined: Wed Jun 19, 2013 3:39 pm

Re: Nagios XI Import Inactive Hosts

Post 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.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios XI Import Inactive Hosts

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
toodaly
Posts: 63
Joined: Wed Jun 19, 2013 3:39 pm

Re: Nagios XI Import Inactive Hosts

Post by toodaly »

OK. Thanks. I'll stick with the XI GUI.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios XI Import Inactive Hosts

Post by abrist »

No problem, I do wish there was an easier way for you.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked