Use Open3.popen2

This commit is contained in:
Jack L. Frost 2016-09-27 16:06:04 +03:00
parent 8847f50ddb
commit 9175caa94d
1 changed files with 7 additions and 3 deletions

View File

@ -3,6 +3,8 @@
class ModNetwork < ModBasic
@@mod_name = 'network'
require 'open3'
def data_loop()
$panel_data[@@mod_name.to_sym] = "checking..."
@ -18,9 +20,11 @@ class ModNetwork < ModBasic
net_ok = 0
hosts.each do |h|
if system("ping -c 1 #{h} > /dev/null")
net_ok += 1
end
i,o,t = Open3.popen2("ping", "-c", "1", h)
i.close; o.close
t.join
net_ok += 1 if t.value
end
if net_ok == 0