stella 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/{README.txt → README.textile} +63 -40
  2. data/Rakefile +7 -5
  3. data/bin/stella +1 -1
  4. data/bin/stella.bat +12 -0
  5. data/lib/pcaplet.rb +180 -0
  6. data/lib/stella/adapter/ab.rb +57 -33
  7. data/lib/stella/adapter/base.rb +11 -1
  8. data/lib/stella/adapter/httperf.rb +13 -10
  9. data/lib/stella/adapter/pcap_watcher.rb +221 -0
  10. data/lib/stella/adapter/proxy_watcher.rb +76 -0
  11. data/lib/stella/adapter/siege.rb +28 -11
  12. data/lib/stella/cli/agents.rb +2 -2
  13. data/lib/stella/cli/base.rb +37 -1
  14. data/lib/stella/cli/localtest.rb +1 -2
  15. data/lib/stella/cli/sysinfo.rb +17 -0
  16. data/lib/stella/cli/watch.rb +278 -0
  17. data/lib/stella/cli.rb +23 -11
  18. data/lib/stella/command/base.rb +1 -10
  19. data/lib/stella/command/localtest.rb +43 -23
  20. data/lib/stella/data/domain.rb +75 -0
  21. data/lib/stella/data/http.rb +124 -0
  22. data/lib/stella/logger.rb +16 -5
  23. data/lib/stella/storable.rb +4 -2
  24. data/lib/stella/support.rb +71 -0
  25. data/lib/stella/sysinfo.rb +247 -0
  26. data/lib/stella/test/base.rb +5 -1
  27. data/lib/stella/test/definition.rb +1 -1
  28. data/lib/stella/test/run/summary.rb +14 -4
  29. data/lib/stella/text/resource.rb +0 -1
  30. data/lib/stella.rb +28 -10
  31. data/lib/utils/domainutil.rb +47 -0
  32. data/lib/utils/fileutil.rb +22 -3
  33. data/lib/utils/httputil.rb +184 -128
  34. data/lib/utils/mathutil.rb +20 -7
  35. data/lib/win32/Console/ANSI.rb +305 -0
  36. data/lib/win32/Console.rb +970 -0
  37. data/spec/show-agents_spec.rb +0 -0
  38. data/support/kvm.h +91 -0
  39. data/support/ruby-pcap-takuma-notes.txt +19 -0
  40. data/support/ruby-pcap-takuma-patch.txt +30 -0
  41. data/support/text/en.yaml +26 -3
  42. data/vendor/frylock/README.textile +72 -0
  43. data/vendor/frylock/bin/example +170 -0
  44. data/vendor/frylock/frylock.gemspec +18 -0
  45. data/vendor/frylock/lib/frylock/exceptions.rb +24 -0
  46. data/vendor/frylock/lib/frylock.rb +232 -0
  47. data/vendor/frylock/test/command_test.rb +33 -0
  48. data/vendor/hitimes-0.4.0/HISTORY +28 -0
  49. data/vendor/hitimes-0.4.0/LICENSE.txt +19 -0
  50. data/vendor/hitimes-0.4.0/README +80 -0
  51. data/vendor/hitimes-0.4.0/Rakefile +63 -0
  52. data/vendor/hitimes-0.4.0/examples/benchmarks.rb +86 -0
  53. data/vendor/hitimes-0.4.0/examples/stats.rb +29 -0
  54. data/vendor/hitimes-0.4.0/ext/extconf.rb +15 -0
  55. data/vendor/hitimes-0.4.0/ext/hitimes_ext.c +21 -0
  56. data/vendor/hitimes-0.4.0/ext/hitimes_instant_clock_gettime.c +20 -0
  57. data/vendor/hitimes-0.4.0/ext/hitimes_instant_osx.c +16 -0
  58. data/vendor/hitimes-0.4.0/ext/hitimes_instant_windows.c +27 -0
  59. data/vendor/hitimes-0.4.0/ext/hitimes_interval.c +340 -0
  60. data/vendor/hitimes-0.4.0/ext/hitimes_interval.h +73 -0
  61. data/vendor/hitimes-0.4.0/ext/hitimes_stats.c +242 -0
  62. data/vendor/hitimes-0.4.0/ext/hitimes_stats.h +30 -0
  63. data/vendor/hitimes-0.4.0/ext/rbconfig-mingw.rb +178 -0
  64. data/vendor/hitimes-0.4.0/ext/rbconfig.rb +178 -0
  65. data/vendor/hitimes-0.4.0/gemspec.rb +54 -0
  66. data/vendor/hitimes-0.4.0/lib/hitimes/mutexed_stats.rb +23 -0
  67. data/vendor/hitimes-0.4.0/lib/hitimes/paths.rb +54 -0
  68. data/vendor/hitimes-0.4.0/lib/hitimes/stats.rb +29 -0
  69. data/vendor/hitimes-0.4.0/lib/hitimes/timer.rb +223 -0
  70. data/vendor/hitimes-0.4.0/lib/hitimes/version.rb +42 -0
  71. data/vendor/hitimes-0.4.0/lib/hitimes.rb +24 -0
  72. data/vendor/hitimes-0.4.0/spec/interval_spec.rb +115 -0
  73. data/vendor/hitimes-0.4.0/spec/mutex_stats_spec.rb +34 -0
  74. data/vendor/hitimes-0.4.0/spec/paths_spec.rb +14 -0
  75. data/vendor/hitimes-0.4.0/spec/spec_helper.rb +6 -0
  76. data/vendor/hitimes-0.4.0/spec/stats_spec.rb +72 -0
  77. data/vendor/hitimes-0.4.0/spec/timer_spec.rb +105 -0
  78. data/vendor/hitimes-0.4.0/spec/version_spec.rb +27 -0
  79. data/vendor/hitimes-0.4.0/tasks/announce.rake +39 -0
  80. data/vendor/hitimes-0.4.0/tasks/config.rb +107 -0
  81. data/vendor/hitimes-0.4.0/tasks/distribution.rake +53 -0
  82. data/vendor/hitimes-0.4.0/tasks/documentation.rake +33 -0
  83. data/vendor/hitimes-0.4.0/tasks/extension.rake +64 -0
  84. data/vendor/hitimes-0.4.0/tasks/rspec.rake +31 -0
  85. data/vendor/hitimes-0.4.0/tasks/rubyforge.rake +52 -0
  86. data/vendor/hitimes-0.4.0/tasks/utils.rb +80 -0
  87. data/vendor/useragent/lib/user_agent.rb +1 -1
  88. metadata +87 -8
