2016-09-27 08:13:42 +00:00
|
|
|
# vim: ft=ruby
|
|
|
|
|
2016-09-28 20:30:07 +00:00
|
|
|
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]
|
2016-10-14 11:35:53 +00:00
|
|
|
file.close
|
2016-09-27 08:13:42 +00:00
|
|
|
|
2016-10-04 12:34:25 +00:00
|
|
|
if la_m.to_i > @my_config['crit_value']
|
2019-05-15 13:04:27 +00:00
|
|
|
fg_colour = "crit_colour"
|
2016-10-04 12:34:25 +00:00
|
|
|
elsif la_m.to_i > @my_config['warn_value']
|
2019-05-15 13:04:27 +00:00
|
|
|
fg_colour = "warn_colour"
|
2016-09-27 08:13:42 +00:00
|
|
|
else
|
2019-05-15 13:04:27 +00:00
|
|
|
fg_colour = "ok_colour"
|
2016-09-27 08:13:42 +00:00
|
|
|
end
|
|
|
|
|
2019-05-15 13:04:27 +00:00
|
|
|
self.write "%{FC{#{fg_colour}}}#{la_m}%{F-}"
|
2016-09-27 08:13:42 +00:00
|
|
|
sleep(5)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-09-28 20:30:07 +00:00
|
|
|
Modules.add("load_average", "LoadAverage")
|