当前位置:网站首页>OperatingSystemMXBean获取系统性能指标
OperatingSystemMXBean获取系统性能指标
2022-08-02 02:33:00 【LG_985938339】
OperatingSystemMXBean获取系统性能指标
| 方法名称 | 含义 | 单位 |
|---|---|---|
| getFreePhysicalMemorySize | 可用物理内存 | 字节 |
| getTotalPhysicalMemorySize | 总物理内存 | 字节 |
| getFreeSwapSpaceSize | 可用交换空间 | 字节 |
| getTotalSwapSpaceSize | 交换空间总量 | 字节 |
| getCommittedVirtualMemorySize | 已提交虚拟内存大小 | 字节 |
| getProcessCpuLoad | 进程CPU使用率(0~1之间) | |
| getSystemCpuLoad | 系统CPU使用率(0~1之间) | |
| getAvailableProcessors | 可用CPU核数 | 个 |
| getProcessCpuTime | 进程使用的 CPU 时间 | 纳秒 |
import com.sun.management.OperatingSystemMXBean;
import java.lang.management.ManagementFactory;
public class Test {
public static void main(String[] args) throws InterruptedException {
final long GB = 1024 * 1024 * 1024;
OperatingSystemMXBean operatingSystemMXBean = (OperatingSystemMXBean)ManagementFactory.getOperatingSystemMXBean();
System.out.println("进程CPU使用率: "+operatingSystemMXBean.getProcessCpuLoad()* 100+"%");
System.out.println("系统CPU使用率: "+operatingSystemMXBean.getSystemCpuLoad()* 100+"%");
System.out.println("物理内存总量: "+operatingSystemMXBean.getTotalPhysicalMemorySize()/GB+"GB");
System.out.println("物理内存剩余可用量: "+operatingSystemMXBean.getFreePhysicalMemorySize()/GB+"GB");
System.out.println("内存使用率: "+(double)100*operatingSystemMXBean.getFreePhysicalMemorySize()/operatingSystemMXBean.getTotalPhysicalMemorySize()+"%");
System.out.println("交换空间总量: "+operatingSystemMXBean.getTotalSwapSpaceSize()/GB+"GB");
System.out.println("交换空间剩余可用量: "+operatingSystemMXBean.getFreeSwapSpaceSize()/GB+"GB");
System.out.println("CPU核心数: "+operatingSystemMXBean.getAvailableProcessors()+"个");
System.out.println("已提交虚拟内存量: "+operatingSystemMXBean.getCommittedVirtualMemorySize());
System.out.println("进程已使用CPU时间: "+operatingSystemMXBean.getProcessCpuTime()/1000000000.0+"秒");
}
}
边栏推荐
- 淘宝详情.
- pyqt上手体验
- 忽晴忽雨
- Outsourcing worked for three years, it was abolished...
- Electronic Manufacturing Warehouse Barcode Management System Solution
- Pinduoduo leverages the consumer expo to promote the upgrading of domestic agricultural products brands and keep pace with international high-quality agricultural products
- 永磁同步电机36问(二)——机械量与电物理量如何转化?
- Good News | AR opens a new model for the textile industry, and ALVA Systems wins another award!
- 拼多多借力消博会推动国内农产品品牌升级 看齐国际精品农货
- The failure to create a role in Dahua Westward Journey has been solved
猜你喜欢

2022-08-01 mysql/stoonedb慢SQL-Q18分析

FOFAHUB使用测试

CASE2023

Software testing Interface automation testing Pytest framework encapsulates requests library Encapsulates unified request and multiple base path processing Interface association encapsulation Test cas

FOFAHUB usage test

四元数、罗德里格斯公式、欧拉角、旋转矩阵推导和资料

拼多多借力消博会推动国内农产品品牌升级 看齐国际精品农货

使用docker安装mysql

Electronic Manufacturing Warehouse Barcode Management System Solution

2022河南青训联赛第(三)场
随机推荐
yaml
789. 数的范围
BI - SQL 丨 WHILE
永磁同步电机36问(三)——SVPWM代码实现
PAT甲级打卡-1001-1004
网络层解析——IP协议、地址管理、路由选择
PHP live source code to achieve simple barrage effect related code
Swift运行时(派发机制)
2022-08-01 mysql/stoonedb慢SQL-Q18分析
mysql 查看死锁
Ringtone 1161. Maximum In-Layer Elements and
EFCore 反向工程
数仓:数仓从ETL到ELT架构的转化以及俩者的区别
Chopper webshell feature analysis
TKU remembers a single-point QPS optimization (I wish ITEYE is finally back)
FOFAHUB usage test
The principle and code implementation of intelligent follower robot in the actual combat of innovative projects
Flask入门学习教程
【web】理解 Cookie 和 Session 机制
leetcode/字符串中的变位词-s1字符串的某个排列是s2的子串