net-ping 1.4.1-x86-mingw32 → 1.5.3-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +258 -232
- data/MANIFEST +25 -23
- data/README +52 -46
- data/Rakefile +100 -89
- data/doc/ping.txt +274 -249
- data/examples/example_pingexternal.rb +16 -16
- data/examples/example_pinghttp.rb +22 -22
- data/examples/example_pingldap.rb +22 -0
- data/examples/example_pingtcp.rb +16 -16
- data/examples/example_pingudp.rb +12 -12
- data/lib/net/ping.rb +18 -15
- data/lib/net/ping/external.rb +122 -126
- data/lib/net/ping/http.rb +149 -120
- data/lib/net/ping/icmp.rb +180 -168
- data/lib/net/ping/ldap.rb +107 -0
- data/lib/net/ping/ping.rb +89 -88
- data/lib/net/ping/tcp.rb +83 -83
- data/lib/net/ping/udp.rb +119 -119
- data/lib/net/ping/wmi.rb +118 -118
- data/net-ping.gemspec +43 -38
- data/test/test_net_ping.rb +37 -37
- data/test/test_net_ping_external.rb +128 -121
- data/test/test_net_ping_http.rb +182 -176
- data/test/test_net_ping_icmp.rb +120 -116
- data/test/test_net_ping_ldap.rb +200 -0
- data/test/test_net_ping_tcp.rb +108 -108
- data/test/test_net_ping_udp.rb +122 -122
- data/test/test_net_ping_wmi.rb +84 -84
- metadata +59 -26
data/MANIFEST
CHANGED
@@ -1,23 +1,25 @@
|
|
1
|
-
* MANIFEST
|
2
|
-
* CHANGES
|
3
|
-
* Rakefile
|
4
|
-
* README
|
5
|
-
* net-ping.gemspec
|
6
|
-
* examples/example_pingexternal.rb
|
7
|
-
* examples/example_pinghttp.rb
|
8
|
-
* examples/example_pingtcp.rb
|
9
|
-
* examples/example_pingudp.rb
|
10
|
-
* lib/net/ping.rb
|
11
|
-
* lib/net/ping/icmp.rb
|
12
|
-
* lib/net/ping/
|
13
|
-
* lib/net/ping/
|
14
|
-
* lib/net/ping/
|
15
|
-
* lib/net/ping/
|
16
|
-
* lib/net/ping/
|
17
|
-
*
|
18
|
-
* test/
|
19
|
-
* test/
|
20
|
-
* test/
|
21
|
-
* test/
|
22
|
-
* test/
|
23
|
-
* test/
|
1
|
+
* MANIFEST
|
2
|
+
* CHANGES
|
3
|
+
* Rakefile
|
4
|
+
* README
|
5
|
+
* net-ping.gemspec
|
6
|
+
* examples/example_pingexternal.rb
|
7
|
+
* examples/example_pinghttp.rb
|
8
|
+
* examples/example_pingtcp.rb
|
9
|
+
* examples/example_pingudp.rb
|
10
|
+
* lib/net/ping.rb
|
11
|
+
* lib/net/ping/icmp.rb
|
12
|
+
* lib/net/ping/ldap.rb
|
13
|
+
* lib/net/ping/tcp.rb
|
14
|
+
* lib/net/ping/udp.rb
|
15
|
+
* lib/net/ping/wmi.rb
|
16
|
+
* lib/net/ping/http.rb
|
17
|
+
* lib/net/ping/external.rb
|
18
|
+
* test/test_net_ping_external.rb
|
19
|
+
* test/test_net_ping_http.rb
|
20
|
+
* test/test_net_ping_icmp.rb
|
21
|
+
* test/test_net_ping_ldap.rb
|
22
|
+
* test/test_net_ping_tcp.rb
|
23
|
+
* test/test_net_ping_udp.rb
|
24
|
+
* test/test_net_ping_wmi.rb
|
25
|
+
* test/test_net_ping.rb
|
data/README
CHANGED
@@ -1,46 +1,52 @@
|
|
1
|
-
== Description
|
2
|
-
A collection of classes that provide different ways to ping computers.
|
3
|
-
|
4
|
-
== Prerequisites
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
1
|
+
== Description
|
2
|
+
A collection of classes that provide different ways to ping computers.
|
3
|
+
|
4
|
+
== Prerequisites
|
5
|
+
The win32-open3 (1.8.x) and windows-pr libraries are required on
|
6
|
+
MS Windows when using the Net::Ping::External class unless you're
|
7
|
+
using JRuby.
|
8
|
+
|
9
|
+
JRuby users should use 1.6.7 or later.
|
10
|
+
|
11
|
+
== Installation
|
12
|
+
gem install net-ping
|
13
|
+
|
14
|
+
== Notes
|
15
|
+
Please read the documentation under the 'doc' directory. Especially pay
|
16
|
+
attention to the documentation pertaining to ECONNREFUSED and TCP pings.
|
17
|
+
|
18
|
+
Also note the documentation regarding down hosts.
|
19
|
+
|
20
|
+
You do not need win32-open3 with Ruby 1.9.x. The open3 library that ships
|
21
|
+
as part of the Ruby standard library should work.
|
22
|
+
|
23
|
+
== How to require net-ping
|
24
|
+
You can do either this:
|
25
|
+
|
26
|
+
require 'net/ping'
|
27
|
+
|
28
|
+
In which case you will get Net::Ping and all of its subclasses. Or,
|
29
|
+
you can load individual subclasses like this:
|
30
|
+
|
31
|
+
require 'net/ping/tcp'
|
32
|
+
|
33
|
+
The former has the advantage of being easier to remember and all inclusive,
|
34
|
+
not to mention backwards compatible. The latter has the advantage of
|
35
|
+
reducing your memory footprint.
|
36
|
+
|
37
|
+
== Known Issues
|
38
|
+
Older versions of Ruby 1.9.x may not work with UDP pings.
|
39
|
+
|
40
|
+
Older versions of JRuby will return false positives in UDP pings
|
41
|
+
because of an incorrect error class being raised. See JRuby-4896.
|
42
|
+
|
43
|
+
JRuby 1.6.7 or later is required for external pings because of a bug
|
44
|
+
in earlier versions with open3 and stream handling.
|
45
|
+
|
46
|
+
== License
|
47
|
+
Artistic 2.0
|
48
|
+
|
49
|
+
== More documentation
|
50
|
+
If you installed this library via Rubygems, you can view the inline
|
51
|
+
documentation via ri or fire up 'gem server', and point your browser at
|
52
|
+
http://localhost:8808.
|
data/Rakefile
CHANGED
@@ -1,89 +1,100 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/clean'
|
3
|
-
require 'rake/testtask'
|
4
|
-
include Config
|
5
|
-
|
6
|
-
CLEAN.include("**/*.gem", "**/*.rbc")
|
7
|
-
|
8
|
-
namespace 'gem' do
|
9
|
-
desc 'Create the net-ping gem'
|
10
|
-
task :create => [:clean] do
|
11
|
-
spec = eval(IO.read('net-ping.gemspec'))
|
12
|
-
Gem::Builder.new(spec).build
|
13
|
-
end
|
14
|
-
|
15
|
-
desc 'Install the net-ping gem'
|
16
|
-
task :install => [:create] do
|
17
|
-
gem_file = Dir["*.gem"].first
|
18
|
-
sh "gem install #{gem_file}"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
namespace 'example' do
|
23
|
-
desc 'Run the external ping example program'
|
24
|
-
task :external do
|
25
|
-
ruby '-Ilib examples/example_pingexternal.rb'
|
26
|
-
end
|
27
|
-
|
28
|
-
desc 'Run the http ping example program'
|
29
|
-
task :http do
|
30
|
-
ruby '-Ilib examples/example_pinghttp.rb'
|
31
|
-
end
|
32
|
-
|
33
|
-
desc 'Run the tcp ping example program'
|
34
|
-
task :tcp do
|
35
|
-
ruby '-Ilib examples/example_pingtcp.rb'
|
36
|
-
end
|
37
|
-
|
38
|
-
desc 'Run the udp ping example program'
|
39
|
-
task :udp do
|
40
|
-
ruby '-Ilib examples/example_pingudp.rb'
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
t.
|
60
|
-
t.
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
t.
|
66
|
-
t.
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
t.
|
72
|
-
t.
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
t.
|
78
|
-
t.
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
t.
|
84
|
-
t.
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/testtask'
|
4
|
+
include Object.const_defined?(:RbConfig) ? RbConfig : Config
|
5
|
+
|
6
|
+
CLEAN.include("**/*.gem", "**/*.rbc")
|
7
|
+
|
8
|
+
namespace 'gem' do
|
9
|
+
desc 'Create the net-ping gem'
|
10
|
+
task :create => [:clean] do
|
11
|
+
spec = eval(IO.read('net-ping.gemspec'))
|
12
|
+
Gem::Builder.new(spec).build
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Install the net-ping gem'
|
16
|
+
task :install => [:create] do
|
17
|
+
gem_file = Dir["*.gem"].first
|
18
|
+
sh "gem install #{gem_file}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
namespace 'example' do
|
23
|
+
desc 'Run the external ping example program'
|
24
|
+
task :external do
|
25
|
+
ruby '-Ilib examples/example_pingexternal.rb'
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'Run the http ping example program'
|
29
|
+
task :http do
|
30
|
+
ruby '-Ilib examples/example_pinghttp.rb'
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'Run the tcp ping example program'
|
34
|
+
task :tcp do
|
35
|
+
ruby '-Ilib examples/example_pingtcp.rb'
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'Run the udp ping example program'
|
39
|
+
task :udp do
|
40
|
+
ruby '-Ilib examples/example_pingudp.rb'
|
41
|
+
end
|
42
|
+
|
43
|
+
desc 'Run the ldap ping example program'
|
44
|
+
task :ldap do
|
45
|
+
ruby '-Ilib examples/example_pingldap.rb'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
Rake::TestTask.new do |t|
|
50
|
+
t.libs << 'test'
|
51
|
+
t.warning = true
|
52
|
+
t.verbose = true
|
53
|
+
t.test_files = FileList['test/test_net_ping.rb']
|
54
|
+
end
|
55
|
+
|
56
|
+
namespace 'test' do
|
57
|
+
Rake::TestTask.new('external') do |t|
|
58
|
+
t.warning = true
|
59
|
+
t.verbose = true
|
60
|
+
t.test_files = FileList['test/test_net_ping_external.rb']
|
61
|
+
end
|
62
|
+
|
63
|
+
Rake::TestTask.new('http') do |t|
|
64
|
+
t.warning = true
|
65
|
+
t.verbose = true
|
66
|
+
t.test_files = FileList['test/test_net_ping_http.rb']
|
67
|
+
end
|
68
|
+
|
69
|
+
Rake::TestTask.new('icmp') do |t|
|
70
|
+
t.warning = true
|
71
|
+
t.verbose = true
|
72
|
+
t.test_files = FileList['test/test_net_ping_icmp.rb']
|
73
|
+
end
|
74
|
+
|
75
|
+
Rake::TestTask.new('tcp') do |t|
|
76
|
+
t.warning = true
|
77
|
+
t.verbose = true
|
78
|
+
t.test_files = FileList['test/test_net_ping_tcp.rb']
|
79
|
+
end
|
80
|
+
|
81
|
+
Rake::TestTask.new('udp') do |t|
|
82
|
+
t.warning = true
|
83
|
+
t.verbose = true
|
84
|
+
t.test_files = FileList['test/test_net_ping_udp.rb']
|
85
|
+
end
|
86
|
+
|
87
|
+
Rake::TestTask.new('wmi') do |t|
|
88
|
+
t.warning = true
|
89
|
+
t.verbose = true
|
90
|
+
t.test_files = FileList['test/test_net_ping_wmi.rb']
|
91
|
+
end
|
92
|
+
|
93
|
+
Rake::TestTask.new('ldap') do |t|
|
94
|
+
t.warning = true
|
95
|
+
t.verbose = true
|
96
|
+
t.test_files = FileList['test/test_net_ping_ldap.rb']
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
task :default => :test
|
data/doc/ping.txt
CHANGED
@@ -1,249 +1,274 @@
|
|
1
|
-
= Description
|
2
|
-
A simple Ruby interface to the 'ping' command.
|
3
|
-
|
4
|
-
= Synopsis
|
5
|
-
require 'net/ping'
|
6
|
-
include Net
|
7
|
-
|
8
|
-
Ping::TCP.service_check = true
|
9
|
-
|
10
|
-
pt = Net::Ping::TCP.new(host)
|
11
|
-
pu = Net::Ping::UDP.new(host)
|
12
|
-
pe = Net::Ping::External.new(host)
|
13
|
-
ph = Net::Ping::HTTP.new(uri)
|
14
|
-
|
15
|
-
if pt.ping
|
16
|
-
puts "TCP ping successful"
|
17
|
-
else
|
18
|
-
puts "TCP ping unsuccessful: " + pt.exception
|
19
|
-
end
|
20
|
-
|
21
|
-
if pu.ping
|
22
|
-
puts "UDP ping successful"
|
23
|
-
else
|
24
|
-
puts "UDP ping unsuccessful: " + pu.exception
|
25
|
-
end
|
26
|
-
|
27
|
-
if pe.ping
|
28
|
-
puts "External ping successful"
|
29
|
-
else
|
30
|
-
puts "External ping unsuccessful: " + pe.exception
|
31
|
-
end
|
32
|
-
|
33
|
-
if ph.ping?
|
34
|
-
puts "HTTP ping successful"
|
35
|
-
else
|
36
|
-
puts "HTTP ping unsuccessful: " + ph.exception
|
37
|
-
end
|
38
|
-
|
39
|
-
= Ping Classes
|
40
|
-
* Ping::TCP
|
41
|
-
* Ping::UDP
|
42
|
-
* Ping::External
|
43
|
-
* Ping::HTTP
|
44
|
-
* Ping::ICMP
|
45
|
-
* Ping::WMI
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
Net::Ping
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
Ping::TCP
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
Ping::UDP
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
returned.
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
Ping::External
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
Ping::HTTP
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
Ping::ICMP
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
Ping::WMI
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
Ping
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
Ping#
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
Ping#
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
1
|
+
= Description
|
2
|
+
A simple Ruby interface to the 'ping' command.
|
3
|
+
|
4
|
+
= Synopsis
|
5
|
+
require 'net/ping'
|
6
|
+
include Net
|
7
|
+
|
8
|
+
Ping::TCP.service_check = true
|
9
|
+
|
10
|
+
pt = Net::Ping::TCP.new(host)
|
11
|
+
pu = Net::Ping::UDP.new(host)
|
12
|
+
pe = Net::Ping::External.new(host)
|
13
|
+
ph = Net::Ping::HTTP.new(uri)
|
14
|
+
|
15
|
+
if pt.ping
|
16
|
+
puts "TCP ping successful"
|
17
|
+
else
|
18
|
+
puts "TCP ping unsuccessful: " + pt.exception
|
19
|
+
end
|
20
|
+
|
21
|
+
if pu.ping
|
22
|
+
puts "UDP ping successful"
|
23
|
+
else
|
24
|
+
puts "UDP ping unsuccessful: " + pu.exception
|
25
|
+
end
|
26
|
+
|
27
|
+
if pe.ping
|
28
|
+
puts "External ping successful"
|
29
|
+
else
|
30
|
+
puts "External ping unsuccessful: " + pe.exception
|
31
|
+
end
|
32
|
+
|
33
|
+
if ph.ping?
|
34
|
+
puts "HTTP ping successful"
|
35
|
+
else
|
36
|
+
puts "HTTP ping unsuccessful: " + ph.exception
|
37
|
+
end
|
38
|
+
|
39
|
+
= Ping Classes
|
40
|
+
* Ping::TCP
|
41
|
+
* Ping::UDP
|
42
|
+
* Ping::External
|
43
|
+
* Ping::HTTP
|
44
|
+
* Ping::ICMP
|
45
|
+
* Ping::WMI
|
46
|
+
* Ping::LDAP
|
47
|
+
|
48
|
+
All Ping classes are children of the Ping parent class (which should
|
49
|
+
never be instantiated directly).
|
50
|
+
|
51
|
+
The Ping::ICMP class requires root privileges on UNIX systems.
|
52
|
+
|
53
|
+
The Ping::WMI class only works on MS Windows.
|
54
|
+
|
55
|
+
== Net::Ping
|
56
|
+
Net::Ping.new(host=nil, port=7, timeout=5)
|
57
|
+
Creates and returns a new Ping object. If the host is not specified
|
58
|
+
in the constructor then it must be specified in the ping method.
|
59
|
+
|
60
|
+
== Net::Ping::TCP
|
61
|
+
Ping::TCP.service_check
|
62
|
+
Returns the setting for how ECONNREFUSED is handled. By default, this is
|
63
|
+
set to false, i.e. an ECONNREFUSED error is considered a failed ping.
|
64
|
+
|
65
|
+
Ping::TCP.service_check=(bool)
|
66
|
+
Sets the behavior for how ECONNREFUSED is handled. By default, this is
|
67
|
+
set to false, i.e. an ECONNREFUSED error is considered a failed ping.
|
68
|
+
|
69
|
+
Ping::TCP#ping(host=nil)
|
70
|
+
Attempts to open a connection using TCPSocket with a +host+ specified
|
71
|
+
either here or in the constructor. A successful open means the ping was
|
72
|
+
successful and true is returned. Otherwise, false is returned.
|
73
|
+
|
74
|
+
== Net::Ping::UDP
|
75
|
+
Ping::UDP#ping
|
76
|
+
Attempts to open a connection using UDPSocket and sends the value of
|
77
|
+
Ping::UDP#data as a string across the socket. If the return string matches,
|
78
|
+
then the ping was successful and true is returned. Otherwise, false is
|
79
|
+
returned.
|
80
|
+
|
81
|
+
Ping::UDP#data
|
82
|
+
Returns the string that is sent across the UDP socket.
|
83
|
+
|
84
|
+
Ping::UDP#data=(string)
|
85
|
+
Sets the string that is sent across the UDP socket. The default is "ping".
|
86
|
+
Note that the +string+ cannot be larger than MAX_DATA (64 characters).
|
87
|
+
|
88
|
+
== Net::Ping::External
|
89
|
+
Ping::External#ping
|
90
|
+
Uses the 'open3' module and calls your system's local 'ping' command with
|
91
|
+
various options, depending on platform. If nothing is sent to stderr, the
|
92
|
+
ping was successful and true is returned. Otherwise, false is returned.
|
93
|
+
|
94
|
+
The MS Windows platform requires the 'win32-open3' package.
|
95
|
+
|
96
|
+
== Ping::HTTP
|
97
|
+
Ping::HTTP.new(uri=nil, port=80, timeout=5)
|
98
|
+
Identical to Net::Ping.new except that, instead of a host, the first
|
99
|
+
argument is a URI.
|
100
|
+
|
101
|
+
Ping::HTTP#ping
|
102
|
+
Checks for a response against +uri+. As long as kind of Net::HTTPSuccess
|
103
|
+
response is returned, the ping is successful and true is returned.
|
104
|
+
Otherwise, false is returned and Ping::HTTP#exception is set to the error
|
105
|
+
message.
|
106
|
+
|
107
|
+
Note that redirects are automatically followed unless the
|
108
|
+
Ping::HTTP#follow_redirects method is set to false.
|
109
|
+
|
110
|
+
Ping::HTTP#follow_redirect
|
111
|
+
Indicates whether or not a redirect should be followed in a ping attempt.
|
112
|
+
By default this is set to true.
|
113
|
+
|
114
|
+
Ping::HTTP#follow_redirect=(bool)
|
115
|
+
Sets whether or not a redirect should be followed in a ping attempt. If
|
116
|
+
set to false, then any redirect is considered a failed ping.
|
117
|
+
|
118
|
+
Ping::HTTP#uri
|
119
|
+
An alias for Ping::HTTP#host.
|
120
|
+
|
121
|
+
Ping::HTTP#uri=(uri)
|
122
|
+
An alias for Ping::HTTP#host=.
|
123
|
+
|
124
|
+
== Ping::ICMP
|
125
|
+
Ping::ICMP#duration
|
126
|
+
The time it took to ping the host. Not a precise value but a good estimate.
|
127
|
+
|
128
|
+
== Ping::WMI
|
129
|
+
Ping::WMI#ping(host, options={})
|
130
|
+
Unlike other Ping classes, this method returns a PingStatus struct that
|
131
|
+
contains various bits of information about the ping itself. The PingStatus
|
132
|
+
struct is a wrapper for the Win32_PingStatus WMI class.
|
133
|
+
|
134
|
+
In addition, you can pass options that will be interpreted as WQL parameters.
|
135
|
+
|
136
|
+
Ping::WMI#ping?(host, options={})
|
137
|
+
Returns whether or not the ping succeeded.
|
138
|
+
|
139
|
+
== Ping::LDAP
|
140
|
+
Ping::LDAP.new(uri=nil, timeout=5)
|
141
|
+
Performs a 'ping' to an LDAP server in the form of either an anonymous
|
142
|
+
or an authenticated LDAP bind.
|
143
|
+
Identical to Net::Ping.new except that, instead of a host, the first
|
144
|
+
argument is a URI.
|
145
|
+
The default +timeout+ is 5 seconds.
|
146
|
+
|
147
|
+
+uri+ string is expected to be a full URI with scheme (ldap/ldaps)
|
148
|
+
and optionally the port (else default port is assumed) e.g.
|
149
|
+
ldap://my.ldap.host.com
|
150
|
+
ldap://my.ldap.host.com:1389
|
151
|
+
ldaps://my.ldap.host.com
|
152
|
+
ldaps://my.ldap.host.com:6636
|
153
|
+
|
154
|
+
If a plain hostname is provided as the +uri+, a default port of 389 is assumed
|
155
|
+
|
156
|
+
Ping::LDAP#encryption
|
157
|
+
Set/get the encyption method. By default is nil, but may be set to :simple_tls
|
158
|
+
|
159
|
+
Ping::LDAP#username
|
160
|
+
Ping::LDAP#password
|
161
|
+
set/get the username and password for ping using and authenticated bind.
|
162
|
+
|
163
|
+
= Common Instance Methods
|
164
|
+
Ping#exception
|
165
|
+
Returns the error string that was set if a ping call failed. If an exception
|
166
|
+
is raised, it is caught and stored in this attribute. It is not raised in
|
167
|
+
your code.
|
168
|
+
|
169
|
+
This should be nil if the ping succeeded.
|
170
|
+
|
171
|
+
Ping#host
|
172
|
+
Returns the host name that ping attempts will ping against.
|
173
|
+
|
174
|
+
Ping#host=(hostname)
|
175
|
+
Sets the host name that ping attempts will ping against.
|
176
|
+
|
177
|
+
Ping#port
|
178
|
+
Returns the port number that ping attempts will use.
|
179
|
+
|
180
|
+
Ping#port=(port)
|
181
|
+
Set the port number to open socket connections on. The default is 7 (or
|
182
|
+
whatever your 'echo' port is set to). Note that you can also specify a
|
183
|
+
string, such as "http".
|
184
|
+
|
185
|
+
Ping#timeout
|
186
|
+
Returns the amount of time before the timeout module raises a TimeoutError
|
187
|
+
during connection attempts. The default is 5 seconds.
|
188
|
+
|
189
|
+
Ping#timeout=(time)
|
190
|
+
Sets the amount of time before the timeout module raises a TimeoutError.
|
191
|
+
during connection attempts.
|
192
|
+
|
193
|
+
Ping#warning
|
194
|
+
Returns a warning string that was returned during the ping attempt. This
|
195
|
+
typically occurs only in the Ping::External class, or the Ping::HTTP class
|
196
|
+
if a redirect occurred.
|
197
|
+
|
198
|
+
== Notes
|
199
|
+
If a host is down *IT IS CONSIDERED A FAILED PING*, and the 'no answer from
|
200
|
+
+host+' text is assigned to the 'exception' attribute. You may disagree with
|
201
|
+
this behavior, in which case you need merely check the exception attribute
|
202
|
+
against a regex as a simple workaround.
|
203
|
+
|
204
|
+
== Pre-emptive FAQ
|
205
|
+
Q: "Why don't you return exceptions if a connection fails?"
|
206
|
+
|
207
|
+
A: Because ping is only meant to return one of two things - success or
|
208
|
+
failure. It's very simple. If you want to find out *why* the ping
|
209
|
+
failed, you can check the 'exception' attribute.
|
210
|
+
|
211
|
+
Q: "I know the host is alive, but a TCP or UDP ping tells me otherwise. What
|
212
|
+
gives?"
|
213
|
+
|
214
|
+
A: It's possible that the echo port has been disabled on the remote
|
215
|
+
host for security reasons. Your best best is to specify a different port
|
216
|
+
or to use Ping::ICMP or Ping::External instead.
|
217
|
+
|
218
|
+
In the case of UDP pings, they are often actively refused. It may be
|
219
|
+
more pragmatic to set Ping::UDP.service_check = false.
|
220
|
+
|
221
|
+
Q: "Why does a TCP ping return false when I know it should return true?"
|
222
|
+
|
223
|
+
A: By default ECONNREFUSED errors will return a value of false. This is
|
224
|
+
contrary to what most other folks do for TCP pings. The problem with
|
225
|
+
their philosophy is that you can get false positives if a firewall blocks
|
226
|
+
the route to the host. The problem with my philosophy is that you can
|
227
|
+
get false negatives if there is no firewall (or it's not blocking the
|
228
|
+
route). Given the alternatives I chose the latter.
|
229
|
+
|
230
|
+
You can always change the default behavior by using the +service_check+
|
231
|
+
class method.
|
232
|
+
|
233
|
+
A similar situation is true for UDP pings.
|
234
|
+
|
235
|
+
Q: "Couldn't you use traceroute information to tell for sure?"
|
236
|
+
|
237
|
+
A: I could but I won't so don't bug me about it. It's far more effort than
|
238
|
+
it's worth. If you want something like that, please port the
|
239
|
+
Net::Traceroute Perl module by Daniel Hagerty.
|
240
|
+
|
241
|
+
= Known Bugs
|
242
|
+
You may see a test failure from the test_net_ping_tcp test case. You can
|
243
|
+
ignore these.
|
244
|
+
|
245
|
+
The socket library that ships with the Windows One-Click installer has
|
246
|
+
known issues. This may cause the Ping::ICMP class to fail. In fact, I
|
247
|
+
make an effort to skip those tests if I detect the one-click installer.
|
248
|
+
|
249
|
+
UDP pings may not work with older versions of Ruby 1.9.x.
|
250
|
+
|
251
|
+
Please report any bugs on the project page at
|
252
|
+
http://www.rubyforge.org/projects/shards.
|
253
|
+
|
254
|
+
= Acknowledgements
|
255
|
+
The Ping::ICMP#ping method is based largely on the identical method from
|
256
|
+
the Net::Ping Perl module by Rob Brown. Much of the code was ported by
|
257
|
+
Jos Backus on ruby-talk.
|
258
|
+
|
259
|
+
= Future Plans
|
260
|
+
Add support for syn pings.
|
261
|
+
|
262
|
+
= License
|
263
|
+
Artistic 2.0
|
264
|
+
|
265
|
+
= Copyright
|
266
|
+
(C) 2003-2010 Daniel J. Berger, All Rights Reserved
|
267
|
+
|
268
|
+
= Warranty
|
269
|
+
This package is provided "as is" and without any express or
|
270
|
+
implied warranties, including, without limitation, the implied
|
271
|
+
warranties of merchantability and fitness for a particular purpose.
|
272
|
+
|
273
|
+
= Author
|
274
|
+
Daniel J. Berger
|