Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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
       address           123.123.123.123
       _IPSNMP        192.168.1.10
}

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/check_snmp_storage.pl '-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

2 Answers 2

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

 
discard

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.