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?
Deactivated Hosts Aren't Removed from Core
Re: Deactivated Hosts Aren't Removed from Core
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.
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
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.
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
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.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.
Re: Deactivated Hosts Aren't Removed from Core
Is there a way to have XI verify the configuration without applying it to check for errors?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.
-
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
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...
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
That sounds like the step we need to run before clicking Apply Configuration.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...
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
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.Hossy wrote:That sounds like the step we need to run before clicking Apply Configuration.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...
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
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!
Re: Deactivated Hosts Aren't Removed from Core
It actually doesn't make sense. This is what I did: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.
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.