Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am interested in seeing if clients are connected to us on lets say port 63004. Now check_tcp works well to see if port is available. Unfortunatley I need to know if the port is in a LISTENING state or ESTABLISHED. is it possible to check if the state of the port is ESTABLISHED as we are in a listening state and await clients connecting to us

share|improve this question

You probably have to write your own check script.

Something like this would work:


connections=`netstat -pant | grep :63004 |grep ESTABLISHED |wc -l`

if [ $connections -gt 0 ]; then
  echo -n "There are $connections established"
  exit 0
  echo -n "There are no established connections"
  exit 1

You should, of course, elaborate on the script, and make it something more robust than something slapped together in a couple minutes to answer a Serverfault question.

share|improve this answer
Thanks cjc. I figured scripting it would cover my needs. – tal Jun 26 '12 at 18:51

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.