[comment]: # translation:outdated

[comment]: # ({f219345d-c7fb170a})
# 11 使用 WMI 进行发现 queries

[comment]: # ({/f219345d-c7fb170a})

[comment]: # ({0480597d-0480597d})
#### 概述

[WMI](https://en.wikipedia.org/wiki/Windows_Management_Instrumentation) 是 Windows 中一个强大的接口，可用于获取有关 Windows 组件、服务状态和已安装软件的各种信息。

它可以用于物理磁盘发现及其性能数据收集、网络接口发现、Hyper-V 客户机发现、监控 Windows 服务以及 Windows 操作系统中的许多其他功能。

此类低级别 [discovery](/manual/discovery/low_level_discovery) 使用 WQL queries 实现，其结果通过 get 自动转换为适用于低级别发现的 JSON object。

[comment]: # ({/0480597d-0480597d})

[comment]: # ({4ccad3a6-6f6dd25b})
#### 监控项键

在 [发现规则](/manual/discovery/low_level_discovery#发现规则) 中使用的 监控项 是

    wmi.getall[<namespace>,<query>]

此 [item](/manual/config/items/itemtypes/zabbix_agent/win_keys) 将 query 结果转换为 JSON array。例如：

    select * from Win32_DiskDrive where Name like '%PHYSICALDRIVE%'

可能会返回如下内容：


```json
[
    {
        "DeviceID" : "\\.\PHYSICALDRIVE0",
        "BytesPerSector" : 512,
        "Capabilities" : [
            3,
            4
        ],
        "CapabilityDescriptions" : [
            "Random Access",
            "Supports Writing"
        ],
        "Caption" : "VBOX HARDDISK ATA Device",
        "ConfigManagerErrorCode" : 0,
        "ConfigManagerUserConfig" : "False",
        "CreationClassName" : "Win32_DiskDrive",
        "Description" : "Disk drive",
        "FirmwareRevision" : "1.0",
        "Index" : 0,
        "InterfaceType" : "IDE"
    },
    {
        "DeviceID" : "\\.\PHYSICALDRIVE1",
        "BytesPerSector" : 512,
        "Capabilities" : [
            3,
            4
        ],
        "CapabilityDescriptions" : [
            "Random Access",
            "Supports Writing"
        ],
        "Caption" : "VBOX HARDDISK ATA Device",
        "ConfigManagerErrorCode" : 0,
        "ConfigManagerUserConfig" : "False",
        "CreationClassName" : "Win32_DiskDrive",
        "Description" : "Disk drive",
        "FirmwareRevision" : "1.0",
        "Index" : 1,
        "InterfaceType" : "IDE"
    }
]
```

[comment]: # ({/4ccad3a6-6f6dd25b})

[comment]: # ({ff2d13fa-ff2d13fa})
#### 低级发现宏

尽管在返回的JSON中没有创建低级别自动发现宏，但用户可以在后续步骤中使用指向返回JSON中已发现值的JSONPath，通过[自定义宏](/manual/discovery/low_level_discovery#自定义宏)功能手动定义这些宏。

然后，这些宏可以用于create 监控项、触发器等原型。

[comment]: # ({/ff2d13fa-ff2d13fa})
