27 lines
652 B
Plaintext
27 lines
652 B
Plaintext
|
# vim: ft=ruby
|
||
|
|
||
|
class ModLoadAverage < ModBasic
|
||
|
@@mod_name = 'load_average'
|
||
|
|
||
|
def data_loop()
|
||
|
while true do
|
||
|
file = File.open("/proc/loadavg", "r")
|
||
|
la_m = file.gets.split[0]
|
||
|
|
||
|
if la_m.to_i > $config['mod']['load_average']['crit_value']
|
||
|
fg_colour = $config['mod']['load_average']['crit_colour']
|
||
|
elsif la_m.to_i > $config['mod']['load_average']['warn_value']
|
||
|
fg_colour = $config['mod']['load_average']['warn_colour']
|
||
|
else
|
||
|
fg_colour = $config['mod']['load_average']['ok_colour']
|
||
|
end
|
||
|
|
||
|
$panel_data[@@mod_name.to_sym] = "%{F#{fg_colour}}#{la_m}%{F-}"
|
||
|
$queue << 1
|
||
|
sleep(5)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
ModLoadAverage.new.mainloop()
|