Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a problem with Nagios, and in particular with the check_tcp plugin, used to check the Citrix connection on a Windows server. Nagios is in version 3.3.1 and nagios plugins are in version 1.4.15 (which seems to be the last ones).

When the connection is OK, the service's status is OK with Status Information saying : "TCP OK". But when the Citrix service is not responding, the service's status is still OK with Status Information saying : "Connection refused", which indicate clearly that the Citrix connection is not OK.

One more thing, when launching the check command by hand it returns 0, which explains the OK status on the web interface, while it must returns 1 or something else to indicate the error.

Did someone already have the same problem ? And is there something that I can do to correct this check ?

Thanks in advance,


share|improve this question
can you give me the command as executed by your server? –  Lucas Kauffman Mar 12 '12 at 10:26

2 Answers 2

up vote 2 down vote accepted

I'm not sure we know enough about the problem to be definitive. This isn't normal behaviour for the check_tcp plugin:

[madhatta@nagios plugins]$ ./check_tcp -H localhost -p 1234
Connection refused
[madhatta@nagios plugins]$ echo $?
[madhatta@nagios plugins]$ 

Can you tell us what happens when you invoke the plugin manually? How is your NAGIOS invoking it right now?

Edit: then you will have to wade through your NAGIOS config, from the check_command entry in the service definition, through the commands definition file, until we know exactly what on-disc command is being run, and with what flags.

Edit 2: I suspect the problem is in the pipeline. I don't know who decided that | sed 's/,/./g' needed to be added, nor why, but the exit status of a pipeline is the exit status of the last command therein. Compare this with the output above:

[madhatta@nagios plugins]$ ./check_tcp -H localhost -p 1234 | sed 's/n/N/g'
CoNNectioN refused
[madhatta@nagios plugins]$ echo $?
[madhatta@nagios plugins]$ 

The sed, being the last command in the pipeline, works fine, so the exit status of the pipeline is 0, meaning "yes, i'm fine", causing NAGIOS to say "yes, everything is fine".

If you feel that you must have that tidying-up, you will need to write a shell script that performs the actual check_tcp, saves the termination status and the output, outputs the output run through sed but terminates with the stored termination status. Better still, stop worrying about dots and commas, and start worrying about whether the server is down or not.

share|improve this answer
the service definition is $USER1$/check_tcp -H $HOSTADDRESS$ -p 1494 -4 -e ICA -w $ARG1$ -c $ARG2$ | sed 's/,/./g' –  Jeremy C. Mar 12 '12 at 11:09
and when i run the command manually I get :Connection refused and $ echo $? returns 0 –  Jeremy C. Mar 12 '12 at 11:10
what an idiot am I ! I really don't know how i didn't see that ! Thank's a lot MadHatter. –  Jeremy C. Mar 12 '12 at 12:31
<GRIN> don't worry Jeremy, it's one of those couldn't-see-the-wood-for-the-trees moments! –  MadHatter Mar 12 '12 at 12:36

Check if on your server you have added -r as an option to the tcp_check command.

 -r, --refuse=ok|warn|crit
    Accept TCP refusals with states ok, warn, crit (default: crit)
share|improve this answer
i don't use the -r option in my command. But, if I put it in the command with --refuse=ok in my case, a normal OK when service will be up would give me a CRITICAL status I think. –  Jeremy C. Mar 12 '12 at 11:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.