import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.lang.management.ManagementFactory;
public class JmxReport {
private static final Log log = LogFactory.getLog(JmxReport.class);
public static void logJmxInfo() {
// Operating System MXBean
log.info("Operating system architecture : " + ManagementFactory.getOperatingSystemMXBean().getArch() );
log.info("Available processors : " + ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors() );
log.info("Operating system name : " + ManagementFactory.getOperatingSystemMXBean().getName() );
log.info("System load average : " + ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage() );
log.info("Operating system version : " + ManagementFactory.getOperatingSystemMXBean().getVersion() );
// Memory MXBean
log.info("Heap memory usage : " + ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().toString() );
log.info("Non-heap memory usage : " + ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage().toString() );
// Class loading MXBean
log.info("Loaded class count : " + ManagementFactory.getClassLoadingMXBean().getLoadedClassCount() );
log.info("Total loaded class count : " + ManagementFactory.getClassLoadingMXBean().getTotalLoadedClassCount() );
log.info("Unloaded class count : " + ManagementFactory.getClassLoadingMXBean().getUnloadedClassCount() );
}
public static void main(String args[]) {
logJmxInfo();
}
}
Wednesday, January 20, 2010
Programmetically access JMX MBean information
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment