gpu
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
31aeacfccd
commit
da0387417b
28
mod/gpu
Normal file
28
mod/gpu
Normal file
|
@ -0,0 +1,28 @@
|
|||
# vim: ft=ruby
|
||||
|
||||
class GPU < Worker
|
||||
require 'open3'
|
||||
|
||||
def mainloop()
|
||||
while true do
|
||||
Open3.popen2("nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader") {|i,o,t|
|
||||
gpu_temp = o.gets.to_i
|
||||
|
||||
if gpu_temp > @my_config['temp_crit'].to_i
|
||||
fg_colour = "crit_colour"
|
||||
elsif gpu_temp > @my_config['temp_warn'].to_i
|
||||
fg_colour = "warn_colour"
|
||||
else
|
||||
fg_colour = "ok_colour"
|
||||
end
|
||||
|
||||
rstr = "%%{FC{%s}}%s%%{F-}" % [ fg_colour, gpu_temp ]
|
||||
self.write(rstr)
|
||||
}
|
||||
|
||||
sleep(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Modules.add("gpu", "GPU")
|
26
mod/gpu2
Normal file
26
mod/gpu2
Normal file
|
@ -0,0 +1,26 @@
|
|||
# vim: ft=ruby
|
||||
|
||||
class GPU2 < Worker
|
||||
def mainloop()
|
||||
IO.popen("nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader -l 3") do |pipe|
|
||||
pipe.each do |line|
|
||||
line.chomp!
|
||||
|
||||
t = line.to_i
|
||||
|
||||
if t > @my_config['temp_crit'].to_i
|
||||
fg_colour = "crit_colour"
|
||||
elsif t > @my_config['temp_warn'].to_i
|
||||
fg_colour = "warn_colour"
|
||||
else
|
||||
fg_colour = "ok_colour"
|
||||
end
|
||||
|
||||
rstr = "%%{FC{%s}}%s%%{F-}" % [ fg_colour, t ]
|
||||
self.write(rstr)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Modules.add("gpu2", "GPU2")
|
Loading…
Reference in New Issue
Block a user