Back to index

munin  2.0.1
CurrentThreadCpuTime.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 
00010 @Graph(title = "CurrentThreadCpuTime", vlabel = "ns", info = "Returns the total CPU time for the current thread in nanoseconds. The returned value is of nanoseconds precison but not necessarily nanoseconds accuracy. If the implementation distinguishes between user mode time and system mode time, the returned CPU time is the amount of time that the current thread has executed in user mode or system mode.")
00011 public class CurrentThreadCpuTime extends AbstractAnnotationGraphsProvider {
00012 
00013        public CurrentThreadCpuTime(Config config) {
00014               super(config);
00015        }
00016 
00017        @Field
00018        public long currentThreadCpuTime() throws IOException {
00019               ThreadMXBean threadmxbean = ManagementFactory.newPlatformMXBeanProxy(
00020                             getConnection(), ManagementFactory.THREAD_MXBEAN_NAME,
00021                             ThreadMXBean.class);
00022               return threadmxbean.getCurrentThreadCpuTime();
00023        }
00024 
00025        public static void main(String args[]) {
00026               runGraph(args);
00027        }
00028 }