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.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)
- Strip all lines starting with “alias” from the backup file and overwrite the original
retention.dat
file 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.
Recent Comments