jmeter生产jtl 和 html

jmeter版本apache-jmeter-5.1.1

设置shell脚本所需入参数据

  1. 设置线程大小 ,${__P(threadCount,)};
  2. 设置运行时间 ,${__P(DurationTime,)};
    设置脚本的入参

文件目录结构:

jmeter.jmx放到下面目录
/home/jmeter/jmxfile/pet/hs.jmx jmeter脚本的路径
/home/jmeter/apache-jmeter-5.1.1/ jmeter安装包路径
/preesstest/ 结果集的目录

设置运行脚本

1.删除原有目录下生成的历史文件或目录
2.运行脚本并生成jtl文件
3.jtl文件生成html目录
4.压缩到指定目录

-----------------------下面是jmeter-run.sh 脚本----------------------------------------------

#!/usr/bin/env bash
set -e
## 如果脚本启动报错syntax error: unexpected end of file
## 请使用vim编辑脚本,退出编辑模式,输入:set ff=unix 将脚本格式改为unix

basePath=/home/jmeter/
cd /home/jmeter/

jmeterHome=$basePath/apache-jmeter-5.1.1/
jmxFilePath=$basePath/jmxfile/pet/
jtlFilePath=$basePath/jmxfile/pet/jtl/
htmlFilePath=$basePath/jmxfile/pet/report/


rm -rf $jtlFilePath/*
rm -rf $basePath/jmeter.log
touch  $basePath/jmeter.log
rm -rf $basePath/error/*


dateStampString=$(date "+%Y%m%d-%H%M")

#获取(脚本信息) cfg.jmx|sim|pet|prod  fileSuffix
jmxName=$1
fileSuffix=$2
threadCount=$3
durationTime=$4

if [[ ! -n "$jmxName"  ]] ; then
   echo "Usage: xxx.sh {cfg.jmx|xx.jmx}"
   exit 0
fi
if [[ ! -n "$fileSuffix"  ]] ; then
   echo "fileSuffix: {hs-acess|mhp-rpc}"
   exit 0
fi

if [[ ! -n "$threadCount"  ]] ; then
   echo "threadCount: {10|200}"
   exit 0
fi

if [[ ! -n "$durationTime"  ]] ; then
   echo "durationTime(s): {10|300}"
   exit 0
fi




rm -rf $jtlFilePath/*
rm -rf $basePath/jmeter.log
touch  $basePath/jmeter.log
rm -rf $basePath/error/*
rm -rf $htmlFilePath/*
#生成具体jtl文件
sh $jmeterHome/bin/jmeter -n -t $jmxFilePath/$jmxName -JthreadCount=$threadCount -JDurationTime=$durationTime -l $jtlFilePath/$jmxName"-press".jtl 
#生成html文件目录
sh $jmeterHome/bin/jmeter.sh -g $jtlFilePath/$jmxName"-press".jtl -o  $htmlFilePath/


echo "靠靠,靠靠靠靠靠"
filename=/presstest/$jmxName"-press-"$dateStampString"["$fileSuffix"].gz"
#tar -czvf $filename $jtlFilePath $jmxFilePath /home/jmeter/jmeter.log
tar -cvf $filename $jtlFilePath $jmxFilePath $basePath/jmeter.log


exit 0

启动命令:
sh /home/jmeter-run.sh hs.jmx hs500 200 200 //hs500结果集压缩包名称 200线程数 200s

在这里插入图片描述
获取执行结果:
/preesstest 目录下,看到*.gz文件
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值