Nagios doesn’t update the host alias macro – Workaround

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:

  1. Stop Nagios
  2. Make a backup copy of the retention.dat file (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)
  3. Strip all lines starting with “alias” from the backup file and overwrite the original retention.dat file with this data
  4. 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: , ,

  1. 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.

  2. Thank you. Very simple solution, for a “hidden” problem.

  3. u are too good. many tx@martin

  4. 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.

  5. Thanks for pointing me to this retention.dat file.
    Spent some time already. Now wrong aliases are fixed.

Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>