Back to index

munin  2.0.1
CurrentThreadUserTime.java
Go to the documentation of this file.
00001 package org.munin.plugin.jmx;
00002 
00003 import java.io.IOException;
00004 import java.lang.management.ManagementFactory;
00005 import java.lang.management.ThreadMXBean;
00006 
00007 import org.munin.plugin.jmx.AbstractAnnotationGraphsProvider.Graph;
00008 
00009 @Graph(title = "CurrentThreadUserTime", vlabel = "ns", info = "Returns the CPU time that the current thread has executed in user mode in nanoseconds. The returned value is of nanoseconds precison but not necessarily nanoseconds accuracy.")
00010 public class CurrentThreadUserTime extends AbstractAnnotationGraphsProvider {
00011        public CurrentThreadUserTime(Config config) {
00012               super(config);
00013        }
00014 
00015        @Field
00016        public long currentThreadUserTime() throws IOException {
00017               ThreadMXBean threadmxbean = ManagementFactory.newPlatformMXBeanProxy(
00018                             getConnection(), ManagementFactory.THREAD_MXBEAN_NAME,
00019                             ThreadMXBean.class);
00020               return threadmxbean.getCurrentThreadUserTime();
00021        }
00022 
00023        public static void main(String args[]) {
00024               runGraph(args);
00025        }
00026 }