new module and some tweaks
This commit is contained in:
parent
c772ed8ce3
commit
8332f8a49f
17
mod/battery
Normal file
17
mod/battery
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# vim: ft=ruby
|
||||||
|
|
||||||
|
class Battery < Worker
|
||||||
|
require 'open3'
|
||||||
|
|
||||||
|
def mainloop()
|
||||||
|
while true do
|
||||||
|
Open3.popen2("acpi") {|i,o,t|
|
||||||
|
self.write(o.gets.split[3])
|
||||||
|
}
|
||||||
|
|
||||||
|
sleep(10)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Modules.add("battery", "Battery")
|
31
mod/network
31
mod/network
|
@ -16,25 +16,24 @@ class Network < Worker
|
||||||
hosts = @my_config['hosts']
|
hosts = @my_config['hosts']
|
||||||
|
|
||||||
net_fail = 0
|
net_fail = 0
|
||||||
i,o,t = Open3.popen2("fping", *hosts)
|
Open3.popen2("fping", *hosts) {|i,o,t|
|
||||||
t.join
|
net_ok = o.each_line.count
|
||||||
|
|
||||||
net_ok = o.each_line.count
|
if net_ok == hosts.count
|
||||||
|
status = "ok"
|
||||||
|
fg_colour = @my_config['ok_colour']
|
||||||
|
elsif net_ok == 0
|
||||||
|
status = "CRIT: all hosts failed!"
|
||||||
|
fg_colour = @my_config['crit_colour']
|
||||||
|
else
|
||||||
|
status = "WARN: #{net_ok} host(s) failed"
|
||||||
|
fg_colour = @my_config['warn_colour']
|
||||||
|
end
|
||||||
|
|
||||||
i.close; o.close
|
@rstr = "%{F#{fg_colour}}#{status}%{F-}"
|
||||||
|
}
|
||||||
|
|
||||||
if net_ok == hosts.count
|
return @rstr
|
||||||
status = "ok"
|
|
||||||
fg_colour = @my_config['ok_colour']
|
|
||||||
elsif net_ok == 0
|
|
||||||
status = "CRIT: all hosts failed!"
|
|
||||||
fg_colour = @my_config['crit_colour']
|
|
||||||
else
|
|
||||||
status = "WARN: #{net_ok} host(s) failed"
|
|
||||||
fg_colour = @my_config['warn_colour']
|
|
||||||
end
|
|
||||||
|
|
||||||
return "%{F#{fg_colour}}#{status}%{F-}"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user