stella 0.8.8.001 → 2.0.1.001
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +9 -1
- data/Gemfile +19 -0
- data/Gemfile.lock +50 -0
- data/README.md +5 -79
- data/Rakefile +10 -7
- data/Rudyfile +1 -1
- data/TODO +31 -0
- data/VERSION.yml +3 -4
- data/bin/stella +23 -81
- data/certs/README.txt +17 -0
- data/certs/cacerts.pem +1529 -0
- data/certs/gd-class2-root.crt +24 -0
- data/certs/gd_bundle.crt +76 -0
- data/certs/gd_intermediate.crt +29 -0
- data/certs/startssl-ca.pem +44 -0
- data/certs/startssl-sub.class1.server.ca.pem +36 -0
- data/certs/stella-master.crt +1738 -0
- data/lib/stella.rb +191 -123
- data/lib/stella/cli.rb +47 -67
- data/lib/stella/client.rb +424 -360
- data/lib/stella/core_ext.rb +527 -0
- data/lib/stella/engine.rb +126 -419
- data/lib/stella/report.rb +391 -0
- data/lib/stella/testplan.rb +432 -306
- data/lib/stella/utils.rb +227 -2
- data/stella.gemspec +56 -55
- data/try/00_basics_try.rb +29 -0
- data/try/01_selectable_try.rb +25 -0
- data/try/09_utils_try.rb +67 -0
- data/try/10_stella_object_try.rb +49 -0
- data/try/40_report_try.rb +133 -0
- data/try/90_class_syntax_try.rb +13 -0
- data/try/emhttp.rb +62 -0
- data/try/rubyroute.rb +70 -0
- data/try/support/file.bmp +0 -0
- data/try/support/file.gif +0 -0
- data/try/support/file.ico +0 -0
- data/try/support/file.jpeg +0 -0
- data/try/support/file.jpg +0 -0
- data/try/support/file.png +0 -0
- data/try/traceviz.rb +60 -0
- data/vendor/httpclient-2.1.5.2/httpclient/session.rb +5 -2
- metadata +81 -53
- data/examples/cookies/plan.rb +0 -49
- data/examples/csvdata/plan.rb +0 -32
- data/examples/csvdata/search_terms.csv +0 -14
- data/examples/dynamic/plan.rb +0 -60
- data/examples/essentials/logo.png +0 -0
- data/examples/essentials/plan.rb +0 -248
- data/examples/essentials/search_terms.txt +0 -19
- data/examples/exceptions/plan.rb +0 -20
- data/examples/httpauth/plan.rb +0 -33
- data/examples/timeout/plan.rb +0 -18
- data/examples/variables/plan.rb +0 -41
- data/lib/stella/client/container.rb +0 -378
- data/lib/stella/common.rb +0 -363
- data/lib/stella/data.rb +0 -59
- data/lib/stella/data/http.rb +0 -189
- data/lib/stella/engine/functional.rb +0 -156
- data/lib/stella/engine/load.rb +0 -516
- data/lib/stella/guidelines.rb +0 -18
- data/lib/stella/logger.rb +0 -150
- data/lib/stella/utils/httputil.rb +0 -266
- data/try/01_numeric_mixins_tryouts.rb +0 -40
- data/try/12_digest_tryouts.rb +0 -42
- data/try/70_module_usage.rb +0 -21
- data/try/api/10_functional.rb +0 -20
- data/try/configs/failed_requests.rb +0 -31
- data/try/configs/global_sequential.rb +0 -18
- data/try/proofs/thread_queue.rb +0 -21
data/try/09_utils_try.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'stella'
|
2
|
+
|
3
|
+
## Knows a valid hostname
|
4
|
+
Stella::Utils.valid_hostname? 'localhost'
|
5
|
+
#=> true
|
6
|
+
|
7
|
+
## Knows a invalid hostname
|
8
|
+
Stella::Utils.valid_hostname? 'localhost900000000'
|
9
|
+
#=> false
|
10
|
+
|
11
|
+
## Local IP address
|
12
|
+
Stella::Utils.local_ipaddr? '127.0.0.255'
|
13
|
+
#=> true
|
14
|
+
|
15
|
+
## Private IP address (class A)
|
16
|
+
Stella::Utils.private_ipaddr? '10.0.0.255'
|
17
|
+
#=> true
|
18
|
+
|
19
|
+
## Private IP address (class C)
|
20
|
+
Stella::Utils.private_ipaddr? '172.16.0.255'
|
21
|
+
#=> true
|
22
|
+
|
23
|
+
## Private IP address (class C)
|
24
|
+
Stella::Utils.private_ipaddr? '192.168.0.255'
|
25
|
+
#=> true
|
26
|
+
|
27
|
+
|
28
|
+
## Rudimentary test for binary data.
|
29
|
+
a = File.read('/usr/bin/less')
|
30
|
+
Stella::Utils.binary?(a)
|
31
|
+
#=> true
|
32
|
+
|
33
|
+
## Rudimentary test for text data
|
34
|
+
a = File.read('/etc/hosts')
|
35
|
+
Stella::Utils.binary?(a)
|
36
|
+
#=> false
|
37
|
+
|
38
|
+
## Knows a JPG
|
39
|
+
a = File.read('try/support/file.jpg')
|
40
|
+
Stella::Utils.jpg?(a)
|
41
|
+
#=>true
|
42
|
+
|
43
|
+
## Knows a GIF
|
44
|
+
a = File.read('try/support/file.gif')
|
45
|
+
Stella::Utils.gif?(a)
|
46
|
+
#=>true
|
47
|
+
|
48
|
+
## Knows a PNG
|
49
|
+
a = File.read('try/support/file.png')
|
50
|
+
Stella::Utils.png?(a)
|
51
|
+
#=>true
|
52
|
+
|
53
|
+
## Knows a BMP
|
54
|
+
a = File.read('try/support/file.bmp')
|
55
|
+
Stella::Utils.bmp?(a)
|
56
|
+
#=>true
|
57
|
+
|
58
|
+
## Knows an ICO
|
59
|
+
a = File.read('try/support/file.ico')
|
60
|
+
Stella::Utils.ico?(a)
|
61
|
+
#=>true
|
62
|
+
|
63
|
+
## Knows an image
|
64
|
+
a = File.read('try/support/file.ico')
|
65
|
+
Stella::Utils.image?(a)
|
66
|
+
#=>true
|
67
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'stella'
|
2
|
+
|
3
|
+
TEST_URI = 'http://www.blamestella.com/'
|
4
|
+
|
5
|
+
## Create testplan w/ uri
|
6
|
+
@tp = Stella::Testplan.new TEST_URI
|
7
|
+
@tp.id
|
8
|
+
#=> '9c7d56020ffa632dd1c798a6ee1990a656d59b59'
|
9
|
+
|
10
|
+
## has consistent usecase ID
|
11
|
+
@tp.usecases.first.id
|
12
|
+
# => '77b98a7a840c8f58bc51a8fdb07874a4ecb752a3'
|
13
|
+
|
14
|
+
## can access first request
|
15
|
+
@tp.first_request.id
|
16
|
+
# => '8cb1d7467eb28ae519bbbc448911b617e5e40130'
|
17
|
+
|
18
|
+
## Request is http
|
19
|
+
@tp.first_request.protocol
|
20
|
+
#=> :http
|
21
|
+
|
22
|
+
## Stella instance
|
23
|
+
@stella = Stella.new TEST_URI
|
24
|
+
@stella.plan.planid
|
25
|
+
#=> @tp.id
|
26
|
+
|
27
|
+
## Create testrun
|
28
|
+
@tr = Stella::Testrun.new @tp
|
29
|
+
@tr.id.class
|
30
|
+
#=> Gibbler::Digest
|
31
|
+
|
32
|
+
## Default testrun status is new
|
33
|
+
@tr.new?
|
34
|
+
#=> true
|
35
|
+
|
36
|
+
## Testrun status can be set
|
37
|
+
@tr.running!
|
38
|
+
@tr.running?
|
39
|
+
#=> true
|
40
|
+
|
41
|
+
## Testplan can go to JSON
|
42
|
+
@tp.to_json
|
43
|
+
##=> ''
|
44
|
+
|
45
|
+
## Can come back from JSON
|
46
|
+
@tr2 = Stella::Testrun.from_json @tr.to_json
|
47
|
+
@tr2.id
|
48
|
+
#=> @tr.id
|
49
|
+
|
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'stella'
|
2
|
+
|
3
|
+
#
|
4
|
+
# require 'socket'
|
5
|
+
#
|
6
|
+
# class TCPSocket
|
7
|
+
#
|
8
|
+
# def write(*args)
|
9
|
+
# STDOUT.puts caller
|
10
|
+
# STDOUT.puts [args].inspect
|
11
|
+
# super
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
|
17
|
+
|
18
|
+
Stella.debug = true
|
19
|
+
|
20
|
+
## Stella::Report is aware of all available modes
|
21
|
+
Stella::Report.plugins
|
22
|
+
#=> {:errors=>Stella::Report::Errors, :statuses=>Stella::Report::Statuses, :headers=>Stella::Report::Headers, :content=>Stella::Report::Content, :metrics=>Stella::Report::Metrics}
|
23
|
+
|
24
|
+
## Headers has a mode
|
25
|
+
Stella::Report::Headers.plugin
|
26
|
+
#=> :headers
|
27
|
+
|
28
|
+
|
29
|
+
## Can process a timline
|
30
|
+
thread = Thread.new do
|
31
|
+
log = Stella::Engine
|
32
|
+
Benelux.timeline.add_message(:kind => :http_log)
|
33
|
+
end
|
34
|
+
thread.join
|
35
|
+
timeline = Benelux.merge_tracks
|
36
|
+
report = Stella::Report.new timeline
|
37
|
+
report.process
|
38
|
+
report.processed?
|
39
|
+
##=> true
|
40
|
+
|
41
|
+
|
42
|
+
# uri = URI.parse ARGV.first
|
43
|
+
# @plan = Stella::Testplan.new uri
|
44
|
+
# @run = Stella::Testrun.new @plan, :checkup, :repetitions => 1
|
45
|
+
# @report = Stella::Engine::Checkup.run @run; nil
|
46
|
+
# run = Stella::Testrun.from_yaml @run.to_yaml
|
47
|
+
# puts @run.to_yaml
|
48
|
+
# puts '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
|
49
|
+
# puts run.to_yaml
|
50
|
+
# puts @run.errors?, run.errors?, run.report.errors?, run.report.statuses.nonsuccessful
|
51
|
+
|
52
|
+
# $ stella checkup http://solutious.com/
|
53
|
+
# ......
|
54
|
+
#
|
55
|
+
# Metrics
|
56
|
+
# socket connect: 10ms
|
57
|
+
# send request: 20ms
|
58
|
+
# first byte: 30ms
|
59
|
+
# last byte: 10ms
|
60
|
+
# response time: 70ms
|
61
|
+
#
|
62
|
+
# Content
|
63
|
+
# page size: 6237kb
|
64
|
+
#
|
65
|
+
# Headers
|
66
|
+
# HTTP/1.1 200 OK
|
67
|
+
# Server: nginx/0.7.61
|
68
|
+
# Date: Mon, 19 Jul 2010 17:05:23 GMT
|
69
|
+
# Content-Type: text/html
|
70
|
+
# Content-Length: 6237
|
71
|
+
# Last-Modified: Sat, 19 Jun 2010 20:52:57 GMT
|
72
|
+
# Connection: keep-alive
|
73
|
+
# Expires: Tue, 20 Jul 2010 17:05:23 GMT
|
74
|
+
# Cache-Control: max-age=86400
|
75
|
+
# Accept-Ranges: bytes
|
76
|
+
#
|
77
|
+
# DNS
|
78
|
+
# solutious.com. 1800 IN A 207.97.227.245
|
79
|
+
#
|
80
|
+
# Host
|
81
|
+
# solutious.com has address 207.97.227.245
|
82
|
+
# solutious.com mail is handled by 70 ASPMX5.GOOGLEMAIL.com.
|
83
|
+
# solutious.com mail is handled by 10 aspmx.l.google.com.
|
84
|
+
# solutious.com mail is handled by 20 ALT1.aspmx.l.google.com.
|
85
|
+
# solutious.com mail is handled by 30 ALT2.aspmx.l.google.com.
|
86
|
+
# solutious.com mail is handled by 40 ASPMX2.GOOGLEMAIL.com.
|
87
|
+
# solutious.com mail is handled by 50 ASPMX3.GOOGLEMAIL.com.
|
88
|
+
# solutious.com mail is handled by 60 ASPMX4.GOOGLEMAIL.com.
|
89
|
+
#
|
90
|
+
# Traceroute
|
91
|
+
# traceroute to solutious.com (207.97.227.245), 64 hops max, 52 byte packets
|
92
|
+
# 1 10.0.1.1 (10.0.1.1) 2.675 ms 1.349 ms 1.302 ms
|
93
|
+
# 2 10.252.128.1 (10.252.128.1) 10.980 ms 6.433 ms 8.999 ms
|
94
|
+
# 3 csw2-vlan202.roemd1.lb.home.nl (213.51.154.1) 9.345 ms 9.704 ms 9.546 ms
|
95
|
+
# 4 csw1-te-1-3.venlo1.lb.home.nl (213.51.157.159) 10.283 ms 10.799 ms 9.311 ms
|
96
|
+
# 5 ht-rc0001-cr102-ae1.core.as9143.net (213.51.158.60) 20.401 ms 10.915 ms 14.186 ms
|
97
|
+
# 6 asd-lc0006-cr101-ae4-0.core.as9143.net (213.51.158.150) 21.662 ms 14.255 ms 12.228 ms
|
98
|
+
# 7 xe-1-1-0.ams20.ip4.tinet.net (77.67.64.65) 15.084 ms 69.496 ms 15.924 ms
|
99
|
+
# 8 ge-11-2-8.er1.ams1.nl.above.net (64.125.14.81) 13.785 ms 12.453 ms
|
100
|
+
# ge-11-0-8.er1.ams1.nl.above.net (64.125.14.77) 13.796 ms
|
101
|
+
# 9 ge-3-0-0.mpr1.ams1.nl.above.net (64.125.26.82) 14.467 ms 12.494 ms 18.616 ms
|
102
|
+
# 10 so-3-0-0.mpr2.ams5.nl.above.net (64.125.28.90) 174.900 ms 16.655 ms 16.108 ms
|
103
|
+
# 11 so-2-0-0.mpr1.lhr2.uk.above.net (64.125.27.177) 22.962 ms 17.936 ms 21.533 ms
|
104
|
+
# 12 so-0-1-0.mpr1.dca2.us.above.net (64.125.27.57) 111.692 ms 101.537 ms 99.477 ms
|
105
|
+
# 13 xe-1-3-0.cr1.dca2.us.above.net (64.125.29.21) 104.827 ms 97.288 ms 97.039 ms
|
106
|
+
# 14 xe-1-1-0.er1.dca2.us.above.net (64.125.26.174) 96.418 ms 97.254 ms 97.766 ms
|
107
|
+
# 15 xe-0-1-0.er1.iad10.us.above.net (64.125.31.206) 97.274 ms 97.726 ms 97.298 ms
|
108
|
+
# 16 209.249.11.37.available.above.net (209.249.11.37) 97.712 ms 96.678 ms 96.586 ms
|
109
|
+
# 17 vlan905.core5.iad2.rackspace.net (72.4.122.10) 95.289 ms 93.712 ms 95.162 ms
|
110
|
+
# 18 aggr301a-1-core5.iad2.rackspace.net (72.4.122.121) 95.627 ms 98.100 ms 96.426 ms
|
111
|
+
# 19 * * *
|
112
|
+
#
|
113
|
+
# 1 10.0.1.1 (10.0.1.1) 4.016 ms 1.309 ms 1.354 ms
|
114
|
+
# 2 10.252.128.1 (10.252.128.1) 6.601 ms 7.316 ms 7.740 ms
|
115
|
+
# 3 csw2-vlan202.roemd1.lb.home.nl (213.51.154.1) 7.603 ms 6.178 ms 8.666 ms
|
116
|
+
# 4 csw1-te-1-3.venlo1.lb.home.nl (213.51.157.159) 8.019 ms 11.461 ms 11.605 ms
|
117
|
+
# 5 ht-rc0001-cr102-ae1.core.as9143.net (213.51.158.60) 9.469 ms 9.764 ms 9.713 ms
|
118
|
+
# 6 asd-lc0006-cr101-ae4-0.core.as9143.net (213.51.158.150) 14.732 ms 17.799 ms 15.138 ms
|
119
|
+
# 7 xe-1-1-0.ams20.ip4.tinet.net (77.67.64.65) 14.819 ms 16.386 ms 13.064 ms
|
120
|
+
# 8 ge-11-2-8.er1.ams1.nl.above.net (64.125.14.81) 19.631 ms
|
121
|
+
# ge-11-0-8.er1.ams1.nl.above.net (64.125.14.77) 13.490 ms 14.538 ms
|
122
|
+
# 9 ge-3-0-0.mpr1.ams1.nl.above.net (64.125.26.82) 14.018 ms 29.386 ms 17.660 ms
|
123
|
+
# 10 so-2-1-0.mpr2.ams5.nl.above.net (64.125.31.254) 15.385 ms 12.865 ms 13.080 ms
|
124
|
+
# 11 xe-3-2-0.mpr1.lhr2.uk.above.net (64.125.31.246) 22.697 ms 20.084 ms 21.045 ms
|
125
|
+
# 12 so-1-1-0.mpr1.dca2.us.above.net (64.125.31.186) 125.494 ms 111.817 ms 125.886 ms
|
126
|
+
# 13 xe-0-3-0.cr1.dca2.us.above.net (64.125.29.17) 101.093 ms 106.459 ms 101.872 ms
|
127
|
+
# 14 xe-0-1-0.er1.dca2.us.above.net (64.125.27.25) 112.132 ms 97.688 ms 99.599 ms
|
128
|
+
# 15 xe-0-1-0.er1.iad10.us.above.net (64.125.31.206) 104.937 ms 97.064 ms 99.862 ms
|
129
|
+
# 16 209.249.11.37.available.above.net (209.249.11.37) 98.160 ms 98.714 ms 97.471 ms
|
130
|
+
# 17 vlan905.core5.iad2.rackspace.net (72.4.122.10) 99.976 ms 99.873 ms 99.243 ms
|
131
|
+
# 18 aggr301a-1-core5.iad2.rackspace.net (72.4.122.121) 97.807 ms 100.763 ms 99.974 ms
|
132
|
+
|
133
|
+
|
data/try/emhttp.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# ruby -Ilib try/emhttp.rb http://www.blamestella.com/
|
2
|
+
require 'stella'
|
3
|
+
require 'eventmachine'
|
4
|
+
require 'em-http'
|
5
|
+
require 'fiber'
|
6
|
+
require 'benelux'
|
7
|
+
require 'pp'
|
8
|
+
|
9
|
+
urls = ARGV
|
10
|
+
if urls.size < 1
|
11
|
+
puts "Usage: #{$0} <url> <url> <...>"
|
12
|
+
exit
|
13
|
+
end
|
14
|
+
|
15
|
+
pending = urls.size
|
16
|
+
|
17
|
+
Benelux.add_timer EventMachine::HttpClient, :connection_completed, :socket_connect
|
18
|
+
|
19
|
+
EM.run do
|
20
|
+
urls.each do |url|
|
21
|
+
http = EM::HttpRequest.new(url).get
|
22
|
+
http.callback {
|
23
|
+
puts "#{url}\n#{http.response_header.status} - #{http.response.length} bytes\n"
|
24
|
+
puts http.response.class
|
25
|
+
|
26
|
+
pending -= 1
|
27
|
+
EM.stop if pending < 1
|
28
|
+
}
|
29
|
+
http.errback {
|
30
|
+
puts "#{url}\n" + http.error
|
31
|
+
|
32
|
+
pending -= 1
|
33
|
+
EM.stop if pending < 1
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
pp Benelux.current_track.timeline.stats.group(:socket_connect).merge
|
39
|
+
|
40
|
+
|
41
|
+
__END__
|
42
|
+
|
43
|
+
class EventMachine::HttpRequest
|
44
|
+
alias_method :original_send_request, :send_request
|
45
|
+
def send_request(&blk)
|
46
|
+
$s = Time.now.to_f
|
47
|
+
ret = original_send_request(&blk)
|
48
|
+
|
49
|
+
ret
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
class EventMachine::HttpClient
|
55
|
+
alias_method :original_connection_completed, :connection_completed
|
56
|
+
def connection_completed
|
57
|
+
ret = original_connection_completed
|
58
|
+
e = Time.now.to_f
|
59
|
+
p [:connect2, e-$s]
|
60
|
+
ret
|
61
|
+
end
|
62
|
+
end
|
data/try/rubyroute.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'timeout'
|
4
|
+
require 'socket'
|
5
|
+
include Socket::Constants
|
6
|
+
|
7
|
+
def random_port
|
8
|
+
1024 + rand(64511)
|
9
|
+
end
|
10
|
+
|
11
|
+
if ARGV[0].nil?
|
12
|
+
puts "Usage: rubyroute host" ; exit 1
|
13
|
+
end
|
14
|
+
|
15
|
+
begin
|
16
|
+
myname = Socket.gethostname
|
17
|
+
rescue SocketError => err_msg
|
18
|
+
puts "Can't get my own host name (#{err_msg})." ; exit 1
|
19
|
+
end
|
20
|
+
|
21
|
+
puts "Tracing route to #{ARGV[0]}"
|
22
|
+
|
23
|
+
ttl = 1
|
24
|
+
max_ttl = 255
|
25
|
+
localport = random_port
|
26
|
+
dgram_sock = UDPSocket::new
|
27
|
+
|
28
|
+
begin
|
29
|
+
dgram_sock.bind( myname, localport )
|
30
|
+
rescue
|
31
|
+
localport = random_port
|
32
|
+
retry
|
33
|
+
end
|
34
|
+
|
35
|
+
icmp_sock = Socket.open( Socket::PF_INET, Socket::SOCK_RAW, Socket::IPPROTO_ICMP )
|
36
|
+
icmp_sockaddr = Socket.pack_sockaddr_in( localport, myname )
|
37
|
+
icmp_sock.bind( icmp_sockaddr )
|
38
|
+
|
39
|
+
begin
|
40
|
+
dgram_sock.connect( ARGV[0], 999 )
|
41
|
+
rescue SocketError => err_msg
|
42
|
+
puts "Can't connect to remote host (#{err_msg})." ; exit 1
|
43
|
+
end
|
44
|
+
|
45
|
+
until ttl == max_ttl
|
46
|
+
dgram_sock.setsockopt( 0, Socket::IP_TTL, ttl )
|
47
|
+
dgram_sock.send( "RubyRoute says hello!", 0 )
|
48
|
+
|
49
|
+
begin
|
50
|
+
Timeout::timeout( 1 ) {
|
51
|
+
data, sender = icmp_sock.recvfrom( 8192 )
|
52
|
+
# 20th and 21th bytes of IP+ICMP datagram carry the ICMP type and code resp.
|
53
|
+
icmp_type = data.unpack( '@20C' )[0]
|
54
|
+
icmp_code = data.unpack( '@21C' )[0]
|
55
|
+
# Extract the ICMP sender from response.
|
56
|
+
puts "TTL = #{ttl}: " + Socket.unpack_sockaddr_in( sender )[1].to_s
|
57
|
+
if ( icmp_type == 3 and icmp_code == 13 )
|
58
|
+
puts "'Communication Administratively Prohibited' from this hop."
|
59
|
+
# ICMP 3/3 is port unreachable and usually means that we've hit the target.
|
60
|
+
elsif ( icmp_type == 3 and icmp_code == 3 )
|
61
|
+
puts "Destination reached. Trace complete."
|
62
|
+
exit 0
|
63
|
+
end
|
64
|
+
}
|
65
|
+
rescue Timeout::Error
|
66
|
+
puts "Timeout error with TTL = #{ttl}!"
|
67
|
+
end
|
68
|
+
|
69
|
+
ttl += 1
|
70
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/try/traceviz.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/bin/env ruby
|
2
|
+
|
3
|
+
require 'timeout'
|
4
|
+
require 'set'
|
5
|
+
require 'socket'
|
6
|
+
|
7
|
+
TRACEROUTE=`which traceroute`.chomp
|
8
|
+
TIMES=3
|
9
|
+
TIMEOUT=60
|
10
|
+
|
11
|
+
def traceroute host
|
12
|
+
`#{TRACEROUTE} -n #{host}`
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
class TraceViz
|
17
|
+
def initialize(times,timeout)
|
18
|
+
@times,@timeout = times,timeout
|
19
|
+
@edges = Set.new
|
20
|
+
@nodes = Set.new
|
21
|
+
@targets = Set.new
|
22
|
+
@this_host = Socket.gethostname
|
23
|
+
@targets << @this_host
|
24
|
+
end
|
25
|
+
|
26
|
+
def trace host
|
27
|
+
@times.times do |i|
|
28
|
+
STDERR.puts "Trace ##{i+1} for #{host}"
|
29
|
+
Timeout::timeout(@timeout) do
|
30
|
+
process_trace(host,traceroute(host))
|
31
|
+
end rescue nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def process_trace host,trace
|
36
|
+
@targets << host
|
37
|
+
trace = [@this_host] + trace.collect do |line|
|
38
|
+
line=line.split
|
39
|
+
line[0].to_i > 0 && line[1] != "*" ? line[1] : nil
|
40
|
+
end.compact
|
41
|
+
trace << host
|
42
|
+
trace.each {|h| @nodes << h }
|
43
|
+
trace.each_cons(2) {|h1,h2| @edges << [h1,h2] }
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_dot
|
47
|
+
res = "digraph G {"
|
48
|
+
@edges.each { |h1,h2| res << " \"#{h1}\"->\"#{h2}\"\n" }
|
49
|
+
@nodes.each do |n|
|
50
|
+
color = @targets.member?(n) ? "lightblue" : "lightgrey"
|
51
|
+
res << " \"#{n}\" [style=filled fillcolor=#{color}]\n"
|
52
|
+
end
|
53
|
+
res << "}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
tv = TraceViz.new(TIMES,TIMEOUT)
|
58
|
+
ARGV.each {|host| tv.trace(host) }
|
59
|
+
puts tv.to_dot
|
60
|
+
|