Deactivated Hosts Aren't Removed from Core

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Hossy
Posts: 27
Joined: Fri Dec 27, 2013 12:37 pm

Deactivated Hosts Aren't Removed from Core

Post by Hossy »

I'm having an issue where if a previously active host is changed to deactivated (Active=No), when you apply the configuration, the /usr/local/nagios/etc/hosts/<host>.cfg files are not deleted.

If I create a new host and leave Active=No, the /usr/local/nagios/etc/hosts/<host>.cfg file is never created (as I would expect).

How can I make XI clean up the CFG files for deactivated hosts?
Hossy
Posts: 27
Joined: Fri Dec 27, 2013 12:37 pm

Re: Deactivated Hosts Aren't Removed from Core

Post by Hossy »

More information:

This seems to only occur when the verification portion of "Apply Configuration" fails the first time. Even if you correct the error (in my case, remove the deactivated host from an active service) and apply the configuration again (succeeding this time), the CFG files will not be deleted.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Deactivated Hosts Aren't Removed from Core

Post by scottwilkerson »

One thing to point out, if Apply Configuration fails, XI automatically restores the last known good configuration (which could include the deactivated hosts).

This is a mechanism to make sure your system will continue monitoring if someone tries to apply a bad configuration.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Hossy
Posts: 27
Joined: Fri Dec 27, 2013 12:37 pm

Re: Deactivated Hosts Aren't Removed from Core

Post by Hossy »

scottwilkerson wrote:One thing to point out, if Apply Configuration fails, XI automatically restores the last known good configuration (which could include the deactivated hosts).

This is a mechanism to make sure your system will continue monitoring if someone tries to apply a bad configuration.
That's fine, but the configuration didn't revert (at least not in XI). It still showed the deactivated hosts as deactivated. On the subsequent Apply Configuration application, it didn't delete the CFG files.
Hossy
Posts: 27
Joined: Fri Dec 27, 2013 12:37 pm

Re: Deactivated Hosts Aren't Removed from Core

Post by Hossy »

scottwilkerson wrote:One thing to point out, if Apply Configuration fails, XI automatically restores the last known good configuration (which could include the deactivated hosts).

This is a mechanism to make sure your system will continue monitoring if someone tries to apply a bad configuration.
Is there a way to have XI verify the configuration without applying it to check for errors?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Deactivated Hosts Aren't Removed from Core

Post by scottwilkerson »

Yes.

Configure -> Core Config Manager -> Tools -> Write Config Files
Write - Will write the current config file from the DB to disk
Verify - Will verify the configuration
Restart - Will restart Nagios with the new configuration.

Do not do the restart if you have errors, or monitoring will stop...
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Hossy
Posts: 27
Joined: Fri Dec 27, 2013 12:37 pm

Re: Deactivated Hosts Aren't Removed from Core

Post by Hossy »

scottwilkerson wrote:Yes.

Configure -> Core Config Manager -> Tools -> Write Config Files
Write - Will write the current config file from the DB to disk
Verify - Will verify the configuration
Restart - Will restart Nagios with the new configuration.

Do not do the restart if you have errors, or monitoring will stop...
That sounds like the step we need to run before clicking Apply Configuration.

But back to the verification failing with Apply Configuration, why would the CFG files not be deleted on the second run if the verification failed? I would think that when I click Apply Configuration, it would first verify the config. If that passes, then it would proceed. If that fails, it would report back making no changes to the system and remember the work it still needs to do (i.e. delete CFG files for deactivated hosts).
Hossy
Posts: 27
Joined: Fri Dec 27, 2013 12:37 pm

Re: Deactivated Hosts Aren't Removed from Core

Post by Hossy »

Hossy wrote:
scottwilkerson wrote:Yes.

Configure -> Core Config Manager -> Tools -> Write Config Files
Write - Will write the current config file from the DB to disk
Verify - Will verify the configuration
Restart - Will restart Nagios with the new configuration.

Do not do the restart if you have errors, or monitoring will stop...
That sounds like the step we need to run before clicking Apply Configuration.

But back to the verification failing with Apply Configuration, why would the CFG files not be deleted on the second run if the verification failed? I would think that when I click Apply Configuration, it would first verify the config. If that passes, then it would proceed. If that fails, it would report back making no changes to the system and remember the work it still needs to do (i.e. delete CFG files for deactivated hosts).
Well, it seems that running the Verify first doesn't exactly work... I just tested it by deactivating a host that I know would cause a problem. I ran Verify and it (correctly) identified that there was a configuration error. I then activated the host again and reran Verify, but it still complained that the same host was missing. I ran Apply Configuration despite the Verify telling me there was an error and Apply Configuration succeeded.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Deactivated Hosts Aren't Removed from Core

Post by lmiltchev »

When you make changes in the CCM, and you want to verify your configs via the "Write Config Tool" you must click on the "Write" button first, then click on the "Verify" button. Clicking on the "Verify" button ONLY will not do anything for you, because the changes that you made in the database have to be written to configs, then verified. I hope this makes sense.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Hossy
Posts: 27
Joined: Fri Dec 27, 2013 12:37 pm

Re: Deactivated Hosts Aren't Removed from Core

Post by Hossy »

lmiltchev wrote:When you make changes in the CCM, and you want to verify your configs via the "Write Config Tool" you must click on the "Write" button first, then click on the "Verify" button. Clicking on the "Verify" button ONLY will not do anything for you, because the changes that you made in the database have to be written to configs, then verified. I hope this makes sense.
It actually doesn't make sense. This is what I did:

1. Ran "Verify" to confirm the unchanged config was valid. It was.
2. Deactivated a host that I knew would make the config invalid.
3. Ran "Verify" to confirm the config showed as invalid. It did.
4. Activated the host.
5. Ran "Verify" to confirm the config was valid again. It still reported the same error as in step 3.
Locked