@@ -0,0 +1,305 @@
1
+ #
2
+ # Win32::Console::ANSI
3
+ #
4
+ # Copyright 2004 - Gonzalo Garramuno
5
+ # Licensed under GNU General Public License or Perl's Artistic License
6
+ #
7
+ # Based on Perl's Win32::Console::ANSI
8
+ # Copyright (c) 2003 Jean-Louis Morel <jl_morel@bribes.org>
9
+ # Licensed under GNU General Public License or Perl's Artistic License
10
+ #
11
+ require "win32/Console"
12
+
13
+ module Win32
14
+ class Console
15
+ module ANSI
16
+
17
+ class IO < IO
18
+
19
+ VERSION = '0.05'
20
+ DEBUG = nil
21
+
22
+ require "win32/registry"
23
+
24
+ include Win32::Console::Constants
25
+
26
+ # @todo: encode is another perl module
27
+ EncodeOk = false
28
+
29
+ # Retrieving the codepages
30
+ cpANSI = nil
31
+ Win32::Registry::HKEY_LOCAL_MACHINE.open('SYSTEM\CurrentControlSet\Control\Nls\CodePage' ) { |reg|
32
+ cpANSI = reg['ACP']
33
+ }
34
+
35
+ STDERR.puts "Unable to read Win codepage #{cpANSI}" if DEBUG && !cpANSI
36
+
37
+
38
+ cpANSI = 'cp'+(cpANSI ? cpANSI : '1252') # Windows codepage
39
+ OEM = Win32::Console::OutputCP()
40
+ cpOEM = 'cp' + OEM.to_s # DOS codepage
41
+ @@cp = cpANSI + cpOEM
42
+
43
+ STDERR.puts "EncodeOk=#{EncodeOk} cpANSI=#{cpANSI} "+
44
+ "cpOEM=#{cpOEM}" if DEBUG
45
+
46
+ @@color = { 30 => 0, # black foreground
47
+ 31 => FOREGROUND_RED, # red foreground
48
+ 32 => FOREGROUND_GREEN, # green foreground
49
+ 33 => FOREGROUND_RED|FOREGROUND_GREEN, # yellow foreground
50
+ 34 => FOREGROUND_BLUE, # blue foreground
51
+ 35 => FOREGROUND_BLUE|FOREGROUND_RED, # magenta foreground
52
+ 36 => FOREGROUND_BLUE|FOREGROUND_GREEN, # cyan foreground
53
+ 37 => FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE, # white foreground
54
+ 40 => 0, # black background
55
+ 41 => BACKGROUND_RED, # red background
56
+ 42 => BACKGROUND_GREEN, # green background
57
+ 43 => BACKGROUND_RED|BACKGROUND_GREEN, # yellow background
58
+ 44 => BACKGROUND_BLUE, # blue background
59
+ 45 => BACKGROUND_BLUE|BACKGROUND_RED, # magenta background
60
+ 46 => BACKGROUND_BLUE|BACKGROUND_GREEN, # cyan background
61
+ 47 => BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE, # white background
62
+ }
63
+
64
+ def initialize
65
+ super(1,'w')
66
+ @Out = Win32::Console.new(STD_OUTPUT_HANDLE)
67
+ @x = @y = 0 # to save cursor position
68
+ @foreground = 7
69
+ @background = 0
70
+ @bold =
71
+ @underline =
72
+ @revideo =
73
+ @concealed = nil
74
+ @conv = 1 # char conversion by default
75
+ end
76
+
77
+
78
+ def write(*s)
79
+ s.each { |x|
80
+ _PrintString(x)
81
+ }
82
+ end
83
+
84
+
85
+ private
86
+
87
+ def _PrintString(t)
88
+ s = t.dup
89
+ while s != ''
90
+ if s.sub!( /([^\e]*)?\e([\[\(])([0-9\;\=]*)([a-zA-Z@])(.*)/s,'\5')
91
+ @Out.Write((_conv("#$1")))
92
+ if $2 == '['
93
+ case $4
94
+ when 'm' # ESC[#;#;....;#m Set display attributes
95
+ attributs = $3.split(';')
96
+ attributs.push(nil) unless attributs # ESC[m == ESC[;m ==...==ESC[0m
97
+ for attr in attributs
98
+ atv = attr.to_i
99
+ if atv > 0
100
+ if atv == 1
101
+ @bold = 1
102
+ elsif atv == 21
103
+ @bold = nil
104
+ elsif atv == 4
105
+ @underline = 1
106
+ elsif atv == 24
107
+ @underline = nil
108
+ elsif atv == 7
109
+ @revideo = 1
110
+ elsif atv == 27
111
+ @revideo = nil
112
+ elsif atv == 8
113
+ @concealed = 1
114
+ elsif atv == 28
115
+ @concealed = nil
116
+ elsif atv >= 30 and atv <= 37
117
+ @foreground = atv - 30
118
+ elsif atv >=40 and atv <=47
119
+ @background = atv - 40
120
+ end
121
+ else # ESC[0m reset
122
+ @foreground = 7
123
+ @background = 0
124
+ @bold =
125
+ @underline =
126
+ @revideo =
127
+ @concealed = nil
128
+ end
129
+ end
130
+
131
+ if @revideo
132
+ attribut = @@color[40+@foreground] |
133
+ @@color[30+@background]
134
+ else
135
+ attribut = @@color[30+@foreground] |
136
+ @@color[40+@background]
137
+ end
138
+ attribut |= FOREGROUND_INTENSITY if @bold
139
+ attribut |= BACKGROUND_INTENSITY if @underline
140
+ @Out.Attr(attribut)
141
+ when 'J'
142
+ if !$3 or $3 == '' # ESC[0J from cursor to end of display
143
+ info = @Out.Info()
144
+ s = ' ' * ((info[1]-info[3]-1)*info[0]+info[0]-info[2]-1)
145
+ @Out.WriteChar(s, info[2], info[3])
146
+ @Out.Cursor(info[2], info[3])
147
+ elsif $3 == '1' # ESC[1J erase from start to cursor.
148
+ info = @Out.Info()
149
+ s = ' ' * (info[3]*info[0]+info[2]+1)
150
+ @Out.WriteChar(s, 0, 0)
151
+ @Out.Cursor(info[2], info[3])
152
+ elsif $3 == '2' # ESC[2J Clear screen and home cursor
153
+ @Out.Cls()
154
+ @Out.Cursor(0, 0)
155
+ else
156
+ STDERR.print "\e#$2#$3#$4" if DEBUG # if ESC-code not implemented
157
+ end
158
+ when 'K'
159
+ info = @Out.Info()
160
+ if !$3 or $3 == '' # ESC[0K Clear to end of line
161
+ s = ' ' * (info[7]-info[2]+1)
162
+ @Out.Write(s)
163
+ @Out.Cursor(info[2], info[3])
164
+ elsif $3=='1' # ESC[1K Clear from start of line to cursor
165
+ s = ' '*(info[2]+1)
166
+ @Out.WriteChar(s, 0, info[3])
167
+ @Out.Cursor(info[2], info[3])
168
+ elsif $3=='2' # ESC[2K Clear whole line.
169
+ s = ' '* info[0]
170
+ @Out.WriteChar(s, 0, info[3])
171
+ @Out.Cursor(info[2], info[3])
172
+ end
173
+ when 'L' # ESC[#L Insert # blank lines.
174
+ n = $3 == ''? 1 : $3.to_i # ESC[L == ESC[1L
175
+ info = @Out.Info()
176
+ @Out.Scroll(0, info[3], info[0]-1, info[1]-1,
177
+ 0, info[3] + n.to_i,
178
+ ' '[0], @Out.Attr(),
179
+ 0, 0, 10000, 10000)
180
+ @Out.Cursor(info[2], info[3])
181
+ when 'M' # ESC[#M Delete # line.
182
+ n = $3 == ''? 1 : $3.to_i # ESC[M == ESC[1M
183
+ info = @Out.Info();
184
+ @Out.Scroll(0, info[3]+n, info[0]-1, info[1]-1,
185
+ 0, info[3],
186
+ ' '[0], @Out.Attr(),
187
+ 0, 0, 10000, 10000)
188
+ @Out.Cursor(info[2], info[3])
189
+ when 'P' # ESC[#P Delete # characters.
190
+ n = $3 == ''? 1 : $3.to_i # ESC[P == ESC[1P
191
+ info = @Out.Info()
192
+ n = info[0]-info[2] if info[2]+n > info[0]-1
193
+ @Out.Scroll(info[2]+n, info[3] , info[0]-1, info[3],
194
+ info[2], info[3],
195
+ ' '[0], @Out.Attr(),
196
+ 0, 0, 10000, 10000)
197
+ s = ' ' * n
198
+ @Out.Cursor(info[0]-n, info[3])
199
+ @Out.Write(s)
200
+ @Out.Cursor(info[2], info[3])
201
+ when '@' # ESC[#@ Insert # blank Characters
202
+ s = ' ' * $3.to_i
203
+ info = @Out.Info()
204
+ s << @Out.ReadChar(info[7]-info[2]+1, info[2], info[3])
205
+ s = s[0..-($3.to_i)]
206
+ @Out.Write(s);
207
+ @Out.Cursor(info[2], info[3])
208
+ when 'A' # ESC[#A Moves cursor up # lines
209
+ (x, y) = @Out.Cursor()
210
+ n = $3 == ''? 1 : $3.to_i; # ESC[A == ESC[1A
211
+ @Out.Cursor(x, y-n)
212
+ when 'B' # ESC[#B Moves cursor down # lines
213
+ (x, y) = @Out.Cursor()
214
+ n = $3 == ''? 1 : $3.to_i; # ESC[B == ESC[1B
215
+ @Out.Cursor(x, y+n)
216
+ when 'C' # ESC[#C Moves cursor forward # spaces
217
+ (x, y) = @Out.Cursor()
218
+ n = $3 == ''? 1 : $3.to_i; # ESC[C == ESC[1C
219
+ @Out.Cursor(x+n, y)
220
+ when 'D' # ESC[#D Moves cursor back # spaces
221
+ (x, y) = @Out.Cursor()
222
+ n = $3 == ''? 1 : $3.to_i; # ESC[D == ESC[1D
223
+ @Out.Cursor(x-n, y)
224
+ when 'E' # ESC[#E Moves cursor down # lines, column 1.
225
+ x, y = @Out.Cursor()
226
+ n = $3 == ''? 1 : $3.to_i; # ESC[E == ESC[1E
227
+ @Out.Cursor(0, y+n)
228
+ when 'F' # ESC[#F Moves cursor up # lines, column 1.
229
+ x, y = @Out.Cursor()
230
+ n = $3 == ''? 1 : $3.to_i; # ESC[F == ESC[1F
231
+ @Out.Cursor(0, y-n)
232
+ when 'G' # ESC[#G Moves cursor column # in current row.
233
+ x, y = @Out.Cursor()
234
+ n = $3 == ''? 1 : $3.to_i; # ESC[G == ESC[1G
235
+ @Out.Cursor(n-1, y)
236
+ when 'f' # ESC[#;#f Moves cursor to line #, column #
237
+ y, x = $3.split(';')
238
+ x = 1 unless x # ESC[;5H == ESC[1;5H ...etc
239
+ y = 1 unless y
240
+ @Out.Cursor(x.to_i-1, y.to_i-1) # origin (0,0) in DOS console
241
+ when 'H' # ESC[#;#H Moves cursor to line #, column #
242
+ y, x = $3.split(';')
243
+ x = 1 unless x # ESC[;5H == ESC[1;5H ...etc
244
+ y = 1 unless y
245
+ @Out.Cursor(x.to_i-1, y.to_i-1) # origin (0,0) in DOS console
246
+ when 's' # ESC[s Saves cursor position for recall later
247
+ (@x, @y) = @Out.Cursor()
248
+ when 'u' # ESC[u Return to saved cursor position
249
+ @Out.Cursor(@x, @y)
250
+ else
251
+ STDERR.puts "\e#$2#$3#$4 not implemented" if DEBUG # ESC-code not implemented
252
+ end
253
+ else
254
+ case $4
255
+ when 'U' # ESC(U no mapping
256
+ @conv = nil
257
+ when 'K' # ESC(K mapping if it exist
258
+ @Out.OutputCP(OEM) # restore original codepage
259
+ @conv = 1
260
+ when 'X' # ESC(#X codepage **EXPERIMENTAL**
261
+ @conv = nil
262
+ @Out.OutputCP($3)
263
+ else
264
+ STDERR.puts "\e#$2#$3#$4 not implemented" if DEBUG # ESC-code not implemented
265
+ end
266
+ end
267
+ else
268
+ @Out.Write(_conv(s))
269
+ s=''
270
+ end
271
+ end
272
+ end
273
+
274
+ def _conv(s)
275
+ if @concealed
276
+ s.gsub!( /\S/,' ')
277
+ elsif @conv
278
+ if EncodeOk
279
+ from_to(s, cpANSI, cpOEM)
280
+ elsif @@cp == 'cp1252cp850' # WinLatin1 --> DOSLatin1
281
+ s.tr!("���������������������������������������������������������������������������������������������������ÁāŁƁǁȁɁʁˁ́́΁ρЁсҁӁԁՁցׁ؁فځہ܁݁ށ߁��������������������������������������������","???�??????????????????????????��������ρ��݁�����������������������������������������󁨁������ǎ����Ԑ�ҁӁށցׁ؁с������噞����ꚁ��ᅁ���Ƅ�������������Ё������䔁����������")
282
+ elsif @@cp == 'cp1252cp437' # WinLatin1 --> DOSLatinUS
283
+ s.tr!("���������������������������������������������������������������������������������������������������ÁāŁƁǁȁɁʁˁ́́΁ρЁсҁӁԁՁցׁ؁فځہ܁݁ށ߁��������������������������������������������", "??????????????????????????????������?�????������???�����??��?��??��������?��????����?�???????��????�?????�??�ᅁ��?�������������?������?���?�����??�")
284
+ elsif @@cp == 'cp1250cp852' # WinLatin2 --> DOSLatin2
285
+ s.tr!("���������������������������������������������������������������������������������������������������ÁāŁƁǁȁɁʁˁ́́΁ρЁсҁӁԁՁցׁ؁فځہ܁݁ށ߁��������������������������������������������",
286
+ "??????????��?��??????????��?������������ρ�?����?��������?����?���???����������񖁾�聵���Ǝ���������Ӂ��ցׁҁс�Ձ��⊙����ށ�뚁�݁�ꁠ��DŽ���������؁���ԁЁ�偢�����������������" )
287
+ elsif @@cp == 'cp1251cp855' # WinCyrillic --> DOSCyrillic
288
+ s.tr!("���������������������������������������������������������������������������������������������������ÁāŁƁǁȁɁʁˁ́́΁ρЁсҁӁԁՁցׁ؁فځہ܁݁ށ߁��������������������������������������������",
289
+ "��?�??????�?����?????????�?����������??���?���?��?�??��????������������쁭������􁸁��ǁсӁՁׁ݁���聫�����������������������끬������󁷁��ƁЁҁԁց؁���灪������������������")
290
+ end
291
+ end
292
+ return s
293
+ end
294
+
295
+ end
296
+
297
+ # end print overloading
298
+
299
+ end
300
+ end
301
+ end
302
+
303
+
304
+ $stdout = Win32::Console::ANSI::IO.new()
305
+