Jetty监控线程使用情况配置

第一步,配置xml文件

jetty-monitor.xml

参数说明:

threads: 线程池中的线程
busyThreads: 使用中的线程
idleThreads: 空闲的线程
lowOnThreads: 是否达到maxThread并且没有空闲线程接受请求(True if the pools is at maxThreads and there are not idle threads than queued jobs)
queueSize: 排队中的job数
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd"> <Configure id="Monitor" class="org.eclipse.jetty.monitor.JMXMonitor">
<Call name="addActions">
<Arg>
<Array type="org.eclipse.jetty.monitor.jmx.MonitorAction">
<Item>
<New class="org.eclipse.jetty.monitor.jmx.SimpleAction">
<Arg>
<New class="org.eclipse.jetty.monitor.triggers.AttrEventTrigger">
<Arg>org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0
</Arg>
<Arg>threads</Arg>
</New>
</Arg>
<Arg>
<New class="org.eclipse.jetty.monitor.jmx.LoggingNotifier">
<Arg>%s</Arg>
</New>
</Arg>
<Arg type="java.lang.Long">1000</Arg>
</New>
</Item>
<Item>
<New class="org.eclipse.jetty.monitor.jmx.SimpleAction">
<Arg>
<New class="org.eclipse.jetty.monitor.triggers.AttrEventTrigger">
<Arg>org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0
</Arg>
<Arg>busyThreads</Arg>
</New>
</Arg>
<Arg>
<New class="org.eclipse.jetty.monitor.jmx.LoggingNotifier">
<Arg>%s</Arg>
</New>
</Arg>
<Arg type="java.lang.Long">1000</Arg>
</New>
</Item>
<Item>
<New class="org.eclipse.jetty.monitor.jmx.SimpleAction">
<Arg>
<New class="org.eclipse.jetty.monitor.triggers.AttrEventTrigger">
<Arg>org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0
</Arg>
<Arg>idleThreads</Arg>
</New>
</Arg>
<Arg>
<New class="org.eclipse.jetty.monitor.jmx.LoggingNotifier">
<Arg>%s</Arg>
</New>
</Arg>
<Arg type="java.lang.Long">1000</Arg>
</New>
</Item>
<Item>
<New class="org.eclipse.jetty.monitor.jmx.SimpleAction">
<Arg>
<New class="org.eclipse.jetty.monitor.triggers.AttrEventTrigger">
<Arg>org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0
</Arg>
<Arg>lowOnThreads</Arg>
</New>
</Arg>
<Arg>
<New class="org.eclipse.jetty.monitor.jmx.LoggingNotifier">
<Arg>%s</Arg>
</New>
</Arg>
<Arg type="java.lang.Long">1000</Arg>
</New>
</Item>
<Item>
<New class="org.eclipse.jetty.monitor.jmx.SimpleAction">
<Arg>
<New class="org.eclipse.jetty.monitor.triggers.AttrEventTrigger">
<Arg>org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0
</Arg>
<Arg>queueSize</Arg>
</New>
</Arg>
<Arg>
<New class="org.eclipse.jetty.monitor.jmx.LoggingNotifier">
<Arg>%s</Arg>
</New>
</Arg>
<Arg type="java.lang.Long">1000</Arg>
</New>
</Item>
</Array>
</Arg>
</Call>
</Configure>

jetty-jmx.xml(保持原样不动即可,以下为参考)

<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">

<Configure id="Server" class="org.eclipse.jetty.server.Server">

  <!-- =========================================================== -->
<!-- Get the platform mbean server -->
<!-- =========================================================== -->
<Call id="MBeanServer" class="java.lang.management.ManagementFactory"
name="getPlatformMBeanServer" /> <!-- =========================================================== -->
<!-- Initialize the Jetty MBean container -->
<!-- =========================================================== -->
<Call name="addBean">
<Arg>
<New id="MBeanContainer" class="org.eclipse.jetty.jmx.MBeanContainer">
<Arg>
<Ref refid="MBeanServer" />
</Arg>
</New>
</Arg>
</Call> <!-- Add the static log -->
<Call name="addBean">
<Arg>
<New class="org.eclipse.jetty.util.log.Log" />
</Arg>
</Call>
</Configure>

第二步,导入xml文件

在jetty.conf中添加以下行:

jetty-monitor.xml
jetty-jmx.xml

第三步,开启对应模块

在start.ini中添加以下行:

--module=monitor
--module=jmx

第四步,重启jetty容器

线程的使用情况会以log的形式展现出来:

2017-01-09 17:24:40.759:INFO:oejmj.LoggingNotifier:pool-1-thread-2: [org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0:idleThreads]=98
Action time: Mon Jan 09 17:24:40 CST 2017
2017-01-09 17:24:40.759:INFO:oejmj.LoggingNotifier:pool-1-thread-4: [org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0:lowOnThreads]=false
Action time: Mon Jan 09 17:24:40 CST 2017
2017-01-09 17:24:40.760:INFO:oejmj.LoggingNotifier:pool-1-thread-1: [org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0:busyThreads]=2
Action time: Mon Jan 09 17:24:40 CST 2017
2017-01-09 17:24:40.760:INFO:oejmj.LoggingNotifier:pool-1-thread-2: [org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0:threads]=100
Action time: Mon Jan 09 17:24:40 CST 2017
2017-01-09 17:24:41.760:INFO:oejmj.LoggingNotifier:pool-1-thread-2: [org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0:idleThreads]=98
Action time: Mon Jan 09 17:24:41 CST 2017
2017-01-09 17:24:41.760:INFO:oejmj.LoggingNotifier:pool-1-thread-1: [org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0:lowOnThreads]=false
Action time: Mon Jan 09 17:24:41 CST 2017
2017-01-09 17:24:41.763:INFO:oejmj.LoggingNotifier:pool-1-thread-4: [org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0:busyThreads]=2
Action time: Mon Jan 09 17:24:41 CST 2017
2017-01-09 17:24:41.763:INFO:oejmj.LoggingNotifier:pool-1-thread-3: [org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0:threads]=100
Action time: Mon Jan 09 17:24:41 CST 2017

