0

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.

aseques
  • 718
  • 4
  • 12
  • 28

2 Answers2

0

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

kernelpanic
  • 1,276
  • 1
  • 10
  • 30
0

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.

aseques
  • 718
  • 4
  • 12
  • 28