Consultor Eletrônico



Kbase 16498: Script to disconnect users with long open transaction.
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
Script to disconnect users with long open transaction.

INTRODUCTION:
=============

When a Progress client has got a transaction open, either small
or large, no space in the before image is reused causing the bi-
file to grow.

This is an example script to monitor active transactions and
disconnect the user who has a transaction open for a time you
can specify.


# @(#) timeout
DBNAME=sports # Database name
TIMEOUT=30 # Timeout in minutes before disconnecting user
LOOPTIME=300 # Time between checks in seconds

: ${DBNAME?'You must first set DLC'} # Only V7.3C or later and V8

# Calculate minutes
time2min()
{
HOUR=`echo $1 | cut -d: -f1`
MIN=`echo $1 | cut -d: -f2`
MINUTES=`expr $MIN + $HOUR \* 60`
#echo USR=$USR TIME=$TIME HOUR=$HOUR MIN=$MIN MINUTES=$MINUTES

}
> $0.out

while true
do
if [ ! -f "$DBNAME.lk" ]
then
echo $0: ERROR No broker running for database $DBNAME
exit
fi
tput clear
echo "R&D\n1\n4\n3\n\n\n\n\n\n\n\n\n\n\nX\n" |
promon $DBNAME 2>/dev
ull > $0.out

# Only look at local clients. (SELF)
egrep "SELF|Usr" $0.out | sort +7 > $0.out2
date
head -15 $0.out2
echo ---------------------------------------------------------
----------
if [ `wc -l <$0.out2` -lt 2 ]
then
echo No users with open transactions.
echo "Sleep $LOOPTIME seconds...\c" ; sleep $LOOPTIME
continue
fi
USR=`head -1 $0.out2 | awk '{ print $1 }'`
TIME=`head -1 $0.out2 | awk '{ print $7 }'`
time2min $TIME ; MIN1=$MINUTES
time2min `date '+%H:%M'` ; MIN2=$MINUTES
MINDIFF=`expr $MIN2 - $MIN1`
if [ "$MINDIFF" -gt "$TIMEOUT" ]
then
# Disconnect the user now:
echo "Transaction timeout of more then $TIMEOUT min on
user $USR
, initiating disconnect..."
#echo "RETURN\c" ; read ANS
proshut $DBNAME -C disconnect $USR
else
echo "User $USR has open transaction for $MINDIFF minu
te(s)."
fi
echo "Sleep $LOOPTIME seconds...\c" ; sleep $LOOPTIME
done


Note: This script is just an example and therefore not supported
by Progress. Tested with 7.3C, 7.3D and 8.1A.

PJO 7 Jan 1997

Progress Software Technical Support Note # 16498