文章目录

  • SpringBoot通过OSHI进行系统监控
  • 一、Maven添加OSHI依赖
  • 二、编写OSHIMonitorUtil工具类
  • 2.1 为了便于使用,我编写了OSHIMonitor工具类,直接返回HashMap对象。代码如下
  • 2.2 测试接口
  • 三、返回数据的字段含义
  • 3.1 sysInfo
  • 3.2 cpuInfo
  • 3.3 diskInfoList
  • 3.4 jvmInfo
  • 3.5 memoryInfo
  • 3.6 netBandwidthInfo
  • 3.7 allDiskUsePercent
  • 3.8 processList
  • 3.9 computerSystem
  • 3.10 centralProcessor
  • 3.11 hardwareAbstractionLayer
  • 3.12 systemProperties


SpringBoot通过OSHI进行系统监控

  • Springboot若要实现系统监控的话一般常用的为Sigar和OSHI。
  • Sigar和OSHI都能够实现服务端资源监控,但是由于Sigar是无法直接获取到操作系统资源的,所以需要通过C语言的汇编文件获取。相比于OSHI直接引入jar就可以获取硬件资源来说,麻烦很多。因此若使用个人推荐OSHI
  • 下面我就来介绍一下OSHI如何使用(本文直接使用的AIZUDA提供的OSHI包)

一、Maven添加OSHI依赖

  • 直接在SpringBoot项目中的pom.xml直接添加下面的代码,然后点击IDEA右侧Maven里面的reload all maven projects即可,Maven的设置方法本文不做简述
<dependency>
    <groupId>com.aizuda</groupId>
    <artifactId>aizuda-monitor</artifactId>
    <version>1.0.0</version>
</dependency>

二、编写OSHIMonitorUtil工具类

2.1 为了便于使用,我编写了OSHIMonitor工具类,直接返回HashMap对象。代码如下

package com.mbtxtq.app.utils;

import com.aizuda.common.toolkit.CollectionUtils;
import com.aizuda.monitor.DiskInfo;
import com.aizuda.monitor.OshiMonitor;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import oshi.software.os.OSProcess;
import oshi.software.os.OperatingSystem;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Configuration
public class OSHIMonitorUtil {

    @Autowired
    private OshiMonitor oshiMonitor;

    @SneakyThrows
    public void appendAllDiskUsePercent(String infoType, Map<String, Object> OSHIInfoMap) {

        // 磁盘信息
        List<DiskInfo> diskInfoList = this.oshiMonitor.getDiskInfos();

        if (CollectionUtils.isNotEmpty(diskInfoList)) {

            long usableSpace = 0;
            long totalSpace = 0;

            for (DiskInfo diskInfo : diskInfoList) {

                usableSpace += diskInfo.getUsableSpace();
                totalSpace += diskInfo.getTotalSpace();

            }

            double usedSize = (totalSpace - usableSpace);

            OSHIInfoMap.put(infoType, this.oshiMonitor.formatDouble((usedSize / totalSpace) * 100));

        }

    }

    @SneakyThrows
    public void appendProcessList(Integer limitNumber, String infoType, Map<String, Object> OSHIInfoMap) {

        // 系统前 10 个进程
        List<OSProcess> processList = this.oshiMonitor.getOperatingSystem().getProcesses(
                null, OperatingSystem.ProcessSorting.CPU_DESC, limitNumber
        );

        List<Map<String, Object>> processMapList = new ArrayList<>();

        for (OSProcess process : processList) {

            Map<String, Object> processMap = new HashMap<>(5);

            processMap.put("name", process.getName());
            processMap.put("pid", process.getProcessID());
            processMap.put("cpu", this.oshiMonitor.formatDouble(process.getProcessCpuLoadCumulative()));

            processMapList.add(processMap);

        }

        OSHIInfoMap.put(infoType, processMapList);

    }

    @SneakyThrows
    public void appendHardwareAbstractionLayer(String infoType, Map<String, Object> OSHIInfoMap) {

        Map<String, Object> hardwareAbstractionLayerMap = new HashMap<>();

        hardwareAbstractionLayerMap.put("memory", this.oshiMonitor.getHardwareAbstractionLayer().getMemory());
        hardwareAbstractionLayerMap.put("sensors", this.oshiMonitor.getHardwareAbstractionLayer().getSensors());
        hardwareAbstractionLayerMap.put("logicalVolumeGroups", this.oshiMonitor.getHardwareAbstractionLayer().getLogicalVolumeGroups());
        hardwareAbstractionLayerMap.put("soundCards", this.oshiMonitor.getHardwareAbstractionLayer().getSoundCards());
        hardwareAbstractionLayerMap.put("graphicsCards", this.oshiMonitor.getHardwareAbstractionLayer().getGraphicsCards());
        hardwareAbstractionLayerMap.put("displays", this.oshiMonitor.getHardwareAbstractionLayer().getDisplays());
        hardwareAbstractionLayerMap.put("diskStores", this.oshiMonitor.getHardwareAbstractionLayer().getDiskStores());
        hardwareAbstractionLayerMap.put("powerSources", this.oshiMonitor.getHardwareAbstractionLayer().getPowerSources());
        hardwareAbstractionLayerMap.put("networkIFs", this.oshiMonitor.getHardwareAbstractionLayer().getNetworkIFs());

        OSHIInfoMap.put(infoType, hardwareAbstractionLayerMap);

    }

