File tree 1 file changed +13
-3
lines changed
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -78,9 +78,11 @@ def network_check
78
78
ip = ssdp_result [ :address ]
79
79
@runner . update_status port , Rainbow ( "Ethernet connected with IP #{ ip } . Running ping test..." ) . aqua
80
80
81
- # ping test
82
- ping = `ping #{ ip } -i 0.5 -c 15 -q`
83
- packet_loss = ping . match ( /(\d +\. \d +)% packet loss/ ) [ 1 ] . to_i
81
+ packet_loss = ping_test ( ip )
82
+ if packet_loss > 0 && packet_loss < 10
83
+ @runner . update_status port , Rainbow ( "RETRY: Packet loss #{ packet_loss } % Trying again..." ) . yellow
84
+ packet_loss = ping_test ( ip )
85
+ end
84
86
if packet_loss > 0
85
87
@runner . update_status port , Rainbow ( "FAILED: Packet loss #{ packet_loss } %" ) . red
86
88
return false
@@ -117,4 +119,12 @@ def generate_label
117
119
@label = label
118
120
end
119
121
122
+ private
123
+
124
+ def ping_test ( ip )
125
+ ping = `ping #{ ip } -i 0.5 -c 15 -q`
126
+ packet_loss = ping . match ( /(\d +\. \d +)% packet loss/ ) [ 1 ] . to_i
127
+ return packet_loss
128
+ end
129
+
120
130
end
You can’t perform that action at this time.
0 commit comments