码迷,mamicode.com
首页 > 其他好文 > 详细

jmeterPlugin CMD命令行生成png图片及csv统计文件

时间:2019-05-14 16:30:00      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:linux环境   cond   linux   功能   响应   NPU   org   mdr   复制   

Jmeter是个纯java的开源的轻量级性能测试工具,功能强大。因为是轻量级的,与loadrunner相比,报告统计的相对较少。不过有jmeter的插件-JMeterPlugins,可以提供不少其他的报告,包括各种响应时间、吞吐率、线程等的变化曲线等

并且这个插件提供了命令行工具,可以将我们看到的各种曲线,各种报告统计成png图片,或者csv文件。这样我们就完全可以通过命令行来运行jmeter,生成jtl文件,然后在解析jtl文件,产生各种报告,或者展示到网页,或者插入到数据库,等等。

英文地址:http://jmeter-plugins.org/wiki/JMeterPluginsCMD/

安装

下载JMeterPlugins-Standard-1.2.0.zip和JMeterPlugins-Extras-1.2.0.zip,解压将里面的jar包复制到jmeter的lib/ext文件夹中即可。

用法

生成png图片:

java -jar $CMDRunnerPath/CMDRunner.jar --tool Reporter --generate-png ThreadsStateOverTime.png

--input-jtl 1.jtl --plugin-type ThreadsStateOverTime

生成csv图片:

java -jar $CMDRunnerPath/CMDRunner.jar --tool Reporter --generate-csv ThreadsStateOverTime.csv --input-jtl 1.jtl --plugin-type ThreadsStateOverTime

当然也可以一次性生成两个文件。下面是改命令的参数:

–generate-png 指定png图片文件
–generate-csv 指定csv文件名
–input-jtl 指定要解析的jtl文件
–plugin-type 指定要输出的数据类型,比如响应时间、cpu使用率、错误率等
Plugin Type Classes
插件提供解析下面这些数据的对象:

AggregateReport = JMeter’s native Aggregate Report, can be saved only as CSV 聚合报告
SynthesisReport = mix between JMeter’s native Summary Report and Aggregate Report, can be saved only as CSV
ThreadsStateOverTime = Active Threads Over Time 线程数随时间的变化曲线
BytesThroughputOverTime 流量随时间的变化曲线
HitsPerSecond 点击率随时间的变化曲线
LatenciesOverTime 延迟随时间的变化曲线
PerfMon = PerfMon Metrics Collector 服务器参数随时间变化曲线注意这个需要在jmx脚本中添加,服务器监控,要指定ip、端口、监控项,还需要指定perfMon的输出文件,或者在命令行指定,如sh jmeter.sh -n -t HTTP请求-baidu.jmx -l 2.jtp -JforcePerfmonFile=true,这样会输出在当前路径。perfmon
ResponseCodesPerSecond 响应码随时间变化曲线
ResponseTimesDistribution 响应时间分布
ResponseTimesOverTime 响应时间随时间变化曲线
ResponseTimesPercentiles 响应时间的百分比
ThroughputVsThreads 吞吐率随线程变化曲线
TimesVsThreads = Response Times VS Threads 响应时间随线程变化曲线
TransactionsPerSecond 事务随时间变化曲线

windows环境.bat文件批处理生成png图片及csv文件