    @SneakyThrows
    public void appendDataInOSHIInfoMap(String infoType, Map<String, Object> OSHIInfoMap) {

        switch (infoType) {

            // 系统信息
            case "sysInfo":

                OSHIInfoMap.put(infoType, this.oshiMonitor.getSysInfo());

                break;

            // CPU 信息
            case "cpuInfo":

                OSHIInfoMap.put(infoType, this.oshiMonitor.getCpuInfo());

                break;

            // 磁盘信息
            case "diskInfoList":

                OSHIInfoMap.put(infoType, this.oshiMonitor.getDiskInfos());

                break;

            // JVM 虚拟机信息
            case "jvmInfo":

                OSHIInfoMap.put(infoType, this.oshiMonitor.getJvmInfo());

                break;

            // 内存信息
            case "memoryInfo":

                OSHIInfoMap.put(infoType, this.oshiMonitor.getMemoryInfo());

                break;

            // 网络带宽信息
            case "netBandwidthInfo":

                OSHIInfoMap.put(infoType, this.oshiMonitor.getNetIoInfo());

                break;

            // 所有磁盘的使用率信息
            case "allDiskUsePercent":

                this.appendAllDiskUsePercent(infoType, OSHIInfoMap);

                break;

            // 系统前10个进程信息
            case "processList":

                this.appendProcessList(10, infoType, OSHIInfoMap);

                break;

            // 计算机系统信息
            case "computerSystem":

                OSHIInfoMap.put(infoType, this.oshiMonitor.getComputerSystem());

                break;

            // 中央处理器信息
            case "centralProcessor":

                OSHIInfoMap.put(infoType, this.oshiMonitor.getCentralProcessor());

                break;

            // 硬件抽象层信息
            case "hardwareAbstractionLayer":
                
                this.appendHardwareAbstractionLayer(infoType, OSHIInfoMap);

                break;

            // 系统属性信息
            case "systemProperties":

                OSHIInfoMap.put(infoType, this.oshiMonitor.getSystemProperties());

                break;

        }

    }

    @SneakyThrows
    // get oshi info function
    public Map<String, Object> GetOSHIInfo(List<String> infoTypeList) {

        Map<String, Object> OSHIInfoMap = new HashMap<>(5);

        for (String infoType: infoTypeList) {

            this.appendDataInOSHIInfoMap(infoType, OSHIInfoMap);

        }

        return OSHIInfoMap;

    }

}

2.2 测试接口

package com.mbtxtq.app.controller.test;

import com.mbtxtq.app.utils.OSHIMonitorUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

@Controller
@CrossOrigin(origins = "*")
@ResponseBody
@RequestMapping("/app")
public class TestController {

    @Autowired
    private OSHIMonitorUtil oshiMonitorUtil;

    @PostMapping("test")
    public Map<String, Object> test() {

        List<String> infoTypeList = Arrays.asList(
                "sysInfo", "cpuInfo", "diskInfoList", "jvmInfo", "memoryInfo", 
                "netBandwidthInfo", "allDiskUsePercent", "processList", "computerSystem",
                "centralProcessor", "hardwareAbstractionLayer", "systemProperties"
        );

        return this.oshiMonitorUtil.GetOSHIInfo(infoTypeList);

    }

}

三、返回数据的字段含义

3.1 sysInfo

  • 示例数据
{

	"sysInfo": {
		"name": "nikolas",
        "ip": "192.168.1.49",
        "osName": "Windows 11",
        "osArch": "amd64",
        "userDir": "E:\\Program\\xuanyong\\xy_java\\xy_mbtxtq"
	}

}
  • 字段含义

属性

说明

name

系统名称

ip

系统ip

osName

操作系统

osArch

系统类型

userDir

项目路径

3.2 cpuInfo

  • 示例数据
{

	"cpuInfo": {
		"physicalProcessorCount": 8,
        "logicalProcessorCount": 16,
        "systemPercent": 0.0,
        "userPercent": 0.0,
        "waitPercent": 0.0,
        "usePercent": 0.01
	}

}
  • 字段含义

属性

说明

physicalProcessorCount

物理处理器数量

