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']
|
||||
|
||||
net_fail = 0
|
||||
hosts.each do |h|
|
||||
i,o,t = Open3.popen2("ping", "-c", "1", h)
|
||||
t.join
|
||||
i,o,t = Open3.popen2("fping", *hosts)
|
||||
t.join
|
||||
|
||||
net_fail += 1 unless t.value.exitstatus == 0
|
||||
end
|
||||
net_ok = o.each_line.count
|
||||
|
||||
if net_fail == 0
|
||||
if net_ok == hosts.count
|
||||
status = "ok"
|
||||
fg_colour = @my_config['ok_colour']
|
||||
elsif net_fail == hosts.length
|
||||
elsif net_ok == 0
|
||||
status = "CRIT: all hosts failed!"
|
||||
fg_colour = @my_config['crit_colour']
|
||||
else
|
||||
status = "WARN: #{net_fail} host(s) failed"
|
||||
status = "WARN: #{net_ok} host(s) failed"
|
||||
fg_colour = @my_config['warn_colour']
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user