Page 1 of 1

connect to address 127.0.0.1 and port 0: Connection refused

Posted: Sat Apr 27, 2024 12:35 am
by pnikhade
Hi All,

Greetings of the day !

I have one RHEL EC2 instance running nginx listening to port 80. I have defined commands and service check in host config file to monitor this host.
After running below command manually, I could see it's working perfectly.

./check_tcp -H 13.233.117.236 -p 80 -w 10 -c 20
TCP OK - 0.001 second response time on 13.233.117.236 port 80|time=0.001162s;10.000000;20.000000;0.000000;10.000000

But on GUI it shows an error like below, i tried to see port 80 is open in firewall so what can be reason here ?

connect to address 127.0.0.1 and port 0: Connection refused.

Below command already defined in commands.cfg,

define command {
command_name check_tcp
command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ $ARG2$
}

On host nrpe.cfg, defined below command,

command[check_tcp]=/usr/local/nagios/libexec/check_tcp -w 10 -c 20

Thanks,
Piyush Nikhade.

Re: connect to address 127.0.0.1 and port 0: Connection refused

Posted: Sat Apr 27, 2024 2:46 am
by kg2857
Try adding $ARG1$ to the command.
command[check_tcp]=/usr/local/nagios/libexec/check_tcp -w 10 -c 20 $ARG1$

Re: connect to address 127.0.0.1 and port 0: Connection refused

Posted: Mon Apr 29, 2024 12:57 am
by pnikhade
Thanks for your response, but it shows status as "Unknown" after modifying the nrpe.cfg on client.

Complete alert as below, looks like that is incorrect syntax.

Current Status: UNKNOWN (for 0d 0h 2m 22s)
Status Information: Usage:
check_tcp -H host -p port [-w <warning time>] [-c <critical time>] [-s <send string>]
[-e <expect string>] [-q <quit string>][-m <maximum bytes>] [-d <delay>]
[-t <timeout seconds>] [-r <refuse state>] [-M <mismatch state>] [-v] [-4
Performance Data: -6] [-j] [-D <warn days cert expire>[,<crit days cert expire>]] [-S <use SSL>] [-E] [-N <server name indication>]
Current Attempt: 3/3 (HARD state)
Last Check Time: 04-29-2024 11:28:46

Re: connect to address 127.0.0.1 and port 0: Connection refused

Posted: Mon Apr 29, 2024 1:53 am
by kg2857
Looks like the plugin wants args in some order. This from the short help output I read...
command[check_tcp]=/usr/local/nagios/libexec/check_tcp $ARG1$ -w 10 -c 20