logicalProcessorCount

逻辑处理器数量

systemPercent

系统使用率

userPercent

用户使用率

waitPercent

当前等待率

usePercent

当前使用率

3.3 diskInfoList

  • 示例数据
{
		
	"diskInfoList": [
		{
            "name": "本地固定磁盘 (C:)",
            "volume": "\\\\?\\Volume{d5aebaac-2946-4457-8459-d4ed3dc6a3fa}\\",
            "label": "",
            "logicalVolume": "",
            "mount": "C:\\",
            "description": "Fixed drive",
            "options": "rw,reparse,sparse,trans,journaled,quota,casess,oids,casepn,efs,streams,unicode,acls,fcomp",
            "type": "NTFS",
            "size": "115.56GB",
            "totalSpace": 124077993984,
            "used": "76.57GB",
            "usableSpace": 41862868992,
            "avail": "38.99GB",
            "usePercent": 66.26,
            "uuid": "d5aebaac-2946-4457-8459-d4ed3dc6a3fa"
        },
        {
            "name": "本地固定磁盘 (D:)",
            "volume": "\\\\?\\Volume{96d13f83-6f31-44a1-bccd-0630c9717cc6}\\",
            "label": "新加卷",
            "logicalVolume": "",
            "mount": "D:\\",
            "description": "Fixed drive",
            "options": "rw,reparse,sparse,trans,journaled,quota,casess,oids,casepn,efs,streams,unicode,acls,fcomp",
            "type": "NTFS",
            "size": "150GB",
            "totalSpace": 161061269504,
            "used": "86.3GB",
            "usableSpace": 68394098688,
            "avail": "63.7GB",
            "usePercent": 57.54,
            "uuid": "96d13f83-6f31-44a1-bccd-0630c9717cc6"
        },
        {
            "name": "本地固定磁盘 (E:)",
            "volume": "\\\\?\\Volume{b9fdb2d2-6163-4b87-af2c-861f4f592df3}\\",
            "label": "新加卷",
            "logicalVolume": "",
            "mount": "E:\\",
            "description": "Fixed drive",
            "options": "rw,reparse,sparse,trans,journaled,quota,casess,oids,casepn,efs,streams,unicode,acls,fcomp",
            "type": "NTFS",
            "size": "210GB",
            "totalSpace": 225485778944,
            "used": "67.69GB",
            "usableSpace": 152802652160,
            "avail": "142.31GB",
            "usePercent": 32.23,
            "uuid": "b9fdb2d2-6163-4b87-af2c-861f4f592df3"
        },
        {
            "name": "光盘 (F:)",
            "volume": "",
            "label": "",
            "logicalVolume": "",
            "mount": "F:\\",
            "description": "CD-ROM",
            "options": "rw",
            "type": "",
            "uuid": "",
            "size": "0KB",
            "totalSpace": 0,
            "used": "0KB",
            "usableSpace": 0,
            "avail": "0KB",
            "usePercent": 0.0
        }
	]
	
}
  • 字段含义

属性

说明

name

磁盘名称

volume

文件系统的卷名

label

标签

logicalVolume

文件系统的逻辑卷名

mount

文件系统的挂载点

description

文件系统的描述

options

文件系统的选项

type

文件系统的类型(FAT、NTFS、etx2、ext4等)

uuid

UUID/GUID

size

分区大小(字符串类型,例如 1GB)

totalSpace

分区大小(Long类型原始值)

used

已使用空间

usableSpace

可用空间(Long类型原始值)

avail

可用空间

usePercent

已使用百分比

3.4 jvmInfo

  • 示例数据
{
	
	"jvmInfo": {
        "jdkVersion": "11.0.15",
        "jdkHome": "D:\\Java\\jdk-11.0.15",
        "jdkName": "Java HotSpot(TM) 64-Bit Server VM",
        "jvmTotalMemory": "303MB",
        "maxMemory": "3.94GB",
        "freeMemory": "123.57MB",
        "usedMemory": "179.43MB",
        "usePercent": 0.59,
        "startTime": 1680832106714,
        "uptime": 11083
    }
	
}
  • 字段含义

属性

说明

jdkVersion

jdk版本

jdkHome

jdk安装目录

jdkName

jdk名称

jvmTotalMemory

总内存

maxMemory

Java虚拟机将尝试使用的最大内存量

freeMemory

空闲内存

usedMemory

已使用内存

usePercent

内存使用率

startTime

返回Java虚拟机的启动时间(毫秒)。此属性返回Java虚拟机启动的大致时间。

uptime

返回Java虚拟机的正常运行时间(毫秒)

3.5 memoryInfo

  • 示例数据
{

	"memortInfo": {
		"total": "15.75GB",
        "used": "7.93GB",
        "free": "7.82GB",
        "usePercent": 0.5
	}

}
  • 字段含义

