configure nrpe(nagios) to listen on different port

Purpose : Some times Isp Or vps provider they block port 5666 Or for any reason if you want to configure nrpe to listen different port example 15666, follow as bellow:

On the Remote host(linux-vps) :

1. Change the Port number in : /etc/xinetd.d/nrpe

# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
        flags           = REUSE
        socket_type     = stream
       port            = 15666
        wait            = no
        user            = nagios
        group           = nagios
        server          = /usr/local/nagios/bin/nrpe
        server_args     = -c /usr/local/nagios/etc/nrpe.cfg --inetd
        log_on_failure  += USERID
        disable         = no
        only_from       = 127.0.0.1 ip.of.nagios.server
}

2. Change port number : vi /etc/services

nrpe            15666/tcp                        # NRPE

3. Change port number in : /usr/local/nagios/etc/nrpe.cfg

server_port=15666

4 . Restart nrpe daemon : service xinetd restart

On the server(nagiosserver) :
Purpose : Example, I have more then 10 linux server. 9 of them listen port 5666 , but only one of them listen port 15666 . So I need to create a different set of commands for nagios server to connect that nrpe client on different port.

1. Create a command in command.cgi file ( /usr/local/nagios/etc/objects/commands.cgi)

#This is slightly modified from check_nrpe command
#Because Vps company they blocked port 5666
#So i had to configure linuxvps server to listen on port  15666, So
#I need to create a different command to connect to different port
 
define command{
command_name check_nrpe_vps
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 15666 -c $ARG1$
}

2. Now call this check_nrpe_vps commands from host definition file
Example : host definition file for linuxvps is : linuxvps.cgi ( /usr/local/nagios/etc/objects/linuxvps.cgi)

   define service{
   use generic-service
   host_name linuxvps
   service_description CPU Load
  check_command check_nrpe_vps!check_load
}

3. now Call this linuxvps.cgi from nagios.cfg file

  cfg_file=/usr/local/nagios/etc/objects/linuxvps.cfg

4. restart the nagios.
So now this nagios server will connect to nrpe client via 15666 port.

Tags:

2 Responses to “configure nrpe(nagios) to listen on different port”

  1. michal says:

    Hi,

    Thanks for Yours HOW TO, but I have one suggestion. We don’t have to configure server xinetd with nrpe. We only need to change option “server_port” in nrpe.cfg file and it is all.

    I had many situation that I had to change standard nrpe port and it’s worked.

  2. Fosiul says:

    ‘@michal ‘

    Hi Michal
    Yes you are true, we don’t have to use Xinetd for nrpe.
    but its an options to secure the nrpe daemon from outsider i.e Daniel server of attack
    why xinetd :
    ref : http://web.archive.org/web/20040607090856/http:/www.xinetd.org/faq.html#why

    Regards
    Fosiul.

Leave a Reply