centos7 安装jq并获取meanResTime和throughput

用jmeter性能测试之后会产生很多jtl,statistic文件,为了方便做excel表,需要自动读出吞吐率和平均响应时间。

1. 添加epel源

yum install wget
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
yum repolist

或者

yum install epel-release -y
yum list jq
yum install jq -y

2. 安装jq

yum install jq

3. 使用

使用命令如下

jq '.query[0].meanResTime' statistics.json #如果多个query,不知道jmeter中是否允许
jq '.query.meanResTime' statistics.json
jq '.query.throughput' statistics.json

产生的json格式的结果文件如下

{
  "Total" : {
    "transaction" : "Total",
    "sampleCount" : 360001,
    "errorCount" : 360000,
    "errorPct" : 99.999725,
    "meanResTime" : 0.22442993213907703,
    "medianResTime" : 0.0,
    "minResTime" : 0.0,
    "maxResTime" : 246.0,
    "pct1ResTime" : 1.0,
    "pct2ResTime" : 1.0,
    "pct3ResTime" : 1.0,
    "throughput" : 11237.389187164441,
    "receivedKBytesPerSec" : 460.9072605818454,
    "sentKBytesPerSec" : 0.0
  },
  "query" : {
    "transaction" : "prepare select statement with parameter",
    "sampleCount" : 360000,
    "errorCount" : 360000,
    "errorPct" : 100.0,
    "meanResTime" : 0.22441111111111164,
    "medianResTime" : 0.0,
    "minResTime" : 0.0,
    "maxResTime" : 246.0,
    "pct1ResTime" : 1.0,
    "pct2ResTime" : 1.0,
    "pct3ResTime" : 1.0,
    "throughput" : 11288.451287197015,
    "receivedKBytesPerSec" : 463.0028848264401,
    "sentKBytesPerSec" : 0.0
  },
  "get current time" : {
    "transaction" : "get current time",
    "sampleCount" : 1,
    "errorCount" : 0,
    "errorPct" : 0.0,
    "meanResTime" : 7.0,
    "medianResTime" : 7.0,
    "minResTime" : 7.0,
    "maxResTime" : 7.0,
    "pct1ResTime" : 7.0,
    "pct2ResTime" : 7.0,
    "pct3ResTime" : 7.0,
    "throughput" : 142.85714285714286,
    "receivedKBytesPerSec" : 0.0,
    "sentKBytesPerSec" : 0.0
  }
}

  

 

posted @ 2022-09-21 16:49  panda4671  阅读(226)  评论(0编辑  收藏  举报