属性

说明

total

总计内存

used

已使用内存

free

未使用内存

usePercent

使用率

3.6 netBandwidthInfo

  • 示例数据
{

	"netBandwidthInfo": {
		"rxpck": "0",
        "txpck": "0",
        "rxbyt": "0",
        "txbyt": "0"
	}

}
  • 字段含义

属性

说明

rxpck

每秒钟接收的数据包,rxpck/s

txpck

每秒钟发送的数据包,txpck/s

rxbyt

每秒钟接收的KB数,rxkB/s

txbyt

每秒钟发送的KB数,txkB/s

3.7 allDiskUsePercent

  • 示例数据
{

	"allDiskUsePercent": 48.5

}
  • 字段含义

allDiskUsePercent(所有磁盘的使用率百分比)

3.8 processList

  • 示例数据
{

	"processList": [
        {
            "name": "Idle",
            "cpu": 6.6,
            "pid": 0
        },
        {
            "name": "java",
            "cpu": 1.11,
            "pid": 13332
        },
        {
            "name": "Nuts",
            "cpu": 0.12,
            "pid": 768
        },
        {
            "name": "idea64",
            "cpu": 0.09,
            "pid": 10500
        }
    ]

}
  • 字段含义

属性

说明

name

该进程名称

cpu

该进程cpu使用率

pid

该进程pid

3.9 computerSystem

  • 示例数据
{

	"computerSystem": {
	
        "firmware": {
            "name": "Q3HC10.06",
            "version": "THTFPC - 1072009",
            "description": "Q3HC10.06",
            "manufacturer": "American Megatrends Inc.",
            "releaseDate": "2022-01-21"
        },
        "baseboard": {
            "version": "Default string be filled by O.E.M",
            "model": "unknown",
            "serialNumber": "Default string be filled by O.E.M",
            "manufacturer": "MECHREVO"
        },
        "model": "Code10-7BB6U",
        "serialNumber": "421108Z0L735432474C",
        "manufacturer": "MECHREVO",
        "hardwareUUID": "03000200-0400-0500-0006-000700080009"
    
    }

}
  • 字段含义
  1. firware(固件信息)

属性

说明

name

固件名称

version

固件版本

describe

固件描述

manufacturer

制造商

releaseDate

发行日期

  1. baseboard(主板)

属性

说明

version

主板版本

model

模型

serialNumber

序列号

manufacturer

制造商

  1. model(型号)
  2. serialNumber(序列号)
  3. manufacturer(制造商)
  4. hardwareUUID(硬件UUID)

3.10 centralProcessor

  • 示例数据
{

	"centralProcessor": {
        "maxFreq": 2304000000,
        "currentFreq": [
            2304000000,
            2304000000,
            2304000000,
            2304000000,
            2096640000,
            2304000000,
            2304000000,
            2304000000,
            2304000000,
            2304000000,
            2304000000,
            2304000000,
            2304000000,
            2304000000,
            2304000000,
            2304000000
        ],
        "contextSwitches": 269854055,
        "interrupts": 259445284,
        "systemCpuLoadTicks": [
            5879118,
            0,
            1334806,
            629557509,
            0,
            29103,
            31025,
            0
        ],
        "processorCpuLoadTicks": [
            [
                300765,
                0,
                61031,
                39409890,
                0,
                15703,
                14781,
                0
            ],
            [
                158343,
                0,
                25046,
                39616921,
                0,
                765,
                906,
                0
            ]
        ],
        "physicalPackageCount": 1,
        "physicalProcessorCount": 2,
        "logicalProcessorCount": 2,
        "logicalProcessors": [
            {
                "processorNumber": 0,
                "physicalProcessorNumber": 0,
                "physicalPackageNumber": 0,
                "numaNode": 0,
                "processorGroup": 0
            },
            {
                "processorNumber": 1,
                "physicalProcessorNumber": 0,
                "physicalPackageNumber": 0,
                "numaNode": 0,
                "processorGroup": 0
            }
        ],
        "physicalProcessors": [
            {
                "physicalPackageNumber": 0,
                "physicalProcessorNumber": 0,
                "efficiency": 0,
                "idString": "BFEBFBFF000806D1"
            },
            {
                "physicalPackageNumber": 0,
                "physicalProcessorNumber": 1,
                "efficiency": 0,
                "idString": "BFEBFBFF000806D1"
            }
        ],
        "processorIdentifier": {
            "processorID": "BFEBFBFF000806D1",
            "cpu64bit": true,
            "name": "11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz",
            "family": "6",
            "identifier": "Intel64 Family 6 Model 141 Stepping 1",
            "vendor": "GenuineIntel",
            "model": "141",
            "microarchitecture": "unknown",
            "stepping": "1",
            "vendorFreq": 2304000000
        }
    }

}
  • 字段含义
  1. maxFreq(CPU最大频率)
  2. currentFreq(CPU当前频率)
  3. contextSwitches(上下文切换次数)
  4. interrupts(中断次数)
  5. systemCpuLoadTicks(系统CPU加载次数)
  6. processorCpuLoadTicks(核心CPU加载次数)
  7. physicalPackageCount(物理包数)
  8. physicalProcessorCount(物理处理器数)
  9. logicalProcessorCount(逻辑处理器数)
  10. logicalProcessors(逻辑处理器)

