Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Since EXECUTE COUNT obtained by V$sysstat is an accumulated value, to obtain the increase per unit time, the unit time increase value = (last value-previous value) must be calculated.

Code Block
languagesql
# gettps.sh
ALTIPID=`ps -ef | grep $USER | grep  "bin/altibase -p boot"  | grep -v grep | awk '{print $2}'`
MAXCOUNT=3
COUNT=0
INTERVAL=30
LOGFILE=altitps.log
 
do_getExecuteCount()
{
is -silent <<EOF
set linesize 1024;
set colsize 50;
set feedback off;
set heading off;
select 'RESULT='||( select count(*) from v\$session )
       ||'=' || ( select count(*) from v\$service_thread )
       ||'=' || ( select sum(value) from v\$sysstat where name in ( 'execute success count','prepare success count','prepare failure count') )
from dual;
EOF
}
 
while [ $COUNT -lt $MAXCOUNT ]
do
ALTICPU=`ps -o pcpu -p $ALTIPID | grep -v CPU`
EXECRESULT=`do_getExecuteCount`
SESSIONCNT=`echo $EXECRESULT | grep "RESULT=" | cut -d'=' -f 2| tr -d ' '`
THREADCNT=`echo $EXECRESULT | grep "RESULT=" | cut -d'=' -f 3 | tr -d ' '`
EXECCNT=`echo $EXECRESULT | grep "RESULT=" | cut -d'=' -f 4 | tr -d ' '`
echo  `date "+%Y%m%d %H%M%S: CPU USAGE="`$ALTICPU" SESSIONCNT=$SESSIONCNT THREADCNT=$THREADCNT EXECCNT=$EXECCNT"
 
sleep  $INTERVAL
COUNT=`expr $COUNT + 1`
done

When the above shell script is executed, the following output can be displayed.

Code Blockpanel

$sh

gettps.sh

20170203

150253:

CPU

USAGE=

12.3

SESSIONCNT=208

THREADCNT=16

EXECCNT=181813


20170203

150323:

CPU

USAGE=

24.8

SESSIONCNT=208

THREADCNT=10

EXECCNT=185834


20170203

150353:

CPU

USAGE=

32.1

SESSIONCNT=212

THREADCNT=15

EXECCNT=189865

......

With the above history information, the user will be able to create a history in the form of a table as follows. It is convenient to use the Excel cell calculation formula for the increment per unit time.

...