#!/bin/sh # This script breaks JMeter JTL output into 1-minute blocks (or larger) # JMeter doesn't display our output too well, but this should help # # Prerequisites: # Unix utilities awk, sed, bc # GNU bash (it might run in ksh also but I haven't tested it) # # FYI timestamps: go to http://en.wikipedia.org/wiki/Unix_timestamp # 600k milliseconds = 10 minutes (jmeter timestamps are millisec from 01 jan 1970) usage="Usage: jtlmin.sh \nSummarizes JMeter JTL output into 1-minute blocks" [ $1 ] || { echo -e $usage; exit 1 ; } echo "Processing $1" # --------------------------------------------------------------------------------------- # pre-process JTL file fl=$1.jtlmin.$$ sed -n '2,$ p' $1 > $fl.a #strip headings sort -o $fl.b $fl.a #sort # chop digits from timestamp to ignore milliseconds and large time intervals cut -c -10,14- $fl.b > $fl # Set up variables for awk routine # can set some variables manually if you like (old functionality) # eg: step=60; start=1158446940; end=1158451080 ustart=`head -1 $fl | cut -c-10` uend=`tail -1 $fl | cut -c-10` start=`echo "$ustart-($ustart%60)"|bc` end=`echo "$uend+60-($uend%60)"|bc` step=60 # put some headings on output file echo "$PWD/$1" > $1.OUT echo "unixtime date time thruput(tpm) avgresponse(ms) maxresponse(ms)" | awk 't="\t" {print $1 t $2 t $3 t $4 t $5 t $6}' >> $1.OUT # --------------------------------------------------------------------------------------- awk_routine() { lastminute=$start thisminute=`echo "$start+$step"|bc` #do throughput calc while [ $thisminute -le $end ] do awk -F',' ' # This script (jtlminav.awk) scans a JTL file for records in a specified interval # and returns record count & average response time. # # Called in this format: # awk -F"," -f {path}/jtlminav.awk lastmin={timestamp1} thismin={timestamp2} {jtl-file-name} # # where {timestamp1} and {timestamp2} specify the interval to scan. # # Returned values: # lastmin value passed in # sumresponse total of response times in the interval # trancount count of records in this interval, ie. throughput # avgresponse average response time BEGIN { avgresponse=0; sumresponse=0; trancount=0; maxresponse=0; } { if(($1 >= lastmin) && ($1 < thismin)) { trancount++ sumresponse += $2 if($2 > maxresponse) { maxresponse = $2 } avgresponse = sumresponse / trancount #debug: print lastmin,thismin,$1,$2,trancount,sumresponse,avgresponse } } END { printf("%d %d %d %d %d",lastmin,sumresponse,trancount,avgresponse,maxresponse); print " ",strftime("%d-%m-%Y %H:%M",lastmin) # ## here endeth the groovy awk routine ## # }' lastmin=$lastminute thismin=$thisminute $fl \ | awk 't="\t" {print $1 t $6 t $7 t $3 t $4 t $5}' lastminute=$thisminute thisminute=`echo "$thisminute+$step"|bc` done #awkroutine=~/bin/jtlminav.awk #awk -F',' -f $awkroutine lastmin=$lastminute thismin=$thisminute $fl \ # | awk 't="\t" {print $1 t $5 t $6 t $3 t $4}' #debug# echo "sh>" $lastminute $thisminute $step $end #datetime=`utime2ymd $lastminute` #mintime=`echo $datetime|awk '{print substr($1,10,2) ":" substr($1,12,2)}'` #echo " $datetime $mintime" # --------------------------------------------------------------------------------------- } awk_routine >> $1.OUT rm -f $fl* exit