Last active
October 12, 2020 10:18
-
-
Save frantic1048/41f56fd6328fa83ce6ad5acb3a4c0336 to your computer and use it in GitHub Desktop.
KDE KSysGuard NVIDIA GPU temperature/memory/utilization sensor
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\n"; | |
}else{ | |
print `nvidia-settings -tq gpucoretemp | head -n1`; | |
} | |
} | |
if(/gpu_graphics/){ | |
if(/\?/){ | |
print "GPU\t0\t0\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\t0\n"; | |
}else{ | |
print `nvidia-settings -tq [gpu:0]/GPUUtilization | awk -F"," '{print(substr(\$2,index(\$2,"=")+1))}'`; | |
} | |
} | |
if(/gpu_video_engine/){ | |
if(/\?/){ | |
print "Video Engine\t0\t0\n"; | |
}else{ | |
print `nvidia-settings -tq [gpu:0]/GPUUtilization | awk -F"," '{print(substr(\$3,index(\$3,"=")+1))}'`; | |
} | |
} | |
print "ksysguardd> "; | |
} |
Fantastic, exactly what I was looking for. I'm using @hacker1024's modified version.
Two things should be added to the comments:
- In KSysGuard,
File -> Monitor Remote Machine
is only available on custom/new tabs, but not on the default tabs, i.e. Process Table, System Load. Took me a while to figure that out. nvidia-settings -tq all
ornvidia-settings -q all
may be used to list all queryable attributes in case one wants to add something
Many thanks!
I ported your script to Bash, extended it and significantly lowered its CPU footprint:
https://gist.github.com/fonic/8f38e5e3ce5c8693ae3a23aa1af21fb9
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've modified your script to add units and detect the amount of GPU memory.
https://gist.github.com/hacker1024/c01a773f50769bd8216fa01ea0a1ef33