Merge pull request #806 from tomsaleeba/tomsaleeba/nvidiagpu-additions

feat: add GPU usage % and GPU memory usage % to nvidiagpu
This commit is contained in:
tobi-wan-kenobi 2021-07-25 06:54:52 +02:00 committed by GitHub
commit f6dd17b383
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,7 +4,7 @@
Parameters:
* nvidiagpu.format: Format string (defaults to '{name}: {temp}°C %{usedmem}/{totalmem} MiB')
Available values are: {name} {temp} {mem_used} {mem_total} {fanspeed} {clock_gpu} {clock_mem}
Available values are: {name} {temp} {mem_used} {mem_total} {fanspeed} {clock_gpu} {clock_mem} {gpu_usage_pct} {mem_usage_pct}
Requires nvidia-smi
@ -41,6 +41,8 @@ class Module(core.module.Module):
clockMem = ""
clockGpu = ""
fanspeed = ""
gpuUsagePct = ""
memPct = ""
for item in sp.split("\n"):
try:
key, val = item.split(":")
@ -61,6 +63,11 @@ class Module(core.module.Module):
name = val
elif key == "Fan Speed":
fanspeed = val.split(" ")[0]
elif title == "Utilization":
if key == "Gpu":
gpuUsagePct = val.split(" ")[0]
elif key == "Memory":
memPct = val.split(" ")[0]
except:
title = item.strip()
@ -76,6 +83,8 @@ class Module(core.module.Module):
clock_gpu=clockGpu,
clock_mem=clockMem,
fanspeed=fanspeed,
gpu_usage_pct=gpuUsagePct,
mem_usage_pct=memPct,
)