Since the upgrade to version 3.2.2 Nagios does not update the host alias macro when the configuration is reloaded. Macros are the variables used in commands, such as notification commands, i.e. the information you receive via E-mail when there is a problem with your hosts or services.
As long as you don’t change your host alias information you will never notice. I did change it and I found myself scratching my head for some time, especially since the same information does get updated in the web interface.
I found a greater number of forum discussions relating to this, but none seemed to offer a practical solution for larger scale environments.
After some pondering I came up with these lines:
service nagios stop cp /usr/local/nagios/var/retention.dat /usr/local/nagios/var/retention.bak grep -v ^alias /usr/local/nagios/var/retention.bak > /usr/local/nagios/var/retention.dat service nagios start
They do the trick in my installations.
Update: Here’s a brief summary of the error and what the script does to work around it.
When Nagios parses the configuration and finds a new host it loads the
alias field into memory. When Nagios reloads the configuration, the
alias information that is already in memory does not get updated. When Nagios stops (or before reloading the configuration) the
alias information in memory is dumped to the
retention.dat file. When Nagios isn’t running and you start the service, it doesn’t load the
alias information from the configuration files but from
retention.dat, unless that information is not present in the file. So my solution does the following:
- Stop Nagios
- Make a backup copy of the
retention.datfile (Note: I’m copying the file instead of renaming it to make sure that it will still have the same owner/group and permissions when I write to the original file in the next step)
- Strip all lines starting with “alias” from the backup file and overwrite the original
retention.datfile with this data
- Start Nagios
You may have to tweak the file location for the
retention.dat and backup files. You may also need to change the commands that stop and start the Nagios deamon.
Tags: bash, nagios, workaround
Thank you Martin! I’d just begun to experience this issue with our Nagios installation. Your effort and your explanation of the issue are both appreciated.
Thank you. Very simple solution, for a “hidden” problem.
u are too good. many tx@martin
Cool ! thank you saved me a lot of struggle
Thank you for this!
I have been editing the host alias for a very long time now (years) and never took to the time to find a solution for why editing doesn’t seem to cause nagios to get the new information even after restarting nagios.
Google and you to the rescue.
Thanks for pointing me to this retention.dat file.
Spent some time already. Now wrong aliases are fixed.
Comments feed for this article
Trackback link: https://ten-fingers-and-a-brain.com/2011/10/nagios-doesnt-update-the-host-alias-macro-–-workaround/trackback/