Jetty监控线程使用情况的配置的更多相关文章

  1. 开源动态可监控线程池DynamicTp介绍

    前言 使用线程池 ThreadPoolExecutor 过程中你是否有以下痛点呢? 代码中创建了一个 ThreadPoolExecutor,但是不知道那几个核心参数设置多少比较合适 凭经验设置参数值, ...

  2. 通过micrometer实时监控线程池的各项指标

    通过micrometer实时监控线程池的各项指标 前提 最近的一个项目中涉及到文件上传和下载,使用到JUC的线程池ThreadPoolExecutor,在生产环境中出现了某些时刻线程池满负载运作,由于 ...

  3. VS中调试时监控线程的最后错误代码

    进行调试的时候,监控线程的最后错误代码是非常有用的. 在 Microsoft Visual studio 中,Microsoft 的调试程序支持一个非常有用的特性,即可以配置 Watch 窗口,以便始 ...

  4. 【第一章】zabbix3.4监控WindowsCPU使用率磁盘IO磁盘事件日志监控阈值邮件报警详细配置

    Windows安装zabbix-agent 监控Windows-CPU使用率 监控Windows-磁盘IO性能监控 监控Windows/Linux-磁盘触发器阈值更改 监控Windows-网卡自动发现 ...

  5. InnoDB的后台线程(IO线程,master线程,锁监控线程,错误监控线程)和内存(缓冲池,重做日志缓冲池,额外内存池)

    InnoDB有多个内存块,你可以认为这些内存块组成了一个大的内存池,负责如下工作: 维护所有进程/线程需要访问的多个内部数据结构. 缓存磁盘上的数据,方便快速地读取,并且在对磁盘文件的数据进行修改之前 ...

  6. HDFS源码分析数据块复制监控线程ReplicationMonitor(一)

    ReplicationMonitor是HDFS中关于数据块复制的监控线程,它的主要作用就是计算DataNode工作,并将复制请求超时的块重新加入到待调度队列.其定义及作为线程核心的run()方法如下: ...

  7. Python之Monitor监控线程(干货)

    在日常工作中常遇到这样的情况,我们需要一个监控线程用于随时的获得其他进程的任务请求,或者我们需要监视某些资源等的变化,一个高效的Monitor程序如何使用python语言实现呢?为了解决上述问题,我将 ...

  8. (十一)使用Jconsole监控线程

    一.案例 监控线程情况,包括阻塞.死循环等 1.1 代码如下,下述代码共有三个线程,Main.mythread01.mythread02线程,其中mythread01线程为死循环.mythread02 ...

  9. stub_status监控Nginx使用情况!

    stub_status监控Nginx使用情况! 查看nginx安装的模块! # /usr/local/nginx/sbin/nginx -V nginx version: nginx/1.8.1 bu ...

随机推荐

  1. SpannableString的一个奇怪的问题

    今天使用spannableString遇到一个奇怪的问题,就是在setspan的时候,原本可以写成 spannableString.setSpan(new RelativeSizeSpan(0.5f) ...

  2. Android(java)学习笔记249:ContentProvider使用之获得系统联系人信息01

    1.系统联系人的数据库(3张最重要的表) (1)raw_contacts  联系人表        保存联系人的id   contact_id (2)data 数据表       保存联系人的数据 ( ...

  3. Android系统更改状态栏字体颜色

    随着时代的发展,Android的状态栏都不是乌黑一片了,在Android4.4之后我们可以修改状态栏的颜色或者让我们自己的View延伸到状态栏下面.我们可以进行更多的定制化了,然而有的时候我们使用的是 ...

  4. GSON 示例代码 实用版

    去除所有格式的json字符串 {"data":[{"friend":[{"address":"广州","nam ...

  5. css 实现文字过长变成省略号(包含单行的and多行的)

    单行的比较简单  但是必须条件同时满足 <DIV STYLE="width: 120px; height: 50px; border: 1px solid blue;overflow: ...

  6. maven的pom.xml深入理解

    maven的pom.xml的具体使用和各个xml标签的作用.这样设计的原理是什么? maven实战的第17章-18章是架构方面的知识

  7. drop表,然后创建表,插入数据,并创建索引等内容。

    execute immediate 'drop table sjb_jhgl_ydjhtdsbb';   execute immediate 'create table dw_sc.sjb_jhgl_ ...

  8. iOS中解析 XML / JSON

    JSON数据格式 1. 概述: JSON (JavaScript Object Notation) 是⼀一种轻量级的数据交换格式 基于⽂文本格式,易于⼈人阅读和编写,同时也易于机器解析和⽣生成. 2. ...

  9. 如何通过Request.ServerVariables["HTTP_USER_AGENT"]获取客户端操作系统信息

    http://www.useragentstring.com/pages/api.php

  10. CSS定位与浮动

    定位的基本思想很简单,它允许你定义元素框相对于其正常位置应该出现的位置,或者相对于父元素.另一个元素甚至浏览器窗口本身的位置.显然,这个功能非常强大,也很让人吃惊.要知道,用户代理对 CSS2 中定位 ...