Problem with check_tcp

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
Vecthor
Posts: 4
Joined: Tue Nov 01, 2011 6:44 am

Problem with check_tcp

Post by Vecthor »

I create a socket on my .net application, listening on port 2001.

On Nagios i create a command with check_tcp using port 2001 and ip of my test machine.

I tested using telnet on another machine and i'm able to create the connection with my test machine using the ip and port 2001, but in nagios i receive these errors:

Host State Information
Host Status: DOWN
Status Information: CRITICAL - Host Unreachable

and

Service State Information
Current Status: UNKNOWN
Status Information: check_tcp: Port must be a positive integer

Does anyone knows what may be?
Last edited by Vecthor on Thu Nov 10, 2011 2:22 pm, edited 1 time in total.
xvvivan
Posts: 8
Joined: Thu Oct 27, 2011 10:31 am
Location: Varese - Italy

Re: Problem with check_tcp

Post by xvvivan »

Hi,

maybe you have an error in your configuration.
Check the port on command line :
$ /usr/local/nagios/libexec/check_tcp -H yourserver -p 2001
If the exit code is correct, you must verify the configuration.
Could you post here the command and the service definition?

I think it looks like this:

Command ->

Code: Select all

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

Code: Select all

define service{
	use		                generic-service
	host_name		yourserver
	service_description	My application [Port 2001]
	check_command	check_tcp!2001
	}
Regards

Ivan
Vecthor
Posts: 4
Joined: Tue Nov 01, 2011 6:44 am

Re: Problem with check_tcp

Post by Vecthor »

I do a review, and it works - thank you ivan -, but now i'm trying to use the param -e:

$ /usr/local/nagios/libexec/check_tcp -H yourserver -p 2001 -e 1

At the first moment i returned 1 and at second moment i returned 0, but the status of this check_tcp doesn't change. I thought if i sent 1 to nagios, it shows ok, and if i sent 0 it shows warning... but doesn't change, i sent a large string and the nagios continue to show status ok.

What can i do to show warning in nagios using the param -e? Exists a way to do that?
xvvivan
Posts: 8
Joined: Thu Oct 27, 2011 10:31 am
Location: Varese - Italy

Re: Problem with check_tcp

Post by xvvivan »

Hi,

I tried the parameter -e on different ports.
I used verbose modality for identify exactly the output:

Code: Select all

$ ./check_tcp -H 127.0.0.1 -p 25 -e 144 -v
Using service TCP
Port: 25
flags: 0x2
server_expect_count: 1
        0: 144
received 91 bytes from host
#-raw-recv-------#
220 localhost.localdomain ESMTP Sendmail 8.14.4/8.14.4; Sat, 5 Nov 2011 20:53:30 +0100

#-raw-recv-------#
looking for [144] anywhere in [220 localhost.localdomain ESMTP Sendmail 8.14.4/8.14.4; Sat, 5 Nov 2011 20:53:30 +0100]
couldn't find it
TCP WARNING - Unexpected response from host/socket: 220 localhost.localdomain ESMTP Sendmail 8.14.4/8.14.4; Sat, 5 Nov 2011 20:53:30 +0100|time=0.002820s;;;0.000000;2.000000
With 1 or 0 the check is OK, I tried with 144 and the plugin show a warning.
Try with parameter -v and see the output. Maybe in your output there are both 1 and 0.

Probably, you should use a different value

Ivan
Locked