com.sun.management.OperatingSystemMXBean Java Examples
The following examples show how to use
com.sun.management.OperatingSystemMXBean.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GetProcessCpuLoad.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] argv) throws Exception { OperatingSystemMXBean mbean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); double load; for(int i=0; i<10; i++) { load = mbean.getProcessCpuLoad(); if((load<0.0 || load>1.0) && load != -1.0) { throw new RuntimeException("getProcessCpuLoad() returns " + load + " which is not in the [0.0,1.0] interval"); } try { Thread.sleep(200); } catch(InterruptedException e) { e.printStackTrace(); } } }
Example #2
Source File: MemoryStatusOverflow.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String... args) throws Exception { OperatingSystemMXBean bean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); List<String> failedGetterNames = new ArrayList<String>(); List<String> testedGetterNames = Arrays.asList( "getTotalSwapSpaceSize", "getFreeSwapSpaceSize", "getTotalPhysicalMemorySize", "getFreePhysicalMemorySize"); for (String getterName : testedGetterNames) { Method getter = OperatingSystemMXBean.class.getMethod(getterName); long value = (Long) getter.invoke(bean); if (value == MEMORYSTATUS_OVERFLOW) { failedGetterNames.add(getterName); } } if (!failedGetterNames.isEmpty()) { throw new AssertionError(failedGetterNames); } System.out.println("Test passed."); }
Example #3
Source File: GetSystemCpuLoad.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String[] argv) throws Exception { OperatingSystemMXBean mbean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); double load; for(int i=0; i<10; i++) { load = mbean.getSystemCpuLoad(); if((load<0.0 || load>1.0) && load != -1.0) { throw new RuntimeException("getSystemCpuLoad() returns " + load + " which is not in the [0.0,1.0] interval"); } try { Thread.sleep(200); } catch(InterruptedException e) { e.printStackTrace(); } } }
Example #4
Source File: GetProcessCpuLoad.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] argv) throws Exception { OperatingSystemMXBean mbean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); double load; for(int i=0; i<10; i++) { load = mbean.getProcessCpuLoad(); if((load<0.0 || load>1.0) && load != -1.0) { throw new RuntimeException("getProcessCpuLoad() returns " + load + " which is not in the [0.0,1.0] interval"); } try { Thread.sleep(200); } catch(InterruptedException e) { e.printStackTrace(); } } }
Example #5
Source File: WindowsSystemCommander.java From Jpom with MIT License | 6 votes |
/** * 获取windows 监控 * https://docs.oracle.com/javase/7/docs/jre/api/management/extension/com/sun/management/OperatingSystemMXBean.html * * @return 返回cpu占比和内存占比 */ @Override public JSONObject getAllMonitor() { OperatingSystemMXBean operatingSystemMXBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); JSONObject jsonObject = new JSONObject(); double total = operatingSystemMXBean.getTotalPhysicalMemorySize(); double free = operatingSystemMXBean.getFreePhysicalMemorySize(); jsonObject.put("memory", String.format("%.2f", (total - free) / total * 100)); //最近系统cpu使用量 double systemCpuLoad = operatingSystemMXBean.getSystemCpuLoad(); if (systemCpuLoad <= 0) { systemCpuLoad = 0; } jsonObject.put("cpu", String.format("%.2f", systemCpuLoad * 100)); jsonObject.put("disk", getHardDisk()); return jsonObject; }
Example #6
Source File: GetProcessCpuLoad.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] argv) throws Exception { OperatingSystemMXBean mbean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); double load; for(int i=0; i<10; i++) { load = mbean.getProcessCpuLoad(); if((load<0.0 || load>1.0) && load != -1.0) { throw new RuntimeException("getProcessCpuLoad() returns " + load + " which is not in the [0.0,1.0] interval"); } try { Thread.sleep(200); } catch(InterruptedException e) { e.printStackTrace(); } } }
Example #7
Source File: MemoryStatusOverflow.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void main(String... args) throws Exception { OperatingSystemMXBean bean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); List<String> failedGetterNames = new ArrayList<String>(); List<String> testedGetterNames = Arrays.asList( "getTotalSwapSpaceSize", "getFreeSwapSpaceSize", "getTotalPhysicalMemorySize", "getFreePhysicalMemorySize"); for (String getterName : testedGetterNames) { Method getter = OperatingSystemMXBean.class.getMethod(getterName); long value = (Long) getter.invoke(bean); if (value == MEMORYSTATUS_OVERFLOW) { failedGetterNames.add(getterName); } } if (!failedGetterNames.isEmpty()) { throw new AssertionError(failedGetterNames); } System.out.println("Test passed."); }
Example #8
Source File: MemoryStatusOverflow.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String... args) throws Exception { OperatingSystemMXBean bean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); List<String> failedGetterNames = new ArrayList<String>(); List<String> testedGetterNames = Arrays.asList( "getTotalSwapSpaceSize", "getFreeSwapSpaceSize", "getTotalPhysicalMemorySize", "getFreePhysicalMemorySize"); for (String getterName : testedGetterNames) { Method getter = OperatingSystemMXBean.class.getMethod(getterName); long value = (Long) getter.invoke(bean); if (value == MEMORYSTATUS_OVERFLOW) { failedGetterNames.add(getterName); } } if (!failedGetterNames.isEmpty()) { throw new AssertionError(failedGetterNames); } System.out.println("Test passed."); }
Example #9
Source File: CollectLocalCpuUsage.java From bazel with Apache License 2.0 | 6 votes |
@Override public void run() { stopwatch = Stopwatch.createStarted(); localCpuUsage = new TimeSeries( /* startTimeMillis= */ stopwatch.elapsed().toMillis(), BUCKET_DURATION.toMillis()); OperatingSystemMXBean bean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); Duration previousElapsed = stopwatch.elapsed(); long previousCpuTimeNanos = bean.getProcessCpuTime(); profilingStarted = true; while (!stopCpuUsage) { try { Thread.sleep(LOCAL_CPU_SLEEP_MILLIS); } catch (InterruptedException e) { return; } Duration nextElapsed = stopwatch.elapsed(); long nextCpuTimeNanos = bean.getProcessCpuTime(); double deltaNanos = nextElapsed.minus(previousElapsed).toNanos(); double cpuLevel = (nextCpuTimeNanos - previousCpuTimeNanos) / deltaNanos; localCpuUsage.addRange(previousElapsed.toMillis(), nextElapsed.toMillis(), cpuLevel); previousElapsed = nextElapsed; previousCpuTimeNanos = nextCpuTimeNanos; } }
Example #10
Source File: MemoryStatusOverflow.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String... args) throws Exception { OperatingSystemMXBean bean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); List<String> failedGetterNames = new ArrayList<String>(); List<String> testedGetterNames = Arrays.asList( "getTotalSwapSpaceSize", "getFreeSwapSpaceSize", "getTotalPhysicalMemorySize", "getFreePhysicalMemorySize"); for (String getterName : testedGetterNames) { Method getter = OperatingSystemMXBean.class.getMethod(getterName); long value = (Long) getter.invoke(bean); if (value == MEMORYSTATUS_OVERFLOW) { failedGetterNames.add(getterName); } } if (!failedGetterNames.isEmpty()) { throw new AssertionError(failedGetterNames); } System.out.println("Test passed."); }
Example #11
Source File: PerformanceMonitor.java From Rainfall-core with Apache License 2.0 | 6 votes |
public synchronized double getCpuUsage() { if (lastSystemTime == 0) { baselineCounters(); return 0; } long systemTime = System.nanoTime(); long processCpuTime = 0; if (getOperatingSystemMXBean() instanceof OperatingSystemMXBean) { processCpuTime = ((OperatingSystemMXBean)getOperatingSystemMXBean()).getProcessCpuTime(); } double cpuUsage = (double)(processCpuTime - lastProcessCpuTime) / (systemTime - lastSystemTime); lastSystemTime = systemTime; lastProcessCpuTime = processCpuTime; return cpuUsage / availableProcessors; }
Example #12
Source File: SystemMonitorUtil.java From base-admin with MIT License | 6 votes |
public static MonitorVo getSysMonitor(){ //jvm MemoryUsage heapInfo = getHeapInfo(); monitorVo.setJvmHeapInit(decimalFormat.format(heapInfo.getInit() / 1024 / 1024)); monitorVo.setJvmHeapMax(decimalFormat.format(heapInfo.getMax() / 1024 / 1024)); monitorVo.setJvmHeapUsed(decimalFormat.format(heapInfo.getUsed() / 1024 / 1024)); monitorVo.setJvmHeapCommitted(decimalFormat.format(heapInfo.getCommitted() / 1024 / 1024)); MemoryUsage noHeapInfo = getNoHeapInfo(); monitorVo.setJvmNonHeapInit(decimalFormat.format(noHeapInfo.getInit() / 1024 / 1024)); monitorVo.setJvmNonHeapMax(decimalFormat.format(noHeapInfo.getMax() / 1024 / 1024)); monitorVo.setJvmNonHeapUsed(decimalFormat.format(noHeapInfo.getUsed() / 1024 / 1024)); monitorVo.setJvmNonHeapCommitted(decimalFormat.format(noHeapInfo.getCommitted() / 1024 / 1024)); //系统信息 monitorVo.setCpuUseRate(decimalFormat.format(getCpuUsage() * 100)); OperatingSystemMXBean memoryUsage = getMemoryUsage(); monitorVo.setRamTotal(decimalFormat.format(memoryUsage.getTotalPhysicalMemorySize() / 1024 / 1024 / 1024)); monitorVo.setRamUsed(decimalFormat.format((memoryUsage.getTotalPhysicalMemorySize() - memoryUsage.getFreePhysicalMemorySize()) / 1024 / 1024 / 1024)); HashMap<String, Double> diskUsage = getDiskUsage(); monitorVo.setDiskTotal(decimalFormat.format(diskUsage.get("total"))); monitorVo.setDiskUsed(decimalFormat.format(diskUsage.get("used"))); return monitorVo; }
Example #13
Source File: GetSystemCpuLoad.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void main(String[] argv) throws Exception { OperatingSystemMXBean mbean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); double load; for(int i=0; i<10; i++) { load = mbean.getSystemCpuLoad(); if((load<0.0 || load>1.0) && load != -1.0) { throw new RuntimeException("getSystemCpuLoad() returns " + load + " which is not in the [0.0,1.0] interval"); } try { Thread.sleep(200); } catch(InterruptedException e) { e.printStackTrace(); } } }
Example #14
Source File: GetSystemCpuLoad.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] argv) throws Exception { OperatingSystemMXBean mbean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); double load; for(int i=0; i<10; i++) { load = mbean.getSystemCpuLoad(); if((load<0.0 || load>1.0) && load != -1.0) { throw new RuntimeException("getSystemCpuLoad() returns " + load + " which is not in the [0.0,1.0] interval"); } try { Thread.sleep(200); } catch(InterruptedException e) { e.printStackTrace(); } } }
Example #15
Source File: GetProcessCpuLoad.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] argv) throws Exception { OperatingSystemMXBean mbean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); double load; for(int i=0; i<10; i++) { load = mbean.getProcessCpuLoad(); if((load<0.0 || load>1.0) && load != -1.0) { throw new RuntimeException("getProcessCpuLoad() returns " + load + " which is not in the [0.0,1.0] interval"); } try { Thread.sleep(200); } catch(InterruptedException e) { e.printStackTrace(); } } }
Example #16
Source File: HealthStatisticsReader.java From attic-stratos with Apache License 2.0 | 6 votes |
public CartridgeStatistics getCartridgeStatistics() throws IOException { OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); double totalMemory = (double) (osBean.getTotalPhysicalMemorySize() / MB); double usedMemory = (double) ((totalMemory - (osBean.getFreePhysicalMemorySize() / MB))); double loadAvg = (double) osBean.getSystemLoadAverage(); // assume system cores = available cores to JVM int cores = osBean.getAvailableProcessors(); double memoryConsumption = (usedMemory / totalMemory) * 100; double loadAvgPercentage = (loadAvg / cores) * 100; if (log.isDebugEnabled()) { log.debug("Memory consumption: [totalMemory] " + totalMemory + "Mb [usedMemory] " + usedMemory + "Mb: " + memoryConsumption + "%"); log.debug("Processor consumption: [loadAverage] " + loadAvg + " [cores] " + cores + ": " + loadAvgPercentage + "%"); } return (new CartridgeStatistics(memoryConsumption, loadAvgPercentage)); }
Example #17
Source File: ClusterMonitor.java From zeppelin with Apache License 2.0 | 6 votes |
private UsageUtil getMachineUsage() { OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class); // Returns the amount of free physical memory in bytes. long freePhysicalMemorySize = operatingSystemMXBean.getFreePhysicalMemorySize(); // Returns the total amount of physical memory in bytes. long totalPhysicalMemorySize = operatingSystemMXBean.getTotalPhysicalMemorySize(); // Returns the "recent cpu usage" for the whole system. double systemCpuLoad = operatingSystemMXBean.getSystemCpuLoad(); int process = Runtime.getRuntime().availableProcessors(); UsageUtil monitorUtil = new UsageUtil(); monitorUtil.memoryUsed = totalPhysicalMemorySize - freePhysicalMemorySize; monitorUtil.memoryCapacity = totalPhysicalMemorySize; monitorUtil.cpuUsed = (long) (process * systemCpuLoad * 100); monitorUtil.cpuCapacity = process * 100; return monitorUtil; }
Example #18
Source File: MemoryStatusOverflow.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void main(String... args) throws Exception { OperatingSystemMXBean bean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); List<String> failedGetterNames = new ArrayList<String>(); List<String> testedGetterNames = Arrays.asList( "getTotalSwapSpaceSize", "getFreeSwapSpaceSize", "getTotalPhysicalMemorySize", "getFreePhysicalMemorySize"); for (String getterName : testedGetterNames) { Method getter = OperatingSystemMXBean.class.getMethod(getterName); long value = (Long) getter.invoke(bean); if (value == MEMORYSTATUS_OVERFLOW) { failedGetterNames.add(getterName); } } if (!failedGetterNames.isEmpty()) { throw new AssertionError(failedGetterNames); } System.out.println("Test passed."); }
Example #19
Source File: MemoryStatusOverflow.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String... args) throws Exception { OperatingSystemMXBean bean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); List<String> failedGetterNames = new ArrayList<String>(); List<String> testedGetterNames = Arrays.asList( "getTotalSwapSpaceSize", "getFreeSwapSpaceSize", "getTotalPhysicalMemorySize", "getFreePhysicalMemorySize"); for (String getterName : testedGetterNames) { Method getter = OperatingSystemMXBean.class.getMethod(getterName); long value = (Long) getter.invoke(bean); if (value == MEMORYSTATUS_OVERFLOW) { failedGetterNames.add(getterName); } } if (!failedGetterNames.isEmpty()) { throw new AssertionError(failedGetterNames); } System.out.println("Test passed."); }
Example #20
Source File: GetSystemCpuLoad.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] argv) throws Exception { OperatingSystemMXBean mbean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); double load; for(int i=0; i<10; i++) { load = mbean.getSystemCpuLoad(); if((load<0.0 || load>1.0) && load != -1.0) { throw new RuntimeException("getSystemCpuLoad() returns " + load + " which is not in the [0.0,1.0] interval"); } try { Thread.sleep(200); } catch(InterruptedException e) { e.printStackTrace(); } } }
Example #21
Source File: GetSystemCpuLoad.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] argv) throws Exception { OperatingSystemMXBean mbean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); double load; for(int i=0; i<10; i++) { load = mbean.getSystemCpuLoad(); if((load<0.0 || load>1.0) && load != -1.0) { throw new RuntimeException("getSystemCpuLoad() returns " + load + " which is not in the [0.0,1.0] interval"); } try { Thread.sleep(200); } catch(InterruptedException e) { e.printStackTrace(); } } }
Example #22
Source File: SystemStatusListener.java From Sentinel with Apache License 2.0 | 5 votes |
@Override public void run() { try { OperatingSystemMXBean osBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class); currentLoad = osBean.getSystemLoadAverage(); /* * Java Doc copied from {@link OperatingSystemMXBean#getSystemCpuLoad()}:</br> * Returns the "recent cpu usage" for the whole system. This value is a double in the [0.0,1.0] interval. * A value of 0.0 means that all CPUs were idle during the recent period of time observed, while a value * of 1.0 means that all CPUs were actively running 100% of the time during the recent period being * observed. All values between 0.0 and 1.0 are possible depending of the activities going on in the * system. If the system recent cpu usage is not available, the method returns a negative value. */ double systemCpuUsage = osBean.getSystemCpuLoad(); // calculate process cpu usage to support application running in container environment RuntimeMXBean runtimeBean = ManagementFactory.getPlatformMXBean(RuntimeMXBean.class); long newProcessCpuTime = osBean.getProcessCpuTime(); long newProcessUpTime = runtimeBean.getUptime(); int cpuCores = osBean.getAvailableProcessors(); long processCpuTimeDiffInMs = TimeUnit.NANOSECONDS .toMillis(newProcessCpuTime - processCpuTime); long processUpTimeDiffInMs = newProcessUpTime - processUpTime; double processCpuUsage = (double) processCpuTimeDiffInMs / processUpTimeDiffInMs / cpuCores; processCpuTime = newProcessCpuTime; processUpTime = newProcessUpTime; currentCpuUsage = Math.max(processCpuUsage, systemCpuUsage); if (currentLoad > SystemRuleManager.getSystemLoadThreshold()) { writeSystemStatusLog(); } } catch (Throwable e) { RecordLog.warn("[SystemStatusListener] Failed to get system metrics from JMX", e); } }
Example #23
Source File: LicenseVerifyManager.java From hugegraph with Apache License 2.0 | 5 votes |
private void checkRam(ExtraParam param) { // Unit MB int expectRam = param.ram(); if (expectRam == NO_LIMIT) { return; } OperatingSystemMXBean mxBean = (OperatingSystemMXBean) ManagementFactory .getOperatingSystemMXBean(); long actualRam = mxBean.getTotalPhysicalMemorySize() / Bytes.MB; if (actualRam > expectRam) { throw newLicenseException( "The server's ram(MB) '%s' exceeded the limit(MB) '%s'", actualRam, expectRam); } }
Example #24
Source File: IndexAdminController.java From pybbs with GNU Affero General Public License v3.0 | 5 votes |
@RequiresUser @GetMapping({"/", "/index"}) public String index(Model model) { // 查询当天新增话题 model.addAttribute("topic_count", topicService.countToday()); // 查询当天新增标签 model.addAttribute("tag_count", tagService.countToday()); // 查询当天新增评论 model.addAttribute("comment_count", commentService.countToday()); // 查询当天新增用户 model.addAttribute("user_count", userService.countToday()); // 获取操作系统的名字 model.addAttribute("os_name", System.getProperty("os.name")); // 内存 int kb = 1024; OperatingSystemMXBean osmxb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); // 总的物理内存 long totalMemorySize = osmxb.getTotalPhysicalMemorySize() / kb; //已使用的物理内存 long usedMemory = (osmxb.getTotalPhysicalMemorySize() - osmxb.getFreePhysicalMemorySize()) / kb; // 获取系统cpu负载 double systemCpuLoad = osmxb.getSystemCpuLoad(); // 获取jvm线程负载 double processCpuLoad = osmxb.getProcessCpuLoad(); model.addAttribute("totalMemorySize", totalMemorySize); model.addAttribute("usedMemory", usedMemory); model.addAttribute("systemCpuLoad", systemCpuLoad); model.addAttribute("processCpuLoad", processCpuLoad); return "admin/index"; }
Example #25
Source File: JmxClient.java From vjtools with Apache License 2.0 | 5 votes |
public synchronized OperatingSystemMXBean getOperatingSystemMXBean() throws IOException { if (hasPlatformMXBeans && operatingSystemMBean == null) { operatingSystemMBean = ManagementFactory.newPlatformMXBeanProxy(server, ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, OperatingSystemMXBean.class); } return operatingSystemMBean; }
Example #26
Source File: PerformanceMonitor.java From Rainfall-core with Apache License 2.0 | 5 votes |
public long getMemoryUsage() { long physicalMemorySize = -1L; if (getOperatingSystemMXBean() instanceof OperatingSystemMXBean) { physicalMemorySize = ((OperatingSystemMXBean)getOperatingSystemMXBean()).getFreePhysicalMemorySize(); } return physicalMemorySize; }
Example #27
Source File: AppServer.java From mpns with Apache License 2.0 | 5 votes |
private void initMxBean() { try { osMxBean = ManagementFactory.newPlatformMXBeanProxy(ManagementFactory.getPlatformMBeanServer(), ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, OperatingSystemMXBean.class); } catch (IOException e) { throw new RuntimeException(e); } vertx.setPeriodic(MINUTES.toMillis(5), t -> logger.info("avgLoad:{}\n freeMem:{}", osMxBean.getSystemLoadAverage(), osMxBean.getFreePhysicalMemorySize() ) ); }
Example #28
Source File: CpuUsageGauge.java From dropwizard-wavefront with Apache License 2.0 | 5 votes |
@Override public Integer getValue() { OperatingSystemMXBean mbean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); return (int) Math.ceil(mbean.getSystemCpuLoad() * 100); }
Example #29
Source File: StatsCommand.java From kyoko with MIT License | 5 votes |
public StatsCommand(CommandManager commandManager) { name = "stats"; aliases = new String[]{"botinfo", "about"}; this.commandManager = commandManager; rb = ManagementFactory.getRuntimeMXBean(); osb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); rt = Runtime.getRuntime(); jvmVersion = System.getProperty("java.version", "unknown") + " (" + System.getProperty("java.vm.version", "unknown") + ")"; }
Example #30
Source File: FreeMemoryGauge.java From dropwizard-wavefront with Apache License 2.0 | 5 votes |
@Override public Long getValue() { OperatingSystemMXBean mbean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); return mbean.getTotalPhysicalMemorySize() - mbean.getCommittedVirtualMemorySize(); }