List of usage examples for java.lang.management ManagementFactory getOperatingSystemMXBean
public static OperatingSystemMXBean getOperatingSystemMXBean()
From source file:org.apache.stratos.load.balance.agent.LoadBalanceAgentService.java
/** * gets the load average of the system/* w ww . jav a 2 s . c om*/ * * @return load average. Returns zero if the load average couldn't be read. * Zero is treated as load-average not read, in the relevant places and ignored in the * load balancer and autoscalar algorithms appropriately. */ public double getLoadAverage() { double systemLoadAverage = 0; try { systemLoadAverage = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage(); } catch (Exception e) { if (log.isDebugEnabled()) { log.debug("Error in retrieving the load average of the instance"); } } return systemLoadAverage; }
From source file:ee.ria.xroad.common.util.SystemMetrics.java
/** * Initializes system metrics internals. *///from w w w . j a v a 2 s .co m public static void init() { OperatingSystemMXBean osStatsBean = ManagementFactory.getOperatingSystemMXBean(); if (osStatsBean instanceof UnixOperatingSystemMXBean) { stats = ((UnixOperatingSystemMXBean) osStatsBean); } else { throw new RuntimeException("Unexpected OperatingSystemMXBean " + osStatsBean); } memoryStats = ManagementFactory.getMemoryMXBean(); }
From source file:com.thoughtworks.go.server.service.support.ServerRuntimeInformationProvider.java
@Override public void appendInformation(InformationStringBuilder infoCollector) { osInfo(ManagementFactory.getOperatingSystemMXBean(), infoCollector); runtimeInfo(ManagementFactory.getRuntimeMXBean(), infoCollector); gcInfo(ManagementFactory.getGarbageCollectorMXBeans(), infoCollector); memoryInfo(ManagementFactory.getMemoryMXBean(), infoCollector); poolInfo(infoCollector);//w ww . jav a 2 s . co m threadInfo(ManagementFactory.getThreadMXBean(), infoCollector); }
From source file:com.ery.ertc.estorm.util.JVM.java
/** * Constructor. Get the running Operating System instance */ public JVM() { this.osMbean = ManagementFactory.getOperatingSystemMXBean(); }
From source file:test.Test_db.java
public void awd() { OperatingSystemMXBean bean = ManagementFactory.getOperatingSystemMXBean(); System.out.println(bean.getSystemLoadAverage()); }
From source file:com.netflix.genie.web.health.GenieCpuHealthIndicator.java
/** * Constructor./*from ww w . j a v a 2s .c om*/ * * @param healthProperties The maximum physical memory threshold * @param registry Registry * @param taskScheduler task scheduler */ @Autowired public GenieCpuHealthIndicator(@NotNull final HealthProperties healthProperties, @NotNull final Registry registry, @NotNull final TaskScheduler taskScheduler) { this(healthProperties.getMaxCpuLoadPercent(), healthProperties.getMaxCpuLoadConsecutiveOccurrences(), (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(), new BasicDistributionSummary(MonitorConfig.builder("genie.cpuLoad").build()), taskScheduler); }
From source file:functionaltests.policy.ram.TestRamPolicy.java
public String getHalfLocalRam() { long memorySize = ((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()) .getTotalPhysicalMemorySize(); return FileUtils.byteCountToDisplaySize(memorySize / 2).replaceAll(" GB", ""); }
From source file:uk.ac.sanger.cgp.wwdocker.beans.WorkerResources.java
public void init() { OperatingSystemMXBean osmxb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); if (availableProcessors == -1) { base_init(osmxb);//from w w w .j av a 2 s . c om } sysLoadAvg = osmxb.getSystemLoadAverage(); freeMemBytes = osmxb.getFreePhysicalMemorySize(); }
From source file:com.snowstore.mercury.core.metric.SystemPublicMetrics.java
/** * Add metrics from ManagementFactory if possible. Note that * ManagementFactory is not available on Google App Engine. */// w ww . ja v a2 s.co m private void addManagementMetrics(Collection<Metric<?>> result) { try { // Add JVM up time in ms result.add(new Metric<Long>("uptime", ManagementFactory.getRuntimeMXBean().getUptime())); result.add(new Metric<Double>("systemload.average", ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage())); addHeapMetrics(result); addNoHeapMetrics(result); addThreadMetrics(result); addClassLoadingMetrics(result); addGarbageCollectionMetrics(result); } catch (NoClassDefFoundError ex) { // Expected on Google App Engine } }
From source file:xbird.util.system.SystemUtils.java
private static void initializeSunJdk() { boolean useSunMx = false; if (IS_SUN_VM) { OperatingSystemMXBean mx = ManagementFactory.getOperatingSystemMXBean(); com.sun.management.OperatingSystemMXBean sunmx = (com.sun.management.OperatingSystemMXBean) mx; long testval = sunmx.getProcessCpuTime(); if (testval != -1L) { useSunMx = true;//from w ww .j ava2s.c om } } if (!useSunMx) { if (System.getProperty("xbird.use_jni") != null) { throw new IllegalStateException("Please set `xbird.use_jni' system property"); } try { System.loadLibrary("xbird_util_lang_SystemUtils"); } catch (UnsatisfiedLinkError le) { LogFactory.getLog(SystemUtils.class).warn( "Performance monitoring is not supported for this JVM. Please ensure that 'xbird.profiling' property is not enabled in your 'xbird.properties'"); } } useSunJdk6 = useSunMx; }