Back to index

munin  2.0.1
ThreadsDaemon.java
Go to the documentation of this file.
00001 package org.munin.plugin.jmx;
00002 
00006 import java.io.IOException;
00007 import java.lang.management.ManagementFactory;
00008 import java.lang.management.ThreadMXBean;
00009 
00010 import org.munin.plugin.jmx.AbstractAnnotationGraphsProvider.Graph;
00011 
00012 @Graph(title = "ThreadsDaemon", vlabel = "threads", info = "Returns the current number of live daemon threads.")
00013 public class ThreadsDaemon extends AbstractAnnotationGraphsProvider {
00014 
00015        private ThreadMXBean threadMXBean;
00016        
00017        public ThreadsDaemon(Config config) {
00018               super(config);
00019        }
00020 
00021        @Override
00022        protected void prepareValues() throws Exception {
00023               threadMXBean = ManagementFactory.newPlatformMXBeanProxy(
00024                             getConnection(), ManagementFactory.THREAD_MXBEAN_NAME,
00025                             ThreadMXBean.class);
00026        }
00027 
00028        @Field
00029        public int threadsDaemon() throws IOException {
00030               return threadMXBean.getDaemonThreadCount();
00031        }
00032 
00033        public static void main(String args[]) {
00034               runGraph(args);
00035        }
00036 }