@echo off
   set file=/Users/Desktop/TestLoad/result/result01.jtl

   set ThreadsStateOverTime=/Users/Desktop
   set BytesThroughputOverTime=/Users/Desktop
   set HitsPerSecond=/Users/Desktop
   set LatenciesOverTime=/Users/Desktop
   set ResponseTimesOverTime=/Users/Desktop
   set ResponseCodesPerSecond=/Users/Desktop
   set ResponseTimesDistribution=/Users/Desktop
   set ResponseTimesPercentiles=/Users/Desktop
   set ThroughputVsThreads=/Users/Desktop
   set TimesVsThreads=/Users/Desktop
   set TransactionsPerSecond=/Users/Desktop
   set PageDataExtractorOverTime=/Users/Desktop

   set CMDRunnerPath=/User/Desktop/Cars_key/software/apache-jmeter-4.0/apache-jmeter-4.0/lib/ext
   rem generate png   
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-png %ThreadsStateOverTime%/ThreadsStateOverTime.png --input-jtl  %file% --plugin-type ThreadsStateOverTime  
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-png %BytesThroughputOverTime%/BytesThroughputOverTime.png --input-jtl  %file% --plugin-type BytesThroughputOverTime  
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-png %HitsPerSecond%/HitsPerSecond.png --input-jtl  %file% --plugin-type HitsPerSecond  
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-png %LatenciesOverTime%/LatenciesOverTime.png --input-jtl  %file% --plugin-type LatenciesOverTime  
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-png %ResponseCodesPerSecond%/ResponseCodesPerSecond.png --input-jtl  %file% --plugin-type ResponseCodesPerSecond  
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-png %ResponseTimesDistribution%/ResponseTimesDistribution.png --input-jtl  %file%  --plugin-type ResponseTimesDistribution  
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-png %ResponseTimesOverTime%/ResponseTimesOverTime.png --input-jtl  %file% --plugin-type ResponseTimesOverTime  
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-png %ResponseTimesPercentiles%/ResponseTimesPercentiles.png --input-jtl  %file% --plugin-type ResponseTimesPercentiles  
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-png %ThroughputVsThreads%/ThroughputVsThreads.png --input-jtl  %file% --plugin-type ThroughputVsThreads  
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-png %TimesVsThreads%/TimesVsThreads.png --input-jtl  %file%  --plugin-type TimesVsThreads  
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-png %TransactionsPerSecond%/TransactionsPerSecond.png --input-jtl  %file% --plugin-type TransactionsPerSecond  
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-png %PageDataExtractorOverTime%/PageDataExtractorOverTime.png --input-jtl  %file%  --plugin-type PageDataExtractorOverTime     
   rem generate csv
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-csv %ThreadsStateOverTime%/ThreadsStateOverTime.csv --input-jtl  %file% --plugin-type ThreadsStateOverTime
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-csv %BytesThroughputOverTime%/BytesThroughputOverTime.csv --input-jtl  %file%  --plugin-type ThreadsStateOverTime
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-csv %HitsPerSecond%/HitsPerSecond.csv --input-jtl  %file%  --plugin-type BytesThroughputOverTime
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-csv %LatenciesOverTime%/LatenciesOverTime.csv --input-jtl  %file%  --plugin-type HitsPerSecond
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-csv %ResponseCodesPerSecond%/ResponseCodesPerSecond.csv --input-jtl  %file%  --plugin-type LatenciesOverTime
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-csv %ResponseTimesDistribution%/ResponseTimesDistribution.csv --input-jtl  %file%  --plugin-type ResponseCodesPerSecond
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-csv %ResponseTimesOverTime%/ResponseTimesOverTime.csv --input-jtl  %file%  --plugin-type ResponseTimesDistribution
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-csv %ResponseTimesPercentiles%/ResponseTimesPercentiles.csv --input-jtl  %file%  --plugin-type ResponseTimesOverTime
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-csv %ThroughputVsThreads%/ThroughputVsThreads.csv --input-jtl  %file%  --plugin-type ResponseTimesPercentiles
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-csv %TimesVsThreads%/TimesVsThreads.csv --input-jtl  %file%  --plugin-type ThroughputVsThreads
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-csv %TransactionsPerSecond%/TransactionsPerSecond.csv --input-jtl  %file%  --plugin-type TimesVsThreads
   java -jar %CMDRunnerPath%/CMDRunner.jar  --tool Reporter --generate-csv %PageDataExtractorOverTime%/TransactionsPerSecond.csv --input-jtl  %file%  --plugin-type TransactionsPerSecond

