Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Jay Konigsberg — — source: Informix-list mailing list archive (1991-1998)
I would like opinons and suggestions as to how useful this utility is.
This is a small (rough) utility for finding out why a 4gl/esql program is
running slowly or using excess resources on a Unix system.
Sesmon works on the (posibilly faulty) assumption the the more often a
particular SQL is found to be running, the more likely it is need of tuning.
The Quit signal (3 - Ctrl-\\) is trapped to give an output of usage, or you
may use 'ls' and 'cat' in the DataDir.
Simple algorithum:
- 'awk' is used to strip the query from 'onstat -g sql'
- 'sum' is used to create a unique filename for the sql
- filename formats are [count].[unix sum]
- when the sum generated matches a sum already in the DataDir, the count
is incremented.
#!/bin/ksh
# sesmon - Monitor a session
# Jay Konigsberg
# 9/20/2000
# Tested on Informix 9.20 & 7.31 - AIX 4.3.2 & 4.3.3
# rev 0.3
SessID=${1:-4148655}
PID=$$
WorkFile=~/tmp/.worksql.$PID
DataDir=~/tmp/.sesmon
[ ! -d ~/tmp ] && mkdir ~/tmp
rm -rf $DataDir
mkdir $DataDir
listhigh()
{
print
print -
--------------------------------------------------------------------
for file in $(ls -r $DataDir/*)
do
print ${file##*/}
cat $file
print -
--------------------------------------------------------------------
done | more
print
print -n "Press RETURN to continue: "
read X
}
trap listhigh 3
while :
do
onstat -g sql $SessID | awk 'BEGIN {
TRUE=1;
FALSE=0;
InSQL=FALSE;
}
{
if ( $0 == "Current SQL statement :" )
{
InSQL=TRUE;
continue;
}
if ( length($0) == 0 )
{
InSQL=FALSE;
break;
}
if ( InSQL )
print $0;
}' > $WorkFile
set $(sum $WorkFile)
TheSum=$1
if [ $TheSum != "00000" ]
then
if [ -f $DataDir/[0-9]*\\.${TheSum} ]
then
FileName=$(print $DataDir/[0-9]*\\.${TheSum})
Count=${FileName%\\.*}
Count=${Count##*/}
(( Count=Count+1))
Count=$(printf "%05d" $Count)
rm -f $FileName
FileName=$DataDir/$Count.${TheSum}
else
FileName=$DataDir/00001.${TheSum}
fi
print $1
print $FileName
cat $WorkFile
mv $WorkFile $FileName
fi
sleep 1
done
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.