当前位置:   article > 正文

SpringBoot进行系统监控(通过OSHI)_springboot oshi

springboot oshi

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>
  • 1
  • 2
  • 3
  • 4
  • 5

二、编写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;

    }

}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203

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);

    }

}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34

三、返回数据的字段含义

3.1 sysInfo

  • 示例数据
{

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

}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 字段含义
属性说明
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
	}

}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 字段含义
属性说明
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
        }
	]
	
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 字段含义
属性说明
name磁盘名称
volume文件系统的卷名
label标签
logicalVolume文件系统的逻辑卷名
mount文件系统的挂载点
description文件系统的描述
options文件系统的选项
type文件系统的类型(FAT、NTFS、etx2、ext4等)
uuidUUID/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
    }
	
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 字段含义
属性说明
jdkVersionjdk版本
jdkHomejdk安装目录
jdkNamejdk名称
jvmTotalMemory总内存
maxMemoryJava虚拟机将尝试使用的最大内存量
freeMemory空闲内存
usedMemory已使用内存
usePercent内存使用率
startTime返回Java虚拟机的启动时间(毫秒)。此属性返回Java虚拟机启动的大致时间。
uptime返回Java虚拟机的正常运行时间(毫秒)

3.5 memoryInfo

  • 示例数据
{

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

}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 字段含义
属性说明
total总计内存
used已使用内存
free未使用内存
usePercent使用率

3.6 netBandwidthInfo

  • 示例数据
{

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

}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 字段含义
属性说明
rxpck每秒钟接收的数据包,rxpck/s
txpck每秒钟发送的数据包,txpck/s
rxbyt每秒钟接收的KB数,rxkB/s
txbyt每秒钟发送的KB数,txkB/s

3.7 allDiskUsePercent

  • 示例数据
{

	"allDiskUsePercent": 48.5

}
  • 1
  • 2
  • 3
  • 4
  • 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
        }
    ]

}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 字段含义
属性说明
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
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 字段含义
  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
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 字段含义
  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物理包数
numaNodeNUMA节点
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
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 字段含义
  1. graphicsCards(显卡信息)
属性说明
name名称
deviceId设备号
vendor制造商
versionInfo版本信息
vram显示储存器
  1. memory(内存信息)

  2. sensors(传感器信息)

属性说明
cpuTemperatureCPU温度
fanSpeeds风扇转速
cpuVoltageCPU电压
  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"
    }

}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 字段含义
属性说明
sun.desktop操作系统信息
awt.toolkit
java.specification.versionjava规范版本
sun.cpu.isalist
sun.jnu.encodingJNU编码
java.class.pathjava类包的路径
java.vm.vendorjava虚拟机制造商
sun.arch.data.model
user.variant
java.vendor.urljava制造商官网
catalina.useNaming
user.timezone用户时区
os.name操作系统名称
java.vm.specification.versionjava虚拟机规范版本
sun.java.launcher
user.country用户国家
sun.boot.library.pathjdk bin目录
sun.java.commandjava命令入口类
jdk.debug
sun.cpu.endian
user.home用户根目录
user.language用户语言
java.specification.vendorjava规范制造商
java.version.datejava版本日期
java.homejdk根目录
file.separator文件分离符
java.vm.compressedOopsMode
line.separator换行分离符
java.specification.namejava规范名称
java.vm.specification.vendorjava虚拟机规范制造商
FILE_LOG_CHARSET日志文件编码
java.awt.graphicsenv
java.awt.headless
user.script用户脚本
sun.management.compiler
java.runtime.versionjava运行环境版本
user.name用户名称
path.separator分离java.class.path 和 java.library.path 的字符
os.version操作系统版本
java.runtime.namejava运行环境名称
file.encoding文件编码
spring.beaninfo.ignore
java.vm.namejava虚拟机名称
java.vendor.versionjava制造商版本
java.vendor.url.bugjava制造商反馈bug网址
java.io.tmpdirjava临时储存目录
catalina.home
com.zaxxer.hikari.pool_number
java.versionjava版本
user.dir工程根目录
os.arch32位/64位
java.vm.specification.namejava虚拟机规范名称
PID
java.awt.printerjob
sun.os.patch.level
CONSOLE_LOG_CHARSET
catalina.base
java.library.path依赖路径
java.vendorjava制造商
java.vm.infojava虚拟机信息
java.vm.versionjava虚拟机版本
sun.io.unicode.encoding
java.class.versionjava类版本
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/319736
推荐阅读
相关标签
  

闽ICP备14008679号