Back to index

munin  2.0.1
ThreadsStartedTotal.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 = "ThreadsStartedTotal", vlabel = "threads", info = "Returns the total number of threads created and also started since the Java virtual machine started.")
00010 public class ThreadsStartedTotal extends AbstractAnnotationGraphsProvider {
00011 
00012        public ThreadsStartedTotal(Config config) {
00013               super(config);
00014        }
00015 
00016        @Field
00017        public long threadsStartedTotal() throws IOException {
00018               ThreadMXBean threadmxbean = ManagementFactory.newPlatformMXBeanProxy(
00019                             getConnection(), ManagementFactory.THREAD_MXBEAN_NAME,
00020                             ThreadMXBean.class);
00021 
00022               return threadmxbean.getTotalStartedThreadCount();
00023        }
00024 
00025        public static void main(String args[]) {
00026               runGraph(args);
00027        }
00028 }