Is there a way to make comments persist across a restart of Nagios but get removed when a service recovers?
If we select the persistent comment check box when acknowledging a service problem then we seem to be left with a large number of old comments, so when the service fails again some time later (days or weeks in some cases) it is shown with the old comment making our team think that somebody is dealing with issue.
If we uncheck the persistent comment check box then all comments are lost every night when we regenerate our Nagios configuration files and restart Nagios.
Is there a way to make Nagios remove comments when a service recovers but make them persist through a restart?
Nothing springs to mind that will automagically do this, though with a bit of effort you might be able to make use of both the “event handler” and “external commands” functionality and write a script that calls DEL_ALL_SVC_COMMENTS on service recovery. Take a look at the following URLs…
as usual, Strides’ idea is the most logical and thorough (and weirdly, I’m beginning to have the same ideas …)
but, just to be sure:
do you really need to restart nagios every night ?
because you could do a reload, which (as far as I can remember) doesn’t remove the comments (not 100% sure on this one, though)
note: I just tried on my nagios 3.x, and the restart didn’t remove the comment, although I didn’t check the persistent box …quite weird
Thanks for your responses. I’ve just done a quick test here reloading the configuration and it has removed the comments in the same way a restart does. We are currently using version 2.10 so I think I may test with the latest 3.x version before trying to script something. I’ll let you know how I get on.
Yep, you’re right:
with the 2.10 version, the comments are deleted when doing a reload (sorry, I assumed that you were in 3.x too … because I’ve never noticed you could acknowledge alarms with 2.x :))
So yes, upgrading your version could be a solution … but you’ll have to test it (just to let you know: I’m still in 2.x too… I just have one integration server in 3.x to try this new version …)