#!/bin/ksh
#
#  
#
# File        : mon_halftcp.sh
#
# Objective   : Report the number of half closed TCP sessions on a specific port
#
# Argument    : Port number
#
# Returns 1st line : -1      Error detected
#                    >0      Number of half closed TCP sessions 
#
# Date (yyyymmdd)   Who              What
# ---------------   --------------   -------------------------------------------------
# 2006 10 25        Peter van Nes    Initial release


# Assign arguments
PORT=$1

if [[ (-n $PORT) && ($PORT == +([0-9]) ) ]] 
then
  netstat -an -f inet | grep "^tcp.*\.${PORT} " | egrep -cv "ESTABLISHED|LISTEN"
else
  echo "-1" 
  echo "Supply a numeric port number as an argument"
fi



