记录阿里巴巴QA架构组成长点滴。2008年关键词为效率,技术,影响力!QA/测试架构师定义:开发和设计测试框架测试库;纵横全局的考虑产品的功能,设计复杂的测试系统;负责研发某一项特定的测试技术;为公司考虑如何提高测试效率。领导公司测试技术的发展和测试策略上的方向,关注整个公司的测试部门的问题,前瞻性的考虑未来的版本的测试策略和技术。测试架构师计划/设计测试平台,关注着产品的测试过程,提供咨询服务,影响到公司内的测试机构测试社区,以及开发机构等,对产品各个方面施加深远而正确的影响,最终提高整体软件质量。

jmeter资源监控器开发——增加监控数据

上一篇 / 下一篇  2008-07-31 22:14:50 / 个人分类:开源工具与新技术研究

查看( 1367 ) / 评论( 5 )

by jack

    jmeter自带的监控器输出的只有四条曲线,其中health和load曲线还是根据mem和thread算出来的,所以真正意义上输出的数据只有两个而已。显然这远远满足不了我们对性能监控的需要么。

    既然jmeter没有,那我就有用武之地了(要不然要我这QA架构师干啥,哈),于是我自己添了几个,用着还不错,现在把添加一个参数的过程完整叙述如下:

以增加swapout为例,取xml中的currentThreadsBusy作为swapout的值。

蓝色字注明关键点:

Stats.java

增加新的数据解析方法

 

      public static intcalculateSwapout(Status stat) {

             doubleswapout= 0;

             if (stat != null && stat.getConnector().size() > 0) {

                    Connector cntr = (Connector) stat.getConnector().get(0);

                    swapout= cntr.getRequestInfo().getCurrentThreadsBusy();

             }

             return (int)swapout;

      }

 

MonitorStats.java

增加私有静态变量

 

      private static final StringSWAPOUT= "stats.swapout";

 

增加构造函数入参、赋值语句

 

      public MonitorStats(int health, int load, int cpuload, int memload, int threadload, int swapin,int swapout, String host, String port,

                    String protocol, long time) {

             this.setHealth(health);

             this.setLoad(load);

             this.setCpuLoad(cpuload);

             this.setMemLoad(memload);

             this.setThreadLoad(threadload);

             this.setSwapin(swapin);

             this.setSwapout(swapout);

             this.setHost(host);

             this.setPort(port);

             this.setProtocol(protocol);

             this.setTimeStamp(time);

      }

 

增加相应setget方法

 

      public voidsetSwapout(int load) {

             this.setProperty(SWAPOUT, String.valueOf(load));

      }

 

      public intgetSwapout() {

             return this.getPropertyAsInt(SWAPOUT);

      }

 

MonitorModel.java

增加私有变量对象current初始化中MonitorStats实例化的入参

 

      private MonitorStats current = new MonitorStats(0, 0, 0, 0, 0, 0,0, "", "", "", System.currentTimeMillis());

 

增加clearData方法中MonitorStats实例化的入参

 

             current = new MonitorStats(0, 0, 0, 0, 0, 0,0, "", "", "", System.currentTimeMillis());

 

增加相应get方法

 

      public intgetSwapout() {

            return this.current.getSwapout();

      }

 

增加cloneMonitorStats方法的入参

 

      public MonitorStats cloneMonitorStats() {

             return new MonitorStats(current.getHealth(), current.getLoad(), current.getCpuLoad(), current.getMemLoad(),

                           current.getThreadLoad(), current.getSwapin(), current.getSwapout(), current.getHost(), current.getPort(), current.getProtocol(), current

                                         .getTimeStamp());

      }

 

MemoryBenchmark.java

增加main方法中MonitorStats实例化的入参

 

                           MonitorStats mstats = new MonitorStats(Stats.calculateHealth(st), Stats.calculateLoad(st), Stats.calculateCpuLoad(st), Stats

                                         .calculateMemLoad(st), Stats.calculateThreadLoad(st), Stats.calculateSwapin(st), Stats.calculateSwapout(st), "localhost", "8080", "http", System

                                         .currentTimeMillis());

 

MonitorAccumModel.java

增加addSample方法中MonitorStats实例化的入参

 

                             MonitorStats stat = new MonitorStats(Stats.calculateHealth(st), Stats.calculateLoad(st), Stats.calculateCpuLoad(st), Stats

                                           .calculateMemLoad(st), Stats.calculateThreadLoad(st), Stats.calculateSwapin(st), Stats.calculateSwapout(st), surl.getHost(), String.valueOf(surl

                                           .getPort()), surl.getProtocol(), System.currentTimeMillis());

 

增加createNewMonitorModel方法中MonitorStats实例化的入参

 

             MonitorStats stat = new MonitorStats(Stats.DEAD, 0, 0, 0, 0, 0,0, url.getHost(), String.valueOf(url.getPort()), url

                           .getProtocol(), System.currentTimeMillis());

 

MonitorPerformancePanel.java

增加公共静态变量(显示文案和图例,同时增加资源文件中对应项,及相应图片)

 

      public static final String LEGEND_SWAPOUT= JMeterUtils.getResString("monitor_legend_swapout_per");

 

      public static final ImageIcon LEGEND_SWAPOUT_ICON = JMeterUtils.getImage("monitor-yellow-legend.gif");

 

 

资源文件messages.properties

monitor_legend_swapout_per=Swap Out

 

图片文件monitor-yellow-legend.gif

 

增加createLegend方法中的JLabel实例化语句

 

             JLabeljswapout= new JLabel(LEGEND_SWAPOUT);

             jswapout.setFont(plaintext);

             jswapout.setPreferredSize(lsize);

             jswapout.setIcon(LEGEND_SWAPOUT_ICON);

             legend.add(jswapout);

 

MonitorGraph.java

增加私有变量

 

      private booleanSWAPOUT= true;

 

增加相应set方法

 

      public voidsetSwapout(booleanswapout) {

             this.SWAPOUT=swapout;

      }

 

增加drawSample方法中相应绘图语句

 

             if (SWAPOUT) {

                    int swoy = (int) (height - (height * (model.getSwapout() / 10000.0)));

                    int lastswoy = (int) (height - (height * (last.getSwapout() / 10000.0)));

 

                    g.setColor(Color.yellow);

                    g.drawLine(lastx, lastswoy, xaxis, swoy);

             }

 

 


TAG: 开源工具与新技术研究

小葱拌豆腐 caiw0418 发布于2011-04-29 17:23:03
感谢jacky的分享。
liran_04的个人空间 liran_04 发布于2012-08-17 14:27:36
感谢jacky的分享。
leagend发布于2012-09-06 15:01:24
附件?
tianhouyin发布于2012-12-26 10:37:27
为什么我看不到附件??
wangfei1129的个人空间 wangfei1129 发布于2013-04-23 14:55:00
附件看不见呀
我来说两句

(可选)

日历

« 2024-04-20  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 154242
  • 日志数: 163
  • 文件数: 1
  • 建立时间: 2008-02-26
  • 更新时间: 2008-12-10

RSS订阅

Open Toolbar