KEBI BLOG

IT,PC,모바일,스마트폰 정보와 팁 그리고 제품리뷰와 생활정보

HP-UX FIN_WAIT_2 제거 script

hp-ux 에서 FIN_WAIT_2 가 발생해 제거가 않될경우 제거해주는 script 입니다.

#!/bin/ksh 
# Hewlett-Packard Corporation 
# This script is UNSUPPORTED.  Use at own risk. 
# @(#)$Revision: 1.3 $   $Author: scotty $   $Date: 98/08/25 17:55:01 $ 
# This script will query the system for any TCP connections that 
# are in the FIN_WAIT_1 state and forcibly disconnect them.  It 
# uses netstat(1) to find the FIN_WAIT_1 connections and calls 
# ndd with the correct hexidecimal representation of the connection 
# to close the connection. 
# Temporary files used to compare netstat output 
MYSCRIPTNAME=${0##*/} 
TMPFILE1=/tmp/hp/$MYSCRIPTNAME.1 
TMPFILE2=/tmp/hp/$MYSCRIPTNAME.2 
PORTNUM=$1
# Create a log file to keep track of connection that were removed 
LOGFILE=/tmp/hp/$MYSCRIPTNAME.log 
function getFinWait2 { 
/usr/bin/printf "%.2x%.2x%.2x%.2x%.4x%.2x%.2x%.2x%.2x%.4x\n" `/usr/bin/netstat -an -f inet | /usr/bin/grep FIN_WAIT_2 |/usr/bin/grep $PORTNUM| /usr/bin/awk '{print $4,$5}' | /usr/bin/sed 's/\./ /g'` > $TMPFILE1

function compareFinWait2 { 

FIRST_TIME=1 
cp $TMPFILE1 $TMPFILE2 
getFinWait1 
comm -12 $TMPFILE1 $TMPFILE2 > $PWD/fin_wait_list
while read CONN 
do 
        echo $CONN
        if [[ $CONN != "000000000000000000000000" ]] 
        then 
                if [ $FIRST_TIME -eq 1 ] 
                then 
                        print >> $LOGFILE 
                        date >> $LOGFILE 
                        FIRST_TIME=0 
                fi 
                print "/usr/bin/ndd -set /dev/tcp tcp_discon_by_addr \"$CONN\"" >> $LOGFILE
                /usr/bin/ndd -set /dev/tcp tcp_discon_by_addr $CONN 
        fi 
done < fin_wait_list

getFinWait2 
# Main 
touch $TMPFILE1 
touch $TMPFILE2 
compareFinWait2


0

Comment *

댓글 달기

6,388,737

전체

551

오늘

4,140

어제

Skin By KEBIBLOG Ver 1.0 Copyright ⓒ KEBI BLOG. All rights reserved.