Back to index

munin  2.0.1
ProcessorsAvailable.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.OperatingSystemMXBean;
00006 
00007 import org.munin.plugin.jmx.AbstractAnnotationGraphsProvider.Graph;
00008 
00009 @Graph(title = "ProcessorsAvailable", vlabel = "processors", info = "Returns the number of processors available to the Java virtual machine. This value may change during a particular invocation of the virtual machine.")
00010 public class ProcessorsAvailable extends AbstractAnnotationGraphsProvider {
00011 
00012        public ProcessorsAvailable(Config config) {
00013               super(config);
00014        }
00015 
00016        @Field
00017        public int processorsAvailable() throws IOException {
00018               OperatingSystemMXBean osmxbean = ManagementFactory
00019                             .newPlatformMXBeanProxy(getConnection(),
00020                                           ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME,
00021                                           OperatingSystemMXBean.class);
00022               return osmxbean.getAvailableProcessors();
00023        }
00024 
00025        public static void main(String args[]) {
00026               runGraph(args);
00027        }
00028 }