我想监控nVidia卡的两个特定指标(编码器和解码器使用)从nVidia清单中,我已经将以下行复制到powershell中:
$gpus = Get-WmiObject -namespace "rootcimv2nv" -class gpu
foreach($object in $gpus) # obtain an instance
{
$object.invokeMethod("info",$null)
}
但这迭代了许多指标,并给出了一个包含指标的大列表:
PS C:UsersAdministratorScripts> .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: PCIVEN_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中获得单一结果?这些编码器/解码器使用指标似乎是一个子类的一部分,称为"视频编解码器",可以通过以下方式请求:Get-WmiObject -Class Gpu -ComputerName localhost -Namespace ROOTcimv2NV | Select-Object *
结果是一个列表,我只粘贴了它的底部部分:
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-NODE13ROOTcimv2NV:Gpu.id=1,uname="Quadro P2200"
Options : System.Management.ObjectGetOptions
ClassPath : \DHC-AMPP-NODE13ROOTcimv2NV:Gpu
Properties : {archId, archName, coolers, coreCount...}
SystemProperties : {__GENUS, __CLASS, __SUPERCLASS, __DYNASTY...}
Qualifiers : {dynamic}
Site :
Container :
我的想法是将这两个指标收集到一个名为zabbix的监控系统中,使用powershell脚本。
这些都存在于videoCodec
属性中,所以只需过滤结果:
$gpus = (Get-WmiObject -namespace "rootcimv2nv" -class gpu).videoCodec |
Select percentEncoderUsage,percentDecoderUsage,encoderSamplingPeriod,
decoderSamplingPeriod,encoderSessionsCount,averageFps,averageLatency
或更短的版本:
$gpus = (Get-WmiObject -namespace "rootcimv2nv" -class gpu).videoCodec |
Select *coder*,*average*
将结果:
percentEncoderUsage : 0
percentDecoderUsage : 0
encoderSamplingPeriod : 167000
decoderSamplingPeriod : 167000
encoderSessionsCount : 0
averageFps : 0
averageLatency : 0