Configuring an extra ip for the hosts in nagios 3

monitoringnagiossnmp

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.

Best Answer

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

Related Topic