属性

说明

processorNumber

处理器序号

physicalProcessorNumber

物理处理器数

physicalPackageNumber

物理包数

numaNode

NUMA节点

processorGroup

处理器组

  1. physicalProcessors(物理处理器)

属性

说明

physicalPackageNumber

物理包数

physicalProcessorNumber

物理处理器数

efficiency

效率

idString

字符串id

  1. processorIdentifier(处理器标识符)

属性

说明

processorID

处理器编号

CPU4bit

是否是64位系统

name

名称

family


identifier

标识符

vendor

厂家

model

型号

microarchitecture

微架构

stepping

步进

vendorFreq

厂家频率

3.11 hardwareAbstractionLayer

  • 示例数据
{

	"hardwareAbstractionLayer": {
        "graphicsCards": [
            {
                "name": "Intel(R) UHD Graphics",
                "deviceId": "0x9a60",
                "vendor": "Intel Corporation (0x8086)",
                "versionInfo": "DriverVersion=31.0.101.3430",
                "vram": 1073741824
            }
        ],
        "memory": {
            "available": 4980723712,
            "pageSize": 4096,
            "virtualMemory": {
                "swapTotal": 5202763776,
                "swapUsed": 106127360,
                "virtualMax": 22112124928,
                "swapPagesOut": 105608,
                "virtualInUse": 18441445376,
                "swapPagesIn": 12599190
            },
            "physicalMemory": [
                {
                    "bankLabel": "BANK 0",
                    "capacity": 8589934592,
                    "clockSpeed": 3200000000,
                    "manufacturer": "Crucial Technology",
                    "memoryType": "DDR4"
                },
                {
                    "bankLabel": "BANK 0",
                    "capacity": 8589934592,
                    "clockSpeed": 3200000000,
                    "manufacturer": "Crucial Technology",
                    "memoryType": "DDR4"
                }
            ],
            "total": 16909361152
        },
        "sensors": {
            "cpuTemperature": 0.0,
            "fanSpeeds": [
                0,
                0,
                0
            ],
            "cpuVoltage": 0.0
        },
        "diskStores": [
            {
                "name": "\\\\.\\PHYSICALDRIVE0",
                "model": "SAMSUNG MZVL2512HCJQ-00B00 (标准磁盘驱动器)",
                "serial": "0025_38BA_1100_9AA3.",
                "size": 512105932800,
                "reads": 2205157,
                "readBytes": 46884032000,
                "writes": 1012810,
                "writeBytes": 44018597888,
                "currentQueueLength": 0,
                "transferTime": 1211195,
                "timeStamp": 1680847862341,
                "partitions": [
                    {
                        "identification": "磁盘 #0,分区 #2",
                        "name": "GPT: Basic Data",
                        "type": "GPT: 基本数据",
                        "uuid": "d5aebaac-2946-4457-8459-d4ed3dc6a3fa",
                        "size": 124077998080,
                        "major": 0,
                        "minor": 2,
                        "mountPoint": "C:\\"
                    },
                    {
                        "identification": "磁盘 #0,分区 #3",
                        "name": "GPT: Basic Data",
                        "type": "GPT: 基本数据",
                        "uuid": "96d13f83-6f31-44a1-bccd-0630c9717cc6",
                        "size": 161061273600,
                        "major": 0,
                        "minor": 3,
                        "mountPoint": "D:\\"
                    },
                    {
                        "identification": "磁盘 #0,分区 #4",
                        "name": "GPT: Basic Data",
                        "type": "GPT: 基本数据",
                        "uuid": "b9fdb2d2-6163-4b87-af2c-861f4f592df3",
                        "size": 225485783040,
                        "major": 0,
                        "minor": 4,
                        "mountPoint": "E:\\"
                    }
                ]
            }
        ],
        "powerSources": [
            {
                "name": "System Battery",
                "deviceName": "Smart-BAT",
                "remainingCapacityPercent": 0.9676456101465337,
                "timeRemainingEstimated": -1.0,
                "timeRemainingInstant": -1.0,
                "powerUsageRate": 0.0,
                "voltage": 12.86,
                "amperage": 0.0,
                "powerOnLine": true,
                "charging": false,
                "discharging": true,
                "capacityUnits": "MWH",
                "currentCapacity": 62843,
                "maxCapacity": 64968,
                "designCapacity": 70050,
                "cycleCount": 0,
                "chemistry": "LION",
                "manufactureDate": null,
                "manufacturer": "Ganfeng",
                "serialNumber": "676482",
                "temperature": 0.0
            }
        ],
        "networkIFs": [
            {
                "name": "eth0",
                "displayName": "VMware Virtual Ethernet Adapter for VMnet1",
                "index": 4,
                "mtu": 1500,
                "subnetMasks": [
                    24
                ],
                "prefixLengths": [
                    64
                ],
                "ifType": 6,
                "ndisPhysicalMediumType": 14,
                "connectorPresent": false,
                "bytesRecv": 42,
                "bytesSent": 4017,
                "packetsRecv": 42,
                "packetsSent": 39,
                "inErrors": 0,
                "outErrors": 0,
                "inDrops": 0,
                "collisions": 0,
                "speed": 100000000,
                "timeStamp": 1680847862638,
                "ifAlias": "VMware Network Adapter VMnet1",
                "ifOperStatus": "UP",
                "ipv6addr": [
                    "fe80:0:0:0:b1b6:9cd:40fc:18eb"
                ],
                "macaddr": "00:50:56:c0:00:01",
                "ipv4addr": [
                    "192.168.44.1"
                ],
                "knownVmMacAddr": true
            },
            {
                "name": "eth1",
                "displayName": "VMware Virtual Ethernet Adapter for VMnet8",
                "index": 8,
                "mtu": 1500,
                "subnetMasks": [
                    24
                ],
                "prefixLengths": [
                    64
                ],
                "ifType": 6,
                "ndisPhysicalMediumType": 14,
                "connectorPresent": false,
                "bytesRecv": 0,
                "bytesSent": 3995,
                "packetsRecv": 0,
                "packetsSent": 0,
                "inErrors": 0,
                "outErrors": 0,
                "inDrops": 0,
                "collisions": 0,
                "speed": 100000000,
                "timeStamp": 1680847862642,
                "ifAlias": "VMware Network Adapter VMnet8",
                "ifOperStatus": "UP",
                "ipv6addr": [
                    "fe80:0:0:0:a9bc:3a3a:b5d0:1090"
                ],
                "macaddr": "00:50:56:c0:00:08",
                "ipv4addr": [
                    "192.168.2.1"
                ],
                "knownVmMacAddr": true
            },
            {
                "name": "wlan1",
                "displayName": "Intel(R) Wi-Fi 6 AX201 160MHz",
                "index": 9,
                "mtu": 1500,
                "subnetMasks": [
                    24
                ],
                "prefixLengths": [
                    64
                ],
                "ifType": 71,
                "ndisPhysicalMediumType": 9,
                "connectorPresent": true,
                "bytesRecv": 14844177645,
                "bytesSent": 1177383246,
                "packetsRecv": 10697025,
                "packetsSent": 1587048,
                "inErrors": 0,
                "outErrors": 0,
                "inDrops": 0,
                "collisions": 0,
                "speed": 1729000000,
                "timeStamp": 1680847862646,
                "ifAlias": "WLAN",
                "ifOperStatus": "UP",
                "ipv6addr": [
                    "fe80:0:0:0:1059:e9ed:5fe3:e040"
                ],
                "macaddr": "98:43:fa:96:a5:69",
                "ipv4addr": [
                    "192.168.1.49"
                ],
                "knownVmMacAddr": false
            },
            {
                "name": "wlan2",
                "displayName": "Microsoft Wi-Fi Direct Virtual Adapter #3",
                "index": 12,
                "mtu": 1500,
                "subnetMasks": [],
                "prefixLengths": [
                    64
                ],
                "ifType": 71,
                "ndisPhysicalMediumType": 9,
                "connectorPresent": false,
                "bytesRecv": 0,
                "bytesSent": 0,
                "packetsRecv": 0,
                "packetsSent": 0,
                "inErrors": 0,
                "outErrors": 0,
                "inDrops": 0,
                "collisions": 0,
                "speed": 0,
                "timeStamp": 1680847862649,
                "ifAlias": "本地连接* 1",
                "ifOperStatus": "DOWN",
                "ipv6addr": [
                    "fe80:0:0:0:937d:b136:db48:edd9"
                ],
                "macaddr": "98:43:fa:96:a5:6a",
                "ipv4addr": [],
                "knownVmMacAddr": false
            },
            {
                "name": "wlan4",
                "displayName": "Microsoft Wi-Fi Direct Virtual Adapter #4",
                "index": 20,
                "mtu": 1500,
                "subnetMasks": [],
                "prefixLengths": [
                    64
                ],
                "ifType": 71,
                "ndisPhysicalMediumType": 9,
                "connectorPresent": false,
                "bytesRecv": 0,
                "bytesSent": 0,
                "packetsRecv": 0,
                "packetsSent": 0,
                "inErrors": 0,
                "outErrors": 0,
                "inDrops": 0,
                "collisions": 0,
                "speed": 0,
                "timeStamp": 1680847862653,
                "ifAlias": "本地连接* 2",
                "ifOperStatus": "DOWN",
                "ipv6addr": [
                    "fe80:0:0:0:9cad:9b1d:25c1:b520"
                ],
                "macaddr": "9a:43:fa:96:a5:69",
                "ipv4addr": [],
                "knownVmMacAddr": false
            }
        ],
        "soundCards": [
            {
                "name": "Intel(R) Corporation 适用于 USB 音频的英特尔® 智音技术",
                "codec": "适用于 USB 音频的英特尔® 智音技术",
                "driverVersion": "IntcUSB.sys 10.29.0.6040"
            },
            {
                "name": "Intel(R) Corporation 适用于 I2S 音频的英特尔® 智音技术",
                "codec": "适用于 I2S 音频的英特尔® 智音技术",
                "driverVersion": "IntcSST.sys 10.29.0.6040"
            },
            {
                "name": "Intel(R) Corporation 适用于数字麦克风的英特尔® 智音技术",
                "codec": "适用于数字麦克风的英特尔® 智音技术",
                "driverVersion": "IntcDMic.sys 10.29.0.6040"
            },
            {
                "name": "Microsoft Microsoft Bluetooth A2dp Source",
                "codec": "Microsoft Bluetooth A2dp Source",
                "driverVersion": "BthA2dp.sys 10.0.22621.1"
            },
            {
                "name": "Intel Corporation HD Audio Driver for Display Audio",
                "codec": "HD Audio Driver for Display Audio",
                "driverVersion": "AcxHdAudio.sys 31.0.101.3430"
            },
            {
                "name": "Microsoft USB Audio Device",
                "codec": "USB Audio Device",
                "driverVersion": "USBAUDIO.sys 10.0.22621.608"
            }
        ],
        "displays": [
            {
                "edid": "AP///wAObwEWAAAAAAAeAQSlIhZ4A+6Vo1RMmSYPUFQAAAABAQEBAQEBAQEBAQEBAQEB/9cAoKBAXmAwIDYAWdcQAAAYAAAA/QAweMvLNwEKICAgICAgAAAA/gBDU09UIFQzCiAgICAgAAAA/gBNTkcwMDdEQTEtMgogAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="
            }
        ],
        "logicalVolumeGroups": []
    }

}
  • 字段含义
  1. graphicsCards(显卡信息)

