feat: add GPU usage % and GPU memory usage % to nvidiagpu

This commit is contained in:
Tom Saleeba 2021-07-24 15:18:04 -06:00
parent 4d422ffc84
commit 98c92bb78f

View file

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