» 您尚未 登录   注册 | 社区服务 | FTP中心 | 帮助 | 社区 | 无图版 | 测试百科  | 测试Blog 
软件测试基地论坛 -> 英语天天看 -> JmeterMeter
 XML   RSS 2.0   WAP 

--> 本页主题: JmeterMeter 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题
Fastpoint


该用户目前不在线
级别: 总版主
精华: 44
发帖: 5033
基地声望: 390 点
基地币: 1687 Bug
基地贡献: 0 点
好评度: 15 点
在线时间:818(小时)
注册时间:2005-10-08
最后登录:2008-07-22
查看作者资料 发送短消息 推荐此帖 引用回复这个帖子

JmeterMeter

Summary

I built this set of programs since I run jmeter almost always in non-interactive mode and the measures computed by jmeter itself were insufficient for my tests.

  • Completely dependent on jmeter.log

  • Has several metrics to analyze the performance of jmeter itself and "client-end" measures:

    1. number of active/terminated threads

    2. requests per minute

    3. average response time

    4. average response time across last X% of requests

    5. average response time across last X% of test duration

    6. mean time between consecutive requests (a nice way to know when things are slowing down)

    7. number of waiting requests (request sent but not received response yet)

    8. grouping response times based on URL regex matching (this would require a text file called RequestClasses in the dir where the server program in invoked with each line containing a PERL5 regular expression to match specific URL's)

  • XML of results can be seen at anytime using a simple command: telnet <host_running_jmserver> <port>

  • Results aggregation across hosts running jmeter

  • Dynamic/near-realtime charting of results using a gnuplot script created dynamically

Dependencies

  • XML::Simple

  • Log::Log4perl

  • Data::Dumper

  • DateTime

  • DateTime::Format::Strptime

  • List::Util

  • Gnuplot

Contents

jmeter.pm

Perl package containing the core class definition and algorithms for metrics computation

Gnuplot.pm

A perl wrapper for Gnuplot to automatically generate a gnuplot script from a perl hash.

jmserver.pl

A server program that invokes two threads: one that reads jmeter.log and computes all kinds of metrics; another that is listening to a socket and when a client attempts to read from the socket, spews out an XML containing the results.

jmclient.pl

A client program that reads XML containing measures from one or more servers, aggregates them, dynamically generates a gnuplot script, and runs gnuplot to generate charts.

Architecture and limitations

The core idea behind this is that the server running jmeter should do nothing except just that -- generate load. So aggregation of the various performance measures is done by a single instance of jmclient.pl while there can be one instance of jmserver.pl per jmeter instance, gathering data from the jmeter log.

The code would only work on a linux distro once the dependencies have been installed. But anyone who knows a little perl can port it to other OS's. (A gnuplot port should ofcourse be available on that OS.)

Also, currently, the analysis is restricted to HTTP samples, but again, even that can be easily changed by changing a few lines in the server process.

It is necessary to have the following two settings in jmeter.properties.

log_level.jmeter.protocol.http.sampler.HTTPSampler=DEBUG
log_level.jmeter.threads.JMeterThread=INFO 

The root loglevel should be WARN to save IO overhead within jmeter.

Ofcourse, if you are trying to gather metrics on other samplers (JDBC,..) you should set the corresponding class at DEBUG level.

Communication between the one or more jmserver processes and the single jmclient process happens via an XML string streamed through a network socket on each host.

jmclient aggregates results across servers and can optionally be made to invoke several child processes each of which can gather measures from other sources. For eg., I have a database statistics collector that collects the number of active/idle oracle sessions and the memory used by them to monitor database performance; another program that is invoked as a child that can collect system memory and CPU usage of arbitrary hosts running perhaps the application/database server; and so on.

jmclient then creates a hash of the results and passes the hash to an instance of Gnuplot.pm that as evident, is a wrapper around the unix charting tool, gnuplot. It dynamically creates a gnuplot script the first time it is invoked with the results hash and from then on, keeps including the new results to dynamically generate charts.

Finally, you can create a simple html that shows the charts; I create a table in the html with each column/row corresponding to each test so that test results can be compared.

Usage

Make sure you install all dependencies.

There are some additional monitoring programs that I invoke as part of jmclient.pl. They should be commented out. Read the source code before using it.

On the host that is going to run jmeter:

  1. cd <dir in which jmeter.log will be written>

  2. rm jmeter.log; touch jmeter.log

  3. tail -100f jmeter.log | perl /path/to/jmserver.pl

On the client that is going to aggregate and visualize charts (i strongly recommend this is a different machine)

  1. cd </path/to/results/directory>

  2. mkdir -p <test_name>/figs

  3. cd <test_name>

  4. perl /path/to/jmclient.pl

  5. Create a html pointing to the png files (I create 1 column/row for each test so that I can compare results across tests.)

There will be some files generated in the dir: - stats.dat contains a space delimited text file containing all data which will be used by gnuplot - figs/ contains all .png's containing metrics - .jmclient.run which contains the time at which the test started. this is useful if you kill the test and restart, but want the original stats to be included while charting the new measures - gnuplot is a dynamically generated gnuplot script. this script is generated once per execution of jmclient.pl. For every new stats XML sourced from the servers running jmserver.pl, this is run once.

Once again, make sure you read the source in all files before using. The program will not compile until you install all the dependencies and may have runtime failures too; but they should be easy to fix if you know a little perl or any other language.

I am yet to optimize jmserver -- perl's hashes are not easy on memory, and jmserver takes a tad more CPU than I would've wished. But I will update the source here whenever I have a newer version of the libraries. You can fire comments/questions to the jmeter user mailing list.

Source: JmeterMeter.tgz



可不可不要这么样徘徊在目光内
你会察觉到我根本寂寞难耐
即使千多百个深夜曾在梦境内
我有吻过你这毕竟并没存在

人声车声开始消和逝
无声挣扎有个情感奴隶
是我多么的想她
但我偏偏只得无尽叹谓

其实每次见你我也着迷
无奈你我各有角色范围
就算在寂寞梦内超出好友关系
唯在暗里爱你暗里着迷
无谓要你惹上各种问题
共我道别吧别让空虚使我越轨
[楼 主] | Posted: 2006-06-27 22:14 顶端
Fastpoint


该用户目前不在线
级别: 总版主
精华: 44
发帖: 5033
基地声望: 390 点
基地币: 1687 Bug
基地贡献: 0 点
好评度: 15 点
在线时间:818(小时)
注册时间:2005-10-08
最后登录:2008-07-22
查看作者资料 发送短消息 推荐此帖 引用回复这个帖子



来源:BonoyQa(Bonoy.com)

摘要

我创建这组程序是由于我经常在非交互模式下运行JMeter并且它自己的测量(Measures)对我的测试来说不够用。

* 完全依赖Jmeter 日志
* 有几个指标用来分析JMeter自己的性能和客户端(client users)的测量
- 活动的/结束的线程数
- 每秒请求数
- 平均响应时间
- 最后X%请求的平均响应时间
- 最后X%测试区间的平均相应时间
- 连续请求的平均时间(一个知晓速度下降的好方法)
- 等待请求数(已发出的,但还没有接受到响应的请求)
- 基于URL正则表达式匹配的分组响应时间(这需要一个放在JMeter 服务器被调用的目录里的名称为RequestClasses的文件,这个文件每一行包含一个PERL5 正则表达式用来匹配特定的URL)

* 可以用一个简单的命令看到XML格式的结果:
telnet <host_running_jmserver> <port>

* 跨运行着JMeter的主机的结果聚合
* 使用gnuplot脚本动态创建动态的/接近实时的结果图

依赖

XML::Simple

Log::Log4perl

Data::Dumper

DateTime

DateTime::Format::Strptime

List::Util

Gnuplot

内容

jmeter.pm

包含核心类定义和度量计算算法的Perl包
Perl package containing the core class definition and algorithms for metrics computation

Gnuplot.pm

用于从Perl 哈希表自动生成gnuplot脚本的Gnuplot包装器
A perl wrapper for Gnuplot to automatically generate a gnuplot script from a perl hash.

jmserver.pl

一个服务器程序,调用两个线程:一个读取jmeter.log并计算所有度量;另一个监听一个socket并在有客户端连接的时候发送一个XML格式的结果
A server program that invokes two threads: one that reads jmeter.log and computes all kinds of metrics; another that is listening to a socket and when a client attempts to read from the socket, spews out an XML containing the results.

jmclient.pl

一个客户端程序,从一个或多个服务器读取包含度量信息的XML,聚合他们,动态生成gnuplot脚本,并运行gnuplot来生成图表。
A client program that reads XML containing measures from one or more servers, aggregates them, dynamically generates a gnuplot script, and runs gnuplot to generate charts.

架构和局限

在这个工具中的核心思想是运行JMeter的服务器除了产生压力,别的什么也不做。

The core idea behind this is that the server running jmeter should do nothing except just that -- generate load. So aggregation of the various performance measures is done by a single instance of jmclient.pl while there can be one instance of jmserver.pl per jmeter instance, gathering data from the jmeter log.

The code would only work on a linux distro once the dependencies have been installed. But anyone who knows a little perl can port it to other OS's. (A gnuplot port should ofcourse be available on that OS.)

Also, currently, the analysis is restricted to HTTP samples, but again, even that can be easily changed by changing a few lines in the server process.

It is necessary to have the following two settings in jmeter.properties.

log_level.jmeter.protocol.http.sampler.HTTPSampler=DEBUG
log_level.jmeter.threads.JMeterThread=INFO The root loglevel should be WARN to save IO overhead within jmeter.

Ofcourse, if you are trying to gather metrics on other samplers (JDBC,..) you should set the corresponding class at DEBUG level.

Communication between the one or more jmserver processes and the single jmclient process happens via an XML string streamed through a network socket on each host.

jmclient aggregates results across servers and can optionally be made to invoke several child processes each of which can gather measures from other sources. For eg., I have a database statistics collector that collects the number of active/idle oracle sessions and the memory used by them to monitor database performance; another program that is invoked as a child that can collect system memory and CPU usage of arbitrary hosts running perhaps the application/database server; and so on.

jmclient then creates a hash of the results and passes the hash to an instance of Gnuplot.pm that as evident, is a wrapper around the unix charting tool, gnuplot. It dynamically creates a gnuplot script the first time it is invoked with the results hash and from then on, keeps including the new results to dynamically generate charts.

Finally, you can create a simple html that shows the charts; I create a table in the html with each column/row corresponding to each test so that test results can be compared.

使用

确保你安装了所有的依赖包。
我在jmeter.pl中调用了几个其他的监测工具。他们已经被注释掉了。在使用前,请阅读源代码。

在要运行Jmeter的机器上:

1. cd <用来存放jmeter.log的目录>

2. rm jmeter.log; touch jmeter.log

3. tail -100f jmeter.log | perl /path/to/jmserver.pl

在用来聚合和可视化图表的机器上(我强烈建议不要使用同一台机器):

4. cd </path/to/results/directory>

5. mkdir -p <test_name>/figs

6. cd <test_name>

7. perl /path/to/jmclient.pl

8. 创建一个指向png文件的HTML文件(我为每个测试创建一列/行,这样我可以跨测试比较结果。)

There will be some files generated in the dir: - stats.dat contains a space delimited text file containing all data which will be used by gnuplot - figs/ contains all .png's containing metrics - .jmclient.run which contains the time at which the test started. this is useful if you kill the test and restart, but want the original stats to be included while charting the new measures - gnuplot is a dynamically generated gnuplot script. this script is generated once per execution of jmclient.pl. For every new stats XML sourced from the servers running jmserver.pl, this is run once.

Once again, make sure you read the source in all files before using. The program will not compile until you install all the dependencies and may have runtime failures too; but they should be easy to fix if you know a little perl or any other language.

I am yet to optimize jmserver -- perl's hashes are not easy on memory, and jmserver takes a tad more CPU than I would've wished. But I will update the source here whenever I have a newer version of the libraries. You can fire comments/questions to the jmeter user mailing list.

 



可不可不要这么样徘徊在目光内
你会察觉到我根本寂寞难耐
即使千多百个深夜曾在梦境内
我有吻过你这毕竟并没存在

人声车声开始消和逝
无声挣扎有个情感奴隶
是我多么的想她
但我偏偏只得无尽叹谓

其实每次见你我也着迷
无奈你我各有角色范围
就算在寂寞梦内超出好友关系
唯在暗里爱你暗里着迷
无谓要你惹上各种问题
共我道别吧别让空虚使我越轨
[1 楼] | Posted: 2006-06-27 22:14 顶端

软件测试基地论坛 -> 英语天天看




软件测试基地上海测仕信息技术有限公司旗下网站
Copyright © 2005-2007 Cntesting.com, All Rights Reserved
沪ICP备06057721号

Powered by PHPWind Code © 2003-06 PHPWind
Total 0.106033(s) query 5, Time now is:12-02 10:58, Gzip disabled
You can contact us


每日一句:Loading...