属性

说明

name

名称

deviceId

设备号

vendor

制造商

versionInfo

版本信息

vram

显示储存器

  1. memory(内存信息)
  2. sensors(传感器信息)

属性

说明

cpuTemperature

CPU温度

fanSpeeds

风扇转速

cpuVoltage

CPU电压

  1. diskStores(磁盘存储信息)
  2. powerSources(电源信息)
  3. networkIFs(网卡信息)
  4. soundCards(声卡信息)

属性

说明

name

名称

codec

编译解码器

driverVersion

驱动版本

  1. displays(显示器信息)
  2. logicalVolumeGroups(逻辑卷组信息)

3.12 systemProperties

  • 示例数据
{

	"systemProperties": {
        "sun.desktop": "windows",
        "awt.toolkit": "sun.awt.windows.WToolkit",
        "java.specification.version": "11",
        "sun.cpu.isalist": "amd64",
        "sun.jnu.encoding": "GBK",
        "java.class.path": "E:\\Program\\xuanyong\\xy_java\\xy_mbtxtq\\target\\classes;D:\\mvn_repository\\org\\springframework\\boot\\spring-boot-starter-web\\2.7.6\\spring-boot-starter-web-2.7.6.jar;D:\\mvn_repository\\org\\springframework\\boot\\spring-boot-starter\\2.7.6\\spring-boot-starter-2.7.6.jar;",
        "java.vm.vendor": "Oracle Corporation",
        "sun.arch.data.model": "64",
        "user.variant": "",
        "java.vendor.url": "https://openjdk.java.net/",
        "catalina.useNaming": "false",
        "user.timezone": "Asia/Shanghai",
        "os.name": "Windows 11",
        "java.vm.specification.version": "11",
        "sun.java.launcher": "SUN_STANDARD",
        "user.country": "CN",
        "sun.boot.library.path": "D:\\Java\\jdk-11.0.15\\bin",
        "sun.java.command": "com.mbtxtq.app.MainApplication",
        "jdk.debug": "release",
        "sun.cpu.endian": "little",
        "user.home": "C:\\Users\\17700",
        "user.language": "zh",
        "java.specification.vendor": "Oracle Corporation",
        "java.version.date": "2022-04-19",
        "java.home": "D:\\Java\\jdk-11.0.15",
        "file.separator": "\\",
        "java.vm.compressedOopsMode": "Zero based",
        "line.separator": "\r\n",
        "java.specification.name": "Java Platform API Specification",
        "java.vm.specification.vendor": "Oracle Corporation",
        "FILE_LOG_CHARSET": "UTF-8",
        "java.awt.graphicsenv": "sun.awt.Win32GraphicsEnvironment",
        "java.awt.headless": "true",
        "user.script": "",
        "sun.management.compiler": "HotSpot 64-Bit Tiered Compilers",
        "java.runtime.version": "11.0.15+8-LTS-149",
        "user.name": "17700",
        "path.separator": ";",
        "os.version": "10.0",
        "java.runtime.name": "Java(TM) SE Runtime Environment",
        "file.encoding": "UTF-8",
        "spring.beaninfo.ignore": "true",
        "java.vm.name": "Java HotSpot(TM) 64-Bit Server VM",
        "java.vendor.version": "18.9",
        "java.vendor.url.bug": "https://bugreport.java.com/bugreport/",
        "java.io.tmpdir": "C:\\Users\\17700\\AppData\\Local\\Temp\\",
        "catalina.home": "C:\\Users\\17700\\AppData\\Local\\Temp\\tomcat.8088.12187551628899921344",
        "com.zaxxer.hikari.pool_number": "1",
        "java.version": "11.0.15",
        "user.dir": "E:\\Program\\xuanyong\\xy_java\\xy_mbtxtq",
        "os.arch": "amd64",
        "java.vm.specification.name": "Java Virtual Machine Specification",
        "PID": "4976",
        "java.awt.printerjob": "sun.awt.windows.WPrinterJob",
        "sun.os.patch.level": "",
        "CONSOLE_LOG_CHARSET": "UTF-8",
        "catalina.base": "C:\\Users\\17700\\AppData\\Local\\Temp\\tomcat.8088.12187551628899921344",
        "java.library.path": "D:\\Java\\jdk-11.0.15\\bin;D:\\Mongodb\\Server\\4.4\\bin;D:\\Microsoft VS Code\\bin;C:\\Users\\17700\\.dotnet\\tools;.",
        "java.vendor": "Oracle Corporation",
        "java.vm.info": "mixed mode",
        "java.vm.version": "11.0.15+8-LTS-149",
        "sun.io.unicode.encoding": "UnicodeLittle",
        "java.class.version": "55.0"
    }

}
  • 字段含义

