java性能监控工具MoSKito学习--MoSKito-Essential模块5

》 Accumulators 收集器
What is an Accumulator? 什么是收集器
一个收集器是一个值的收集者对于给出的区间,生产者,状态和值。
收集器收集和存储数据,那就是他们不同于生产者的地方。生产者只是对最近产生的动作展示数据,而收集器存储了从应用开始监控以后的全部数据。
当然,收集者可以通过图表的形式展示收集到的数据,图表可以帮助你评估你的应用性能通过很长一段时间。
例如:
我们依然监控我们应用中的session数。
这个收集器,和生产者关联,将会收集关于session数量的信息,通过你配置的区间(例如5分钟).

更多相关的,所有session信息将会被存储从收集器被创建后开始。如图Accumulators.png所示:


Why We Created Accumulators? 为啥我们创建收集器
MoSKito结构不同于stats的收集,在VM中产生,在其他地方收集。现在,在VM中收集的stats值通常有多个值,当前值和每一个区间的值. 对于一个成熟的系统来说,这个值很快就变的非常大。例如设置了1056个生产者有27067statvalues值和216536个值持有者。每个持有者都持有当前值和每一个区间的值。这个默认是9个值,也就是几乎是2 millions 值存储在系统中.
人们通常抱怨在MoSKito WebUI和内嵌的UI的值中没有时间线。上面的计算十分明确增加至少10个历史值轻松达到 20.000.000. 对于过去的10个历史值你能由50分钟获取,如果你每5分钟收集的话,其实什么也没有。为了有至少一周的历史也就意味着有每5分钟有2016个值 - 我觉得你明白这一点.
然而它对最近的历史值有用,这就是MoSKito收集器的作用。
Adding an Accumulator 添加一个收集器
收集器可以被添加或者定义如下:
  》programmatically by code,以编程方式实现
  》programmatically by annotations,以注解方式实现
  》by configuration or via WebUI. 通过配置或者通过WebUI来完成
Via WebUI 通过WebUI
有两种方法可以通过WebUI来添加一个收集器,对于最终的用户来说;然而,他们中的一个正在开发中,所以我们专注于工作中的一个。
To add an accumulator via WebUI:
首先,你应该知道你要统计什么。比方说我们想要统计每5分钟创建的session数。
  1,来到Producers tab 页.

  2,找到并点击生产者 (Session统计对于我们来说是)。如图Click_Producer1.png所示:


  3,在出现的生产者页,单击Add Accumulator按钮(在右上角)。如图CreateAccumulator_button.png所示:


  4,在新出现的Accumulatorbox内:
      i,输入名字(Name box)
      ii,选择要监视的区间(interval menu)
      iii,选择测量单元(Unit menu)

   如图NewAccumulator_Box.png所示


  5,在Stats和Values表(在新 Accumnlator box下面),选择要监视的值(对我们来说是New)并单击正确的ADD链接。

  如图ChooseParamater.png所示。


  恭喜,一个新的收集器已经添加了。
  你将重定向到Accumulators页,你能够查看你新添加的收集器。
Config 配置
添加一个收集器最容易的方式是使用MoSKito的配置:
MoSKito-Essential Configuration Guide#Accumulators
Programmatically  代码
为了完成一个收集器的添加,你需要创建一个 AccumulatorDefinition.这是一个例子的代码:


AccumulatorDefinition definition = new AccumulatorDefinition();
definition.setName(name);
definition.setProducerName(producerName);
definition.setStatName(statName);
definition.setValueName(valueName);
definition.setIntervalName(intervalName);


Accumulator acc = AccumulatorRepository.getInstance().createAccumulator(definition);
我们提供了一个方便的类net.anotheria.moskito.core.accumulation.Accumulators ,其中有一些常用的创建收集器的方法.
static Accumulator  createAccumulator(java.lang.String name, java.lang.String producerName, java.lang.String statName, java.lang.String valueName, java.lang.String intervalName)
Creates a new accumulator.


static Accumulator  createMemoryAccumulator(java.lang.String name, java.lang.String producerName, java.lang.String valueName, java.lang.String interval)
Create a new memory pool value accumulator.


static Accumulator  createMemoryAccumulator1m(java.lang.String name, java.lang.String producerName, java.lang.String valueName)
Create a new memory pool value accumulator for 1m interval.


static Accumulator  createMemoryAccumulator5m(java.lang.String name, java.lang.String producerName, java.lang.String valueName)
Create a new memory pool value accumulator for 5m interval.


static void createServiceAVGAccumulator(java.lang.String name, java.lang.String producerName)
Creates a new accumulator for service average response time measurement.


