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. boostrap按钮

    bootstrap按钮 对应链接:http://v3.bootcss.com/css/#buttons 使用时添加基础类class:btn 默认样式class=btn-default,控制大小clas ...

  2. css布局篇

    <!doctype html><html lang="en"><head> <meta charset="UTF-8" ...

  3. 解决ajax请求cors跨域问题

    ”已阻止跨源请求:同源策略禁止读取位于 ***** 的远程资源.(原因:CORS 头缺少 'Access-Control-Allow-Origin').“ ”已阻止跨源请求:同源策略禁止读取位于 ** ...

  4. 使用Canvas实现下雪功能

    示例代码: <html> <head> <meta http-equiv="Content-Type" content="text/html ...

  5. html5的Canvas

    Canvas一般是指画布,最近对用html5写游戏比较感兴趣,所以简单的用了一下Canvas. 之前接触Canvas是在silverlight和wpf上用到过他,在silverlight上Canvas ...

  6. ORA-16018: cannot use LOG_ARCHIVE_DEST with LOG_ARCHIVE_DEST_n or DB_RECOVERY_FILE_DEST【error收集】

    之前一直没有注意一个事情, 关于设置archive归档路径设置的问题. 设置数据库为归档模式的命令: 1.首先要切换到mount状态: 2.执行alter system archivelog; 3.查 ...

  7. Java直接插入算法

    直接插入算法是将N个带排序的元素看做成一个有序表和一个无序表. 每次从无序表中取一个元素和有序表比较,重复N-1次完成排序. 直接上代码: package test; public class Tes ...

  8. (一)Angularjs - 入门

    AngularJS进行应用开发的一个重要的思维模式: 从构造声明式界面入手 ng-app: 这个指定定义并且关联了使用angularJS的HTML页面部分 ng-model: 这个指定定义并绑定Ang ...

  9. thinkphp 配置

    ThinkPHP框架中所有配置文件的定义格式均采用返回PHP数组的方式,格式为: //项目配置文件 return array( 'DEFAULT_MODULE' => 'Index', //默认 ...

  10. phpcms v9二次开发之模型类的应用(1)

    在<phpcms二次开发之模型类model.class.php>中讲到了模型类的建立方法,接下来我讲一下模型类的应用.      前段时间我基于phpcms v9开发了一个足球网.足球网是 ...