如何从给定列表中获取特定的 WMI 指标
How to obtain specific WMI metric out of a given list
我想监控来自 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 解码器使用情况和 VideoEngine 编码器使用情况中获得单一结果?
这些 Encoder/Decoder 使用指标似乎是名为 'videoCodec' 的子类的一部分,可以通过以下方式请求:Get-WmiObject -Class Gpu -ComputerName localhost -Namespace ROOT\cimv2\NV | Select-对象 *
结果是一个列表,我只粘贴了它的底部:
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 的监控系统中。
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
我想监控来自 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 解码器使用情况和 VideoEngine 编码器使用情况中获得单一结果? 这些 Encoder/Decoder 使用指标似乎是名为 'videoCodec' 的子类的一部分,可以通过以下方式请求:Get-WmiObject -Class Gpu -ComputerName localhost -Namespace ROOT\cimv2\NV | Select-对象 *
结果是一个列表,我只粘贴了它的底部:
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 的监控系统中。
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