DSMARWAY, thank you
for the helpful information.
Here's is the script I am using
which monitors connections to Iplanet webservers.
Robert
!/usr/bin/ksh
# webserver status
# 7/22/2002
# Version 1.0
# Author: Robert G. Jordan x2335
# monitor iplanet webservers
# requires lsof utility
clear
LSOF='/usr/local/bin/lsof -V'
EXIT=false
TMP=/tmp/TMP.file.$$
HOST_NAME=`uname -n`
IP=`/usr/bin/nslookup $HOST_NAME|grep "Address:"|tail -1|awk '{print $2}'`
clear
echo "Working..."
$LSOF|grep TCP|grep httpd|grep LISTEN|awk '{print $2,$3,$9}'|sort -u > $TMP.ws_info
until [ "$EXIT" = "true" ]
do
TIME=`/usr/bin/date`
echo " $TIME" >> $TMP.output
echo " $HOST_NAME" >> $TMP.output
echo " $IP" >> $TMP.output
cat $TMP.ws_info|while read WS_INFO
do
WS_PID=`echo $WS_INFO|awk '{print $1}'`
WS_OWNER=`echo $WS_INFO|awk '{print $2}'`
WS_PORT=`echo $WS_INFO|awk '{print $3}'|awk -F : '{print $2}'`
if [ "$WS_PORT" = "http" ]
then
WS_PORT=80
fi
WS_NAME=`ps -ef|grep httpd|grep " $WS_PID "|awk -F https- '{print $2}'|awk -F "/config" '{print $1}'`
netstat -an|grep "$WS_PORT "|egrep "CLOSE_WAIT|ESTABLISHED|FIN_WAIT_1|FIN_WAIT_2|TIME_WAIT" > $TMP.netstat
ESTABLISHED=`cat $TMP.netstat|grep ESTABLISHED|wc -l`
TIME_WAIT=`cat $TMP.netstat|grep TIME_WAIT|wc -l`
FIN_WAIT_1=`cat $TMP.netstat|grep FIN_WAIT_1|wc -l`
FIN_WAIT_2=`cat $TMP.netstat|grep FIN_WAIT_2|wc -l`
CLOSE_WAIT=`cat $TMP.netstat|grep CLOSE_WAIT|wc -l`
echo " ----------------------------------------" >> $TMP.output
echo " Webserver:\t\t$WS_NAME" >> $TMP.output
echo " Port:\t\t\t$WS_PORT" >> $TMP.output
echo " PID:\t\t\t$WS_PID" >> $TMP.output
echo " Owner:\t\t\t$WS_OWNER" >> $TMP.output
echo " CONNECTIONS" >> $TMP.output
echo " Established:\t\t$ESTABLISHED" >> $TMP.output
echo " Time_Wait:\t\t$TIME_WAIT" >> $TMP.output
echo " Fin_Wait_1:\t\t$FIN_WAIT_1" >> $TMP.output
echo " Fin_Wait_2:\t\t$FIN_WAIT_2" >> $TMP.output
echo " Close_Wait:\t\t$CLOSE_WAIT" >> $TMP.output
done
clear
cat $TMP.output
> $TMP.output
echo;echo " press Ctrl-c to exit"
sleep 2
done
----------------------------------------
Webserver: prods
Port: 443
PID: 10360
Owner: intranet
CONNECTIONS
Established: 1
Time_Wait: 23
Fin_Wait_1: 0
Fin_Wait_2: 0
Close_Wait: 0
----------------------------------------
Webserver: intranet
Port: 80
PID: 2005
Owner: intranet
CONNECTIONS
Established: 1
Time_Wait: 0
Fin_Wait_1: 0
Fin_Wait_2: 0
Close_Wait: 0
----------------------------------------
Webserver: admserv
Port: 8888
PID: 2205
Owner: root
CONNECTIONS
Established: 0
Time_Wait: 0
Fin_Wait_1: 0
Fin_Wait_2: 3
Close_Wait: 0
----------------------------------------
Webserver: usanet
Port: 445
PID: 22315
Owner: intranet
CONNECTIONS
Established: 0
Time_Wait: 0
Fin_Wait_1: 0
Fin_Wait_2: 0
Close_Wait: 0
Robert G. Jordan
Unix Sys Admin
Sleepy Hollow, Illinois U.S.A.
FREE Unix Scripts