-
-
Save zedxxx/2984c23eede3893d3d244bc3e2436f46 to your computer and use it in GitHub Desktop.
KDE KSysGuard NVIDIA GPU temperature/memory/utilization sensor, based on @frantic1048's script, but with units and total memory detection.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
# act as a KSysGuard sensor | |
# provides NVIDIA GPU info via `nvidia-settings` | |
# Usage (e.g. add gpu temperature sensor) | |
# 1. save this file, make sure it has a exec permission | |
# 2. in KSysGuard's menu, open `File` -> `Monitor Remote Machine` | |
# 3.1 in new dialog, type `Host` whatever you want | |
# 3.2 set `Connection Type` to `Custom command` | |
# 3.3 set `Command` like `path/to/this-sensor.pl` | |
# 4. click `OK`, now you can find new sensor named `gpu_temp` | |
# which is provides GPU temperature | |
# See Also | |
# https://techbase.kde.org/Development/Tutorials/Sensors | |
$|=1; | |
print "ksysguardd 1.2.0\n"; | |
print "ksysguardd> "; | |
while(<>){ | |
if(/monitors/){ | |
print "gpu_temp\tinteger\n"; | |
print "gpu_graphics\tinteger\n"; | |
print "gpu_memory\tinteger\n"; | |
print "gpu_video_engine\tinteger\n"; | |
} | |
if(/gpu_temp/){ | |
if(/\?/){ | |
print "GPU Temp\t0\t0\t°C\n"; | |
}else{ | |
print `nvidia-settings -tq gpucoretemp | head -n1`; | |
} | |
} | |
if(/gpu_graphics/){ | |
if(/\?/){ | |
print "GPU\t0\t100\t%\n"; | |
}else{ | |
print `nvidia-settings -tq [gpu:0]/GPUUtilization | awk -F"," '{print(substr(\$1,index(\$1,"=")+1))}'`; | |
} | |
} | |
if(/gpu_memory/){ | |
if(/\?/){ | |
print "GPU Memory\t0\t".`nvidia-settings -tq [gpu:0]/TotalDedicatedGPUMemory | perl -pe 'chomp'`."\tMB\n"; | |
}else{ | |
print `nvidia-settings -tq [gpu:0]/UsedDedicatedGPUMemory`; | |
} | |
} | |
if(/gpu_video_engine/){ | |
if(/\?/){ | |
print "Video Engine\t0\t100\t%\n"; | |
}else{ | |
print `nvidia-settings -tq [gpu:0]/GPUUtilization | awk -F"," '{print(substr(\$3,index(\$3,"=")+1))}'`; | |
} | |
} | |
print "ksysguardd> "; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment