Jetty监控线程使用情况的配置
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)
<?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> </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
相关推荐
smallwhale 2011-07-13
HatsuneMiku 2011-06-19
stoneechogx 2019-10-23
积跬步以至千里 2016-07-11
CSDNMrWang 2011-05-19
码路心路知行合一 2011-11-18
易鲸捷大数据库 2015-01-23
xggnoh 2013-05-10
wangteng 2012-09-16
tengmuxin 2012-08-24
bgylde 2012-05-21
dangzhangjing 2011-08-30
vallenlsl 2010-11-09
TangCuYu 2013-06-26
wanchaopeng 2019-06-21
87901735 2019-05-29