moltenbar/mod/load_average

25 lines
473 B
Plaintext
Raw Normal View History

2016-09-27 08:13:42 +00:00
# vim: ft=ruby
class LoadAverage < Worker
def mainloop()
2016-09-27 08:13:42 +00:00
while true do
file = File.open("/proc/loadavg", "r")
la_m = file.gets.split[0]
file.close
2016-09-27 08:13:42 +00:00
if la_m.to_i > @my_config['crit_value']
fg_colour = "crit_colour"
elsif la_m.to_i > @my_config['warn_value']
fg_colour = "warn_colour"
2016-09-27 08:13:42 +00:00
else
fg_colour = "ok_colour"
2016-09-27 08:13:42 +00:00
end
self.write "%{FC{#{fg_colour}}}#{la_m}%{F-}"
2016-09-27 08:13:42 +00:00
sleep(5)
end
end
end
Modules.add("load_average", "LoadAverage")