jmeter参数化部分参考上一篇
shell参数说明:$1线程数,$2:全部并发数rampup时间,$3:脚本持续运行时间,$4:每次脚本循环持续时间 $5:所以循环持续时间
#!/bin/bash
REPORT_TIME=`date ‘+%Y%m%d%H%M%S‘`
jmeter_basedir=/Users/lyh/Desktop/dubbo-performance-testing/apache-jmeter-2.13
report_icon=$jmeter_basedir/extras/collapse.png
WORKSPACE=/Users/lyh/Desktop/script
report_jtl=$WORKSPACE/report/jtl
report_html=$WORKSPACE/report/html
echo "starting..."
cd /Users/lyh/Desktop/script
for v1 in $(ls *.jmx)
do
# REPORT_TIME=`date ‘+%Y%m%d%H%M%S‘`
# TestReport=`ls $v1|sed ‘s/.jmx//g‘`
# echo $TestReport
cd $jmeter_basedir/bin
sh jmeter.sh -JthreadCount=$1 -JRampUp=$2 -JDurationTime=$3 -n -t /Users/lyh/Desktop/script/$v1 -l $report_jtl/TestReport_$REPORT_TIME.jtl &
# >~/logs.log &
# xsltproc $jmeter_basedir/extras/jmeter-results-detail-report_21.xsl $report_jtl/TestReport_$REPORT_TIME.jtl > $report_html/TestReport_$REPORT_TIME.html
# sed -i "s/date not defined/$REPORT_TIME/g" grep “date not defined" -l $report_html/TestReport_$REPORT_TIME.html
# if [! -f "$report_icon"];then
# cp $jmeter_basedir/extras/collapse.png $jmeter_basedir/extras/expand.png $report_html
# fi
# if [! -d "$report_jtl"];then
# cd $WORKSPACE/report && mkdir jtl
# fi
sleep $4
#for id in $(ps -ef|grep jmeter|grep -v grep|awk ‘{print $2}‘)
#do
#echo $id
#kill -9 $id
#done
#sleep 5
done &
sleep $5
xsltproc $jmeter_basedir/extras/jmeter-results-detail-report_21.xsl $report_jtl/TestReport_$REPORT_TIME.jtl > $report_html/TestReport_$REPORT_TIME.html &
sleep 30
for id1 in $(ps -ef|grep JMeter|awk ‘{print $2}‘)
do
echo $id1
kill -9 $id1
done
echo "ending..."
运行命令:sh shell文件名.sh $1 $2 $3 $4 $5
sh -x shell 3 1 30 40 140
运行结果:
在tomcat中打开html结果文件如下: