分类: LINUX
2010-08-13 00:19:20
#!/usr/bin/ksh
banner http://netyu.cublog.cn
if [ $# -ne 2 ] ; then
echo Usage : count.sh parameter1 parameter2 .
echo parameter1 means application name in cs.sh script .
echo parameter2 means the period\(minutes\)
echo example: speed_est.sh saledb 2
echo this means to estimat the pprc speed of saledb in 2 minutes
exit 1
fi
CS_DIR=/opt/ibm/scripts
LSPPRC_PS=lspprc_PS
EXECUTE_CS=--production
if [ ! -e $CS_DIR/cs.sh ] ; then
echo Cannot find cs.sh , please edit this file to redefine the cs.sh directory .
exit 1
fi
if [ ` $CS_DIR/cs.sh $EXECUTE_CS $1 $LSPPRC_PS |grep 'no DSCLI commands found for' |wc -l ` -gt 0 ] ; then
echo cs.sh cannot execute , please check it !
else
result1=0
a=`$CS_DIR/cs.sh -production $1 $LSPPRC_PS |grep , |grep -v Date |grep -v ID |grep -v Full |awk -F, '{print $5}'`
for i in $a
do
result1=`expr $result1 + $i`
done
if [ $result1 -eq 0 ] ; then
echo PPRC of $1 has been finished or no data is modified ,speed estimation is terminated !
exit 1
else
sec=`expr $2 \* 60 `
echo Please wait for $sec\(seconds\) ...
sleep $sec
result2=0
a=`$CS_DIR/cs.sh $EXECUTE_CS $1 $LSPPRC_PS |grep , |grep -v Date |grep -v ID |grep -v Full |awk -F, '{print $5}'`
for i in $a
do
result2=`expr $result2 + $i`
done
if [ $result2 -ge $result1 ] ; then
echo PPRC of $1 is not started or data of being modified is more than that of being transfered , speed estimation is terminated !
exit 1
fi
if [ $result2 -eq 0 ] ; then
echo $1 has been finished in the period ,speed estimation is not quiet correctly !
speed=`echo \($result1 - $result2\)*64/1024/$sec|bc `
echo pprc speed is $speed\(m\)\/sec
else
speed=`echo \($result1 - $result2\)*64/1024/$sec|bc `
remain=`echo $result2*64/1024/1024 |bc `
alltime=`echo $result2*64/1024/$speed | bc `
echo $1 still has $remain\(G\) to be finished and the speed is $speed\(m\)\/second and it will be finished in $alltime\(seconds\) .
fi
fi
fi