Java JMX OperatingSystemMXBean
JMX Java About 993 words功能
OperatingSystemMXBean
可以获取Java
运行所在机器的操作系统信息:
SystemLoadAverage
: 系统负载Name
: 机器名称Version
: 机器版本Arch
: 机器架构AvailableProcessors
: 机器可用的CPU
处理器
代码
public class OperatingSystemMXBeanTest {
public static void main(String[] args) {
OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
System.out.println("systemLoadAverage: " + operatingSystemMXBean.getSystemLoadAverage());
System.out.println("name: " + operatingSystemMXBean.getName());
System.out.println("version: " + operatingSystemMXBean.getVersion());
System.out.println("arch: " + operatingSystemMXBean.getArch());
System.out.println("availableProcessors: " + operatingSystemMXBean.getAvailableProcessors());
System.out.println("objectName: " + operatingSystemMXBean.getObjectName());
}
}
输出
systemLoadAverage: 0.83740234375
name: Mac OS X
version: 13.6
arch: aarch64
availableProcessors: 10
objectName: java.lang:type=OperatingSystem
Views: 581 · Posted: 2024-01-01
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...