25 lines
473 B
Ruby
25 lines
473 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]
|
|
file.close
|
|
|
|
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"
|
|
else
|
|
fg_colour = "ok_colour"
|
|
end
|
|
|
|
self.write "%{FC{#{fg_colour}}}#{la_m}%{F-}"
|
|
sleep(5)
|
|
end
|
|
end
|
|
end
|
|
|
|
Modules.add("load_average", "LoadAverage")
|