Home > Enterprise >  How to obtain specific WMI metric out of a given list
How to obtain specific WMI metric out of a given list

Time:10-05

I would like to monitor two specific metrics from an nVidia card (Encoder and Decoder Usage) From the nVidia manifest i've copied the following lines into a powershell:

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

But that iterates over a number of metrics and gives a large list with metrics:

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

How can I formulate the WMI command or pipe an instruction like grep so that i get the single result from the VideoEngine Decoder Usage and VideoEngine Encoder Usage? Those Encoder/Decoder Usage metrics seems to be part of a subclass called 'videoCodec' and could be requested via: Get-WmiObject -Class Gpu -ComputerName localhost -Namespace ROOT\cimv2\NV | Select-Object *

Which results in a list from which i only pasted the bottom part of it:

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             :

The idea is that i collect those two metrics into a monitoring system called zabbix, with the use of powershell scripting.

CodePudding user response:

It's all exists in the videoCodec property so just filter the results:

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

or shorter version:

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

Will results:

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