【问题标题】:How to obtain specific WMI metric out of a given list如何从给定列表中获取特定的 WMI 指标
【发布时间】:2021-11-24 03:56:56
【问题描述】:

我想监控来自 nVidia 卡的两个特定指标(编码器和解码器使用情况) 从 nVidia 清单中,我将以下行复制到 powershell 中:

$gpus = Get-WmiObject -namespace "root\cimv2\nv" -class gpu
foreach($object in $gpus) # obtain an instance
{
$object.invokeMethod("info",$null)
}

但这会迭代多个指标并给出一个包含指标的大列表:

PS C:\Users\Administrator\Scripts> .\check.ps1
class: Gpu
class version: 2.4.0
object name: Quadro P2200
object ID: 1 (0x1)
GPU handle: 0xD800
GPU type: Quadro
GPU memory type: GDDR5X
Virtual memory size: 53488 MB
Physical memory size: 5120 MB
Available memory size: 1242 MB
Memory bus width: 160
Number of cores: 1280
Current GPU clock: 1754 MHz
Current Memory clock: 5005 MHz
Power consumed over sampling period: 29.369 Watt
Power sampling period: 1 ms
Number of power measurement samples: 1
The percentage of time where the GPU is considered busy: 21
The percentage of GPU memory utilization: 75
Video BIOS version: 86.6.77.0.5
Device Info: PCI\VEN_10DE&DEV_1C31&SUBSYS_131B1028&REV_A1
coolers: Cooler.id=1
thermal probes: ThermalProbe.id=1
ECC: Ecc.id=1
PCI-E current bus protocol generation: 3
PCI-E current width: 16 lanes
PCI-E current speed: 8000 Mbps
PCI-E maximum bus protocol generation: 3
PCI-E maximum width: 16 lanes
PCI-E maximum speed: 8000 Mbps
PCI-E downstream width: 16 lanes
VideoEngine Encoder usage: 76%
VideoEngine Decoder usage: 6%
VideoEngine Encoder sampling period: 167000 ms
VideoEngine Decoder sampling period: 167000 ms
VideoEngine Encoder sessions: 11
VideoEngine average FPS: 50
VideoEngine average latency: 1264 ms

如何制定 WMI 命令或管道指令(如 grep),以便从 VideoEngine Decoder Usage 和 VideoEngine Encoder Usage 获得单一结果? 这些编码器/解码器使用指标似乎是名为“videoCodec”的子类的一部分,可以通过以下方式请求:Get-WmiObject -Class Gpu -ComputerName localhost -Namespace ROOT\cimv2\NV |选择对象 *

这会产生一个列表,我只粘贴了它的底部:

productName           : Quadro P2200
productType           : 2
thermalProbes         : {ThermalProbe.id=1}
uname                 : Quadro P2200
ver                   : System.Management.ManagementBaseObject
verVBIOS              : System.Management.ManagementBaseObject
videoCodec            : System.Management.ManagementBaseObject
Scope                 : System.Management.ManagementScope
Path                  : \\DHC-AMPP-NODE13\ROOT\cimv2\NV:Gpu.id=1,uname="Quadro P2200"
Options               : System.Management.ObjectGetOptions
ClassPath             : \\DHC-AMPP-NODE13\ROOT\cimv2\NV:Gpu
Properties            : {archId, archName, coolers, coreCount...}
SystemProperties      : {__GENUS, __CLASS, __SUPERCLASS, __DYNASTY...}
Qualifiers            : {dynamic}
Site                  :
Container             :

我的想法是,我使用 powershell 脚本将这两个指标收集到一个名为 zabbix 的监控系统中。

【问题讨论】:

    标签: powershell wmi nvidia metrics zabbix


    【解决方案1】:

    这一切都存在于videoCodec 属性中,所以只需过滤结果:

    $gpus = (Get-WmiObject -namespace "root\cimv2\nv" -class gpu).videoCodec | 
    Select percentEncoderUsage,percentDecoderUsage,encoderSamplingPeriod,
    decoderSamplingPeriod,encoderSessionsCount,averageFps,averageLatency
    

    或更短的版本:

    $gpus = (Get-WmiObject -namespace "root\cimv2\nv" -class gpu).videoCodec | 
    Select *coder*,*average*
    

    会结果:

    percentEncoderUsage   : 0
    percentDecoderUsage   : 0
    encoderSamplingPeriod : 167000
    decoderSamplingPeriod : 167000
    encoderSessionsCount  : 0
    averageFps            : 0
    averageLatency        : 0
    

    【讨论】:

    • 谢谢!!由于缺乏声誉,无法支持您的答案。但是你成功了!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-10
    • 1970-01-01
    • 2020-06-13
    • 2022-01-20
    • 2016-11-27
    • 1970-01-01
    相关资源
    最近更新 更多