Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've just migrated from nagios2 to nagios3, basically for the custom macro feature.
In my network there're two kind of servers:

  • Single ip server (the same ip is used both for services and snmp server)
  • Dual ip server (public ip for the services and private ip for the snmp server)

What I try to do is set a default value to the macro $_HOSTIPSNMP$ in the host template ..

define host {
       name linux-server
       _IPSNMP                 $HOSTADDRESS$

I assumed that all the hosts automatically would set $_HOSTIPSNMP$ with the content of $HOSTADDRESS$

If I can get this working, the second part would be to set on a per-host basis custom values for $_HOSTIPSNMP$, in the style of:

define host {
       use linux-server

So $_HOSTIPSNMP$ has always a sane value and I can set it to whatever I want whenever I need.

The error I'm facing is this, it seems that the _HOSTIPSNMP doesn't get replaced properly for the variable value, but instead it gets replaced for the variable name.

cmd=[/usr/lib/nagios/plugins/ '-H' 'HOSTADDRESS'
'-C' 'comunity' '-m' '/' '-w' '80%' '-c' '85%']
output=[ERROR: Unable to resolve UDP/IPv4 address 'HOSTADDRESS'.

I tried changing the quoting of $HOSTADDRESS$ in the template, but nothing I tried worked.

Thanks for your help.

share|improve this question

According to the Nagios documentation on macros, the proper way to reference _IPSNMP defined above would be $_HOSTIPSNMP$

share|improve this answer
After re-reading your post, it sounds like that's what your doing. – kernelpanic Oct 11 '10 at 14:47
I guess I'll have to fill a but in the nagios tracker, cause all the sources seem to indicate that it should work. – Aseques Oct 13 '10 at 8:40
up vote 0 down vote accepted

Well, at the end the only solution for this was to inform on all the hosts the value of _IPSNMP
It seems that the macros aren't resolved recursively and it's the intended behaviour (at least in nagios 3)
At least I was able do what I wanted in a neat way. I'd recommend to everyone to use macros.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.