属性

说明

sun.desktop

操作系统信息

awt.toolkit

java.specification.version

java规范版本

sun.cpu.isalist

sun.jnu.encoding

JNU编码

java.class.path

java类包的路径

java.vm.vendor

java虚拟机制造商

sun.arch.data.model

user.variant

java.vendor.url

java制造商官网

catalina.useNaming

user.timezone

用户时区

os.name

操作系统名称

java.vm.specification.version

java虚拟机规范版本

sun.java.launcher

user.country

用户国家

sun.boot.library.path

jdk bin目录

sun.java.command

java命令入口类

jdk.debug

sun.cpu.endian

user.home

用户根目录

user.language

用户语言

java.specification.vendor

java规范制造商

java.version.date

java版本日期

java.home

jdk根目录

file.separator

文件分离符

java.vm.compressedOopsMode

line.separator

换行分离符

java.specification.name

java规范名称

java.vm.specification.vendor

java虚拟机规范制造商

FILE_LOG_CHARSET

日志文件编码

java.awt.graphicsenv

java.awt.headless

user.script

用户脚本

sun.management.compiler

java.runtime.version

java运行环境版本

user.name

用户名称

path.separator

分离java.class.path 和 java.library.path 的字符

os.version

操作系统版本

java.runtime.name

java运行环境名称

file.encoding

文件编码

spring.beaninfo.ignore

java.vm.name

java虚拟机名称

java.vendor.version

java制造商版本

java.vendor.url.bug

java制造商反馈bug网址

java.io.tmpdir

java临时储存目录

catalina.home

com.zaxxer.hikari.pool_number

java.version

java版本

user.dir

工程根目录

os.arch

32位/64位

java.vm.specification.name

java虚拟机规范名称

PID

java.awt.printerjob

sun.os.patch.level

CONSOLE_LOG_CHARSET

catalina.base

java.library.path

依赖路径

java.vendor

java制造商

java.vm.info

java虚拟机信息

java.vm.version

java虚拟机版本

sun.io.unicode.encoding

java.class.version

java类版本