webtest.sh 很不错的WEB服务器压力测试脚本(2)

发表于:2012-04-16来源:linux安全网作者:zhaoyun00点击数: 标签:压力测试
else echo \ ; echo \ file echo 本次下载用了$M 分 $MS 秒 file fi F=`grep fail test.logfor |wc -l ` O=`grep ok test.logfor |wc -l ` echo \ ; echo \ file echo 下载成功 $O 个 file echo \ ; ec

  else

  echo \ ; echo \ >> file

  echo "本次下载用了$M 分 $MS 秒" >>file

  fi

  F=`grep fail test.logfor |wc -l `

  O=`grep ok test.logfor |wc -l `

  echo \ ; echo \ >>file

  echo "下载成功 $O 个" >>file

  echo \ ; echo \ >> file

  echo "下载失败 $F 个" >>file

  fi

  #1$# BTIME=`echo "$TIME*60"|bc`

  MAXTIME=`echo "$MAXTIME*60"|bc` #3^#

  if [ $MODE = SC -o $MODE = SERVER -o $MODE = CLIENT ] ; then

  while [ 1 ]

  do

  #4^#

  grep 1 whstat &>/dev/null

  if [ $? -eq 0 ] ; then

  echo \ ; echo \ >> file

  if [ $MODE = CLIENT ] ; then

  echo \ ; echo \ >> file

  echo "当前模式为 【 $MODE 】 模式" >> file

  fi

  if [ $MODE = SERVER -o $MODE = SC ] ; then

  echo \ ; echo \ >> file

  echo "本次测试的对象链接为 $URL " >> file

  fi

  echo \ ; echo \ >> file

  echo "下载压力测试结果:" >>file

  #5^#

  if [ $MODE = SC -o $MODE = SERVER ] ; then

  OK=`tail -n 1 ok |awk '{print $2}'`

  echo \ ; echo \ >> file

  echo "本次测试共成功启动了 $OK 次进程" >>file

  T=`cat time`

  N=`date +%s `

  if [ $BTIME -lt $MAXTIME -o $NUMBER -lt $MAXNUMBER ] ; then

  S=`echo "$N-$T" |bc`

  M=`echo "scale=1;$S/60"|bc |awk -F. '{print $1}'`

  MS=`echo "scale=1;$S/60"|bc |awk -F. '{print $2*0.01*60}'|awk -F. '{print $1}'`

  if [ $S -lt 60 ] ; then

  echo \ ; echo \ >> file

  echo "本次测试共用了 $S 秒" >>file

  else

  echo \ ; echo \ >> file

  echo "本次下载用了 $M 分 $MS 秒" >>file

  fi

  else

  O=`wc -l ok|awk '{print $1}'`

  L=`echo "$O*3" | bc `

  S=`echo "$N-$T-$L" | bc `

  echo \ ; echo \ >> file

  echo "本次测试共用了 $S 秒" >>file

  echo ; echo ;

  M=`echo "scale=1;$S/60"|bc |awk -F. '{print $1}'`

  MS=`echo "scale=1;$S/60"|bc |awk -F. '{print $2*0.01*60}'|awk -F. '{print $1}'`

  if [ $S -lt 60 ] ; then

  echo \ ; echo \ >> file

  echo "本次测试共用了 $S 秒" >>file

  else

  echo \ ; echo \ >> file

  echo "本次下载用了 $M 分 $MS 秒" >>file

  fi

  fi

  fi

  #5$#

  #6^#

  if [ $GRAPH = ON ] ; then

  if [ $MODE = CLIENT -o $MODE = SC ] ; then

  ESTAB=`wc -l established|awk '{print $1}'`

  AVEESTAB=`cat established | awk -vESTAB="$ESTAB" '{total+=$1}END {print total/ESTAB}'|awk -F. '{print $1}'`

  MEM=`wc -l mem |awk '{print $1}'`

  AVEMEM=`cat mem |awk -vMEM="$MEM" '{total+=$1}END {print total/MEM"%"}' `

  echo \ ; echo \ >>file

  echo "本次测试机器内存平均使用用率为 $AVEMEM " >> file

  CPU=`wc -l cpu |awk '{print $1 }'`

  AVECPU=`cat cpu |grep -v CPU | awk -vCPU="$CPU" '{total+=$1}END {print total/CPU"%"}' `

  echo \ ; echo \ >>file

  echo "本次测试机器CPU平均使用用率为 $AVECPU " >> file

  echo \ ; echo \ >>file

  echo "本次测试平均建立的连接为 $AVEESTAB 个" >> file

  echo \ ; echo \ >>file

  echo "提示:【将文件graph用excel打开,生成折线图.】" >>file

  echo

  echo " $NAME graph " >> graph

  cat ok |awk '{print $2}' | paste -s >> graph

  cat cpu | paste -s >> graph

  cat mem | paste -s >> graph

  cat established |paste -s >> graph

  fi

  fi

  #6$# #7^#

  if [ $MODE = SC -o $MODE = SERVER ] ; then

  #8^#

  if [ $BTIME -lt $MAXTIME -o $NUMBER -lt $MAXNUMBER ] ; then

  sum=`cat sum`

  echo \ ; echo \ >>file

  echo "本次测试共下载了 $sum 次" >> file

  succok=`cat succok`

  echo \ ; echo \ >>file

原文转自:http://www.ltesting.net