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

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

1 Answer 1

You probably have to write your own check script.

Something like this would work:

#!/bin/bash

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

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

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

 
discard

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.