static void createServiceAVGAccumulator(java.lang.String name, java.lang.String producerName, java.lang.String interval)
Creates a new accumulator for service average response time measurement.


static void createServiceREQAccumulator(java.lang.String name, java.lang.String producerName)
Creates a new accumulator for service req count.


static void createServiceREQAccumulator(java.lang.String name, java.lang.String producerName, java.lang.String interval)
Creates a new accumulator for service req count.


static void createUrlAVGAccumulator(java.lang.String name, java.lang.String url)
Creates a new accumulator for avg response time of the url.


static void createUrlAVGAccumulator(java.lang.String name, java.lang.String url, java.lang.String interval)
Creates a new accumulator for avg response time of the url.


static void createUrlREQAccumulator(java.lang.String name, java.lang.String url)
Creates a new accumulator for request count of the url.


static void createUrlREQAccumulator(java.lang.String name, java.lang.String url, java.lang.String interval)
Creates a new accumulator for request count of the url.
通过这个实用类你的代码能够创建一些收集器很容易而且快速:
Accumulators.createAccumulator("SessionCount CurAbsolute", "SessionCount", "Sessions", "cur", "default");
Accumulators.createAccumulator("SessionCount Cur1h", "SessionCount", "Sessions", "cur", "1h");
Accumulators.createAccumulator("SessionCount New1h", "SessionCount", "Sessions", "new", "1h");
Accumulators.createAccumulator("SessionCount Del1h", "SessionCount", "Sessions", "del", "1h");
或者
Accumulators.createMemoryAccumulator5m("PermGenFree 5m", "MemoryPool-PS Perm Gen-NonHeap", "Free");
Accumulators.createMemoryAccumulator5m("PermGenFree MB 5m", "MemoryPool-PS Perm Gen-NonHeap", "Free MB");
Accumulators.createMemoryAccumulator5m("OldGenFree 5m", "MemoryPool-PS Old Gen-Heap", "Free");
Accumulators.createMemoryAccumulator5m("OldGenFree MB 5m", "MemoryPool-PS Old Gen-Heap", "Free MB");
Accumulators.createMemoryAccumulator5m("OldGenUsed 5m", "MemoryPool-PS Old Gen-Heap", "Used");
Accumulators.createMemoryAccumulator5m("OldGenUsed MB 5m", "MemoryPool-PS Old Gen-Heap", "Used MB");
最好的方式来添加你的收集器是使用一些你的应用或容器一启动就开始的功能。对于webapp最好是上下文监听。
一些例子关于MoSKito自己:WebUI和MoSKito Demo.
Accumulators tab 收集器页
为了查看所有可用的收集器:单击收集器页。

收集器页可能是MoSKito页中最简单的一个。单独列出了收集器集合。如图Accumulator_Controls.png所示。


收集器列表中的4列
Name 收集器的名字
Path  收集器的描述, 被用在MoSKito数据交互配置文件内部。描述使用如下格式:


<Producer.Stat.Value/Interval/TimeUnit>
For example: SessionCount.Sessions.new/1h/MILLISECONDS


Values  accumulator value (within the last interval)
Last Timestame 最后测量的时间
Displaying Accumulator Data as Charts 用图表形式展示数据
为了展示收集器图表并展示其他可用的收集器:
在收集器列表中,单击需要收集器的链接或者选择收集器通过它的选择框然后单击Submit按钮。

如图Accum_ChartOnly.png所示:


为了展示收集器图表中的详情信息:单击icon, 定位相同的需要的收集器的连接.
下面的图表,你能够看到下面信息部分:


Data section: 当前时间内的所有收集器的值,
JSON section: 所有可用收集器信息的JSON文件.
移动指针到图表中弯曲点展示调出的菜单如下:
  》时间戳
  》收集器名字
  》收集器值

  如图AccumulatorChart_AdditionalInfo.png所示:


为了隐藏图表和回到收集器列表:刷新Accumulatorstab页。
Displaying Multiple Charts 展示多个图表
MoSKito收集器的一个优点是你可以同时查看多个图表,这样方便对比。
为了查看多个图表:


在收集器列表, 通过选择框选中收集器 (列的最左侧).单击Submit按钮.多个图表被展示.
我们推荐使用Combin和正常的展示模式(查看展示模式和图表类型段落)
Display Modes 展示模式
当查看收集器图表,你可以选择多种展示模式来方便自己查看。而控制器在收集器列表底部.

为了改变展示模式,选择需要的模式并选择即可。如图Chart_ModesTypes.png所示:


具体说明见下图:


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值