Page 1 of 1

Same address different port

Posted: Tue Feb 28, 2012 10:10 am
by Adamba
Hey,

I have 4 servers on a different network then my Nagios server.
Now, I can access nrpe with a VIP and a different port on each server (each port refers to a different server, but i'm using the same address, the VIP's address).
Is there a way in Nagios that I can configure the same address in the hosts.cfg file, for the 4 servers, and add a port configuration or something like that:

Code: Select all

define host{
    use         generic-host
    host_name   server1
    address     192.168.1.4:5667
}

define host{
    use         generic-host
    host_name   server2
    address     192.168.1.4:5668
}
Is there any way I can do something like that?

Re: Same address different port

Posted: Tue Feb 28, 2012 3:46 pm
by scottwilkerson
You could use a custom object variable for each of the hosts.

Like so

Code: Select all

define host{
    use         generic-host
    host_name   server1
    _PORT       5667
    address     192.168.1.4
}

define host{
    use         generic-host
    host_name   server2
    _PORT       5668
    address     192.168.1.4
}
Then make a custom nrpe command like so

Code: Select all

define command {
       command_name                             check_nrpe_customport
       command_line                             $USER1$/check_nrpe -H $HOSTADDRESS$ -p $HOSTPORT$ -t 30 -c $ARG1$ $ARG2$
}
Then you can use the check_nrpe_customport command for these services and they will all use the custom ports.