Same address different port

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Adamba
Posts: 1
Joined: Mon Feb 27, 2012 9:51 am

Same address different port

Post 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?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Same address different port

Post 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.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked