Java OpenResty Spring Spring Boot MySQL Redis MongoDB PostgreSQL Linux Android Nginx 面试 小程序 Arthas JVM AQS juc Kubernetes Docker 诊断工具


Java JMX OperatingSystemMXBean

JMX Java 大约 993 字

功能

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
阅读 91 · 发布于 2024-01-01

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb

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

扫描二维码关注我
昵称:
随便看看 换一批