Page 1 of 6

Deactivated Hosts Aren't Removed from Core

Posted: Mon Jan 27, 2014 8:59 pm
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?

Re: Deactivated Hosts Aren't Removed from Core

Posted: Mon Jan 27, 2014 9:38 pm
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.

Re: Deactivated Hosts Aren't Removed from Core

Posted: Mon Jan 27, 2014 9:47 pm
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.

Re: Deactivated Hosts Aren't Removed from Core

Posted: Mon Jan 27, 2014 10:55 pm
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.

Re: Deactivated Hosts Aren't Removed from Core

Posted: Mon Jan 27, 2014 11:01 pm
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?

Re: Deactivated Hosts Aren't Removed from Core

Posted: Tue Jan 28, 2014 8:52 am
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...

Re: Deactivated Hosts Aren't Removed from Core

Posted: Tue Jan 28, 2014 8:59 am
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).

Re: Deactivated Hosts Aren't Removed from Core

Posted: Tue Jan 28, 2014 9:09 am
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.

Re: Deactivated Hosts Aren't Removed from Core

Posted: Tue Jan 28, 2014 10:56 am
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.

Re: Deactivated Hosts Aren't Removed from Core

Posted: Tue Jan 28, 2014 11:11 am
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.