Linux环境.sh脚本生成png图片及csv文件

#!/bin/sh  
   file= /Users/Desktop/TestLoad/result/result01.jtl

   CMDRunnerPath=/User/Desktop/software/apache-jmeter-4.0/apache-jmeter-4.0/lib/ext 

   #generate png  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-png ${file%.*}_ThreadsStateOverTime.png --input-jtl  $file  --plugin-type ThreadsStateOverTime  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-png ${file%.*}_BytesThroughputOverTime.png --input-jtl  $file  --plugin-type BytesThroughputOverTime  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-png ${file%.*}_HitsPerSecond.png --input-jtl  $file  --plugin-type HitsPerSecond  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-png ${file%.*}_LatenciesOverTime.png --input-jtl  $file  --plugin-type LatenciesOverTime  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-png ${file%.*}_ResponseCodesPerSecond.png --input-jtl  $file  --plugin-type ResponseCodesPerSecond  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-png ${file%.*}_ResponseTimesDistribution.png --input-jtl  $file  --plugin-type ResponseTimesDistribution  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-png ${file%.*}_ResponseTimesOverTime.png --input-jtl  $file  --plugin-type ResponseTimesOverTime  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-png ${file%.*}_ResponseTimesPercentiles.png --input-jtl  $file  --plugin-type ResponseTimesPercentiles  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-png ${file%.*}_ThroughputVsThreads.png --input-jtl  $file  --plugin-type ThroughputVsThreads  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-png ${file%.*}_TimesVsThreads.png --input-jtl  $file  --plugin-type TimesVsThreads  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-png ${file%.*}_TransactionsPerSecond.png --input-jtl  $file  --plugin-type TransactionsPerSecond  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-png ${file%.*}_PageDataExtractorOverTime.png --input-jtl  $file  --plugin-type PageDataExtractorOverTime 
   #generate csv  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-csv ${file%.*}_AggregateReport.csv --input-jtl  $file  --plugin-type AggregateReport  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-csv ${file%.*}_ThreadsStateOverTime.csv --input-jtl  $file  --plugin-type ThreadsStateOverTime  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-csv ${file%.*}_BytesThroughputOverTime.csv --input-jtl  $file  --plugin-type BytesThroughputOverTime  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-csv ${file%.*}_HitsPerSecond.csv --input-jtl  $file  --plugin-type HitsPerSecond  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-csv ${file%.*}_LatenciesOverTime.csv --input-jtl  $file  --plugin-type LatenciesOverTime  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-csv ${file%.*}_ResponseCodesPerSecond.csv --input-jtl  $file  --plugin-type ResponseCodesPerSecond  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-csv ${file%.*}_ResponseTimesDistribution.csv --input-jtl  $file  --plugin-type ResponseTimesDistribution  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-csv ${file%.*}_ResponseTimesOverTime.csv --input-jtl  $file  --plugin-type ResponseTimesOverTime  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-csv ${file%.*}_ResponseTimesPercentiles.csv --input-jtl  $file  --plugin-type ResponseTimesPercentiles  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-csv ${file%.*}_ThroughputVsThreads.csv --input-jtl  $file  --plugin-type ThroughputVsThreads  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-csv ${file%.*}_TimesVsThreads.csv --input-jtl  $file  --plugin-type TimesVsThreads  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-csv ${file%.*}_TransactionsPerSecond.csv --input-jtl  $file  --plugin-type TransactionsPerSecond  
   java -jar $CMDRunnerPath/CMDRunner.jar  --tool Reporter --generate-csv ${file%.*}_PageDataExtractorOverTime.csv --input-jtl  $file  --plugin-type PageDataExtractorOverTime  

jmeterPlugin CMD命令行生成png图片及csv统计文件

标签:linux环境   cond   linux   功能   响应   NPU   org   mdr   复制   

原文地址:https://blog.51cto.com/14314637/2394376

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!