Use Open3.popen2
This commit is contained in:
parent
8847f50ddb
commit
9175caa94d
10
mod/network
10
mod/network
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user