ether_ping 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/bin/ether_ping +14 -4
- data/ether_ping.gemspec +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/bin/ether_ping
CHANGED
@@ -8,8 +8,8 @@ options = {}
|
|
8
8
|
parser = OptionParser.new do |opts|
|
9
9
|
opts.banner = "Usage: #{$0} [options] destination_mac"
|
10
10
|
|
11
|
-
opts.on('-e', '--interface ETH', 'Ethernet interface name, e.g. eth0') do |
|
12
|
-
options[:interface] =
|
11
|
+
opts.on('-e', '--interface ETH', 'Ethernet interface name, e.g. eth0') do |e|
|
12
|
+
options[:interface] = e
|
13
13
|
end
|
14
14
|
|
15
15
|
opts.on('-t', '--type TYPE',
|
@@ -26,6 +26,14 @@ parser = OptionParser.new do |opts|
|
|
26
26
|
options[:size] = s.to_i
|
27
27
|
end
|
28
28
|
|
29
|
+
opts.on('-i', '--interval SECONDS', 'Time between successive pings') do |i|
|
30
|
+
options[:interval] = i.to_f
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on('-x', '--timeout SECONDS', 'Time before giving up on a ping') do |x|
|
34
|
+
options[:timeout] = x.to_f
|
35
|
+
end
|
36
|
+
|
29
37
|
opts.on('-h', '--help', 'Display this screen') do
|
30
38
|
puts opts
|
31
39
|
exit
|
@@ -36,6 +44,8 @@ parser.parse!
|
|
36
44
|
options[:interface] ||= Ethernet.devices.keys.sort.first
|
37
45
|
options[:ether_type] ||= 0x88B5
|
38
46
|
options[:size] ||= 64 unless options[:data]
|
47
|
+
options[:interval] ||= 1
|
48
|
+
options[:timeout] ||= 1
|
39
49
|
|
40
50
|
if ARGV.length < 1
|
41
51
|
puts "Missing destination MAC address"
|
@@ -53,7 +63,7 @@ client = EtherPing::Client.new options[:interface], options[:ether_type],
|
|
53
63
|
loop do
|
54
64
|
print "Ping... "
|
55
65
|
STDOUT.flush
|
56
|
-
result = client.ping options[:size] || options[:data]
|
66
|
+
result = client.ping options[:size] || options[:data], options[:timeout]
|
57
67
|
if result
|
58
68
|
if result.kind_of? Numeric
|
59
69
|
puts "#{result * 1000000}us"
|
@@ -66,5 +76,5 @@ loop do
|
|
66
76
|
puts "Timed out"
|
67
77
|
end
|
68
78
|
STDOUT.flush
|
69
|
-
sleep
|
79
|
+
sleep options[:interval]
|
70
80
|
end
|
data/ether_ping.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ether_ping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Victor Costan
|