Package: tanktools
Yandex-tank preparephoutfile with statistics after load testing.tanktoolsmodule helps to parse such files and convert to DataFrame.
You can usepandasmodule in manual mode to handle DataFrame
or use build-in functions.Generate Yandex-tank ammo from pcap or har files usingpcap2ammoorhar2ammoscrips. HTTP requests are extracted completely
with headers and body.So you can:calc quantilesget information about timings, latency, status codesextract requests by timestamp, tag and other columnsgroup and analyze specific data like total/partial RPS,
average request/response sizecalc statistical metricsconvert pcap file to ammoconvert har file to ammofilter out and modify requests on ammo generatingInstallationpipinstalltanktoolsExamplesSelect DataFrame by timestampIt is possible to parse a part of staistics by time and overal countfromtanktoolsimportphoutflags={'from_date':'2018-01-18 20:09:50.123','to_date':'2018-01-18 20:10:00.456','limit':100}data=phout.parse_phout('phout.log',flags)print("Total count:%d"%phout.size(data))Total count: 100Print percentilesdata=phout.parse_phout('phout.log')phout.print_quantiles(data,'receive_time')Percentiles for 150030 requests
    from 2018-01-18 20:09:42.983
    to   2018-01-18 20:10:55.108:
quantile (%)  receive_time (mks)
        10.0                   9
        20.0                   9
        30.0                  10
        40.0                  10
        50.0                  10
        60.0                  10
        70.0                  11
        80.0                  12
        90.0                  13
        95.0                  14
        98.0                  16
        99.0                  17
        100.0                 716NotePay attention, timings are calculated in microseconds.Print latency mediandata=phout.parse_phout('phout.log')# Convert and print timing in millisecondsprint("\n\nLatency median:%dms"%int(data.latency.median()/1000))Latency median: 30 msGet RPSdata=phout.parse_phout('phout.log')rps=phout.get_rps(data)Print HTTP response statisticsdata=phout.parse_phout('phout.log')phout.print_http_reponses(data)HTTP code   count  percent (%)
     500   83429        56.38
     200   61558        41.60
     502    2944         1.99
       0      41         0.03Select 200 OK responses and print latency mediandata=phout.parse_phout('phout.log')selected_http_responses=data[data.proto_code==200]print("Latency median for 200 OK:%d"%selected_http_responses.latency.median())Latency median for 200 OK: 3539Print average request/response sizeprint("Avg. Request / Response:%d/%dbytes"%(data.size_in.astype(float).mean(),data.size_out.astype(float).mean()))Avg. Request / Response: 364 / 26697 bytesNotePay attention it is required to convert data to float for correct work ofmeanfunctionPrint RPS at Nth requestprint("RPS at request:")chunk_size=int(phout.size(data)/2)forstartinrange(0,phout.size(data),chunk_size):data_subset=phout.subset(data,start,chunk_size)print("\t%s:%.2f"%(start+chunk_size,phout.get_rps(data_subset)))RPS at request:
    73986: 2062.50
    147972: 2530.56pcap2ammoConvert pcap file to Yandex-tank ammopcap2ammofile.pcap73
GET https://rambler.ru/ HTTP/1.1\r\n
Host: rambler.ru\r\n
Content-Length: 0\r\n\r\nCount statistics about HTTP requestspcap2ammo-Sfile.pcapStats:total:1complete:1incorrect:0incomplete:0Print to filepcap2ammo-oout.ammofile.pcapAdd or delete headersApplyed for all requests, containing specified headerspcap2ammo--add-header'Referer: http://domain.com'--add-header'X-Ip: 1.1.1.1'file.pcappcap2ammo--delete-header'Content-Length'file.pcappcap2ammo--delete-header'Connection'--add-header'Connection: keep-alive'file.pcapFilter TCP/IP packetspcap2ammo-f'ip.src==10.10.10.10 and tcp.dport==8080'file.pcapFilter HTTP packetspcap2ammo-F'"rambler.ru" in http.uri'file.pcapYou can use logical expressions in filterspcap2ammo-F'"keep-alive" in http.headers["connection"] or "Keep-alive" in http.headers["connection"]'file.pcapString functions over HTTP headerspcap2ammo-F'"keep-alive" in http.headers["connection"].lower()'file.pcapUse excluding filters alsopcap2ammo-F'"rambler.ru" != http.headers["host"]'file.pcaphar2ammoConvert pcap file to Yandex-tank ammohar2ammofile.har73
GET https://rambler.ru/ HTTP/1.1\r\n
Host: rambler.ru\r\n
Content-Length: 0\r\n\r\nCount statistics about HTTP requestshar2ammo-Sfile.harStats:total:1complete:1incorrect:0incomplete:0Print to filehar2ammo-oout.ammofile.harAdd or delete headersApplyed for all requests, containing specified headershar2ammo--add-header'Referer: http://domain.com'--add-header'X-Ip: 1.1.1.1'file.harhar2ammo--delete-header'Content-Length'file.harhar2ammo--delete-header'Connection'--add-header'Connection: keep-alive'file.harFilter HTTP packetshar2ammo-F'"rambler.ru" in http.uri'file.harYou can use logical expressions and python functions in filtershar2ammo-F'"keep-alive" in http.headers["connection"] or "Keep-alive" in http.headers["connection"]'file.harhar2ammo-F'"keep-alive" not in http.headers["connection"].lower()'file.harPlease, see more information about filters inpcaperpackage description.