21 lines
1.3 KiB
PowerShell
21 lines
1.3 KiB
PowerShell
# Copyright 2024 Spearhead Systems SRL
|
|
#
|
|
# This goes in C:\ProgramData\checkmk\agent\plugins. It should be added automatically by
|
|
# baking a new MSI after setting "Agent Rules" > "Deploy Custom Files With Agent" with
|
|
# "Deploy Custom Files With Agent" including "amd_gpu".
|
|
|
|
foreach ($Item in Get-ChildItem "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}" -Name -Include 000*) {
|
|
$Name = Get-ItemPropertyValue "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\$Item" "DriverDesc"
|
|
if ($Name -match 'Radeon') {
|
|
$GpuBytesTotal = Get-ItemPropertyValue "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\$Item" "HardwareInformation.qwMemorySize"
|
|
$GpuRawName = Get-ItemPropertyValue "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\$Item" "HardwareInformation.AdapterString"
|
|
break
|
|
}
|
|
}
|
|
|
|
$GpuName = [System.Text.Encoding]::Unicode.GetString($GpuRawName)
|
|
$GpuPercent = (((Get-Counter "\GPU Engine(*)\Utilization Percentage" ).CounterSamples).CookedValue | measure -sum).sum
|
|
$GpuBytesUsed = (((Get-Counter "\GPU Process Memory(*)\Dedicated Usage").CounterSamples).CookedValue | measure -sum).sum
|
|
|
|
Write-Output "<<<amd_gpu:sep(0)>>>", $GpuName, $GpuPercent, $GpuBytesUsed, $GpuBytesTotal
|