opinkerfi / adagios

Adagios - Web Based Nagios Configuration
GNU Affero General Public License v3.0
327 stars 75 forks source link

HOSTDISPLAYNAME macro doesn't get translated in the service information command display #500

Closed wasserman closed 9 years ago

wasserman commented 9 years ago

There are times when I use $HOSTDISPLAYNAME$ in a command definition. When I look at the preview under the service information tab the macro's value is absent. The checks from the Nagios side still work as they should.

Example: check_nrpe -H $HOSTDISPLAYNAME$

It would show up like: check_nrpe -H

This works properly with $HOSTALIAS$.
FYI, I've also seen a similar behavior with a custom variable, such as $_HOSTPORT$, in case there is a common cause.

palli commented 9 years ago

The cause for this is that when resolving standard macros (i.e. $HOST* and not $_HOST*) it will default to assuming the macroname is the same as the name of the attribute (i.e. it assumed HOSTDISPLAYNAME -> displayname, when in reality the attribute is called display_name)

There is a list of overrides in Model/macros.py that controls this behavior, but as you can see in the pending pull request the list is fairly short. I added $HOSTDISPLAYNAME$ to the list, but we still have a long way to go before supporting everything that nagios does if you want to help contribute to that list, help is most welcome. Of course it is not documented which of that long list of macros nagios supports while running a check command (for example it does not make sense to use HOSTSTATE in a check command), so this is a little bit of trial and error.

Please update pynag once you see the pull request mentioned in this issue has been merged.

wasserman commented 9 years ago

Thanks for the quick response! Now that I see where the mapping is made, I can certainly make similar fixes when I come across them.

palli commented 9 years ago

Cheers and good luck.