moltenbar/mod/load_average
fbt c1ffc8cb6c ok this time for sure
Signed-off-by: fbt <fbt@fleshless.org>
2016-09-28 23:30:07 +03:00

24 lines
592 B
Ruby

# vim: ft=ruby
class LoadAverage < Worker
def mainloop()
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
self.write "%{F#{fg_colour}}#{la_m}%{F-}"
sleep(5)
end
end
end
Modules.add("load_average", "LoadAverage")