当前位置:网站首页>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+"秒");
}
}
边栏推荐
- Safety (2)
- Good News | AR opens a new model for the textile industry, and ALVA Systems wins another award!
- 数仓:为什么说 ETL 的未来不是 ELT,而是 EL (T)
- AWR analysis report questions for help: How can SQL be optimized from what aspects?
- qt点云配准软件
- BioVendor人俱乐部细胞蛋白(CC16)Elisa试剂盒研究领域
- Flask之路由(app.route)详解
- 【CNN记录】tensorflow slice和strided_slice
- Unable to log in to the Westward Journey
- The state status is displayed incorrectly after the openGauss switch
猜你喜欢
随机推荐
OC和Swift语言的区别
四元数、罗德里格斯公式、欧拉角、旋转矩阵推导和资料
JVM调优实战
Safety (1)
工程师如何对待开源
机器人领域期刊会议汇总
BI-SQL丨WHILE
Entry name 'org/apache/commons/codec/language/bm/gen_approx_greeklatin.txt' collided
60 Feature Engineering Operations: Using Custom Aggregate Functions【Favorites】
2022年NPDP考完多久出成绩?怎么查询?
Scheduled tasks for distributed applications in Golang
Rasa 3 x learning series - Rasa - 4873 dispatcher Issues. Utter_message study notes
CodeTon Round 2 D. Magical Array
The first time I wrote a programming interview question for Niu Ke: input a string and return the letter with the most occurrences of the string
考完PMP学什么?前方软考等着你~
canal同步Mariadb到Mysql
【CNN记录】tensorflow slice和strided_slice
MySQL - CRUD operations
TKU remembers a single-point QPS optimization (I wish ITEYE is finally back)
PHP live source code to achieve simple barrage effect related code







