use fping
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
c744364285
commit
09dea79ab2
14
mod/network
14
mod/network
|
@ -16,21 +16,19 @@ class Network < Worker
|
||||||
hosts = @my_config['hosts']
|
hosts = @my_config['hosts']
|
||||||
|
|
||||||
net_fail = 0
|
net_fail = 0
|
||||||
hosts.each do |h|
|
i,o,t = Open3.popen2("fping", *hosts)
|
||||||
i,o,t = Open3.popen2("ping", "-c", "1", h)
|
t.join
|
||||||
t.join
|
|
||||||
|
|
||||||
net_fail += 1 unless t.value.exitstatus == 0
|
net_ok = o.each_line.count
|
||||||
end
|
|
||||||
|
|
||||||
if net_fail == 0
|
if net_ok == hosts.count
|
||||||
status = "ok"
|
status = "ok"
|
||||||
fg_colour = @my_config['ok_colour']
|
fg_colour = @my_config['ok_colour']
|
||||||
elsif net_fail == hosts.length
|
elsif net_ok == 0
|
||||||
status = "CRIT: all hosts failed!"
|
status = "CRIT: all hosts failed!"
|
||||||
fg_colour = @my_config['crit_colour']
|
fg_colour = @my_config['crit_colour']
|
||||||
else
|
else
|
||||||
status = "WARN: #{net_fail} host(s) failed"
|
status = "WARN: #{net_ok} host(s) failed"
|
||||||
fg_colour = @my_config['warn_colour']
|
fg_colour = @my_config['warn_colour']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user