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: 622 · Posted: 2024-01-01

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh