Class: Fluent::Loadgen::ApacheLogGen
- Inherits:
-
Object
- Object
- Fluent::Loadgen::ApacheLogGen
- Defined in:
- lib/fluent/loadgen/datagen.rb
Instance Method Summary collapse
- #code ⇒ Object
- #gen ⇒ Object
- #host ⇒ Object
-
#initialize ⇒ ApacheLogGen
constructor
A new instance of ApacheLogGen.
- #method ⇒ Object
- #path ⇒ Object
- #size ⇒ Object
- #tag ⇒ Object
- #time ⇒ Object
Constructor Details
#initialize ⇒ ApacheLogGen
Returns a new instance of ApacheLogGen.
29 30 31 32 33 34 35 36 |
# File 'lib/fluent/loadgen/datagen.rb', line 29 def initialize @r = Random.new @methods = ['PUT', 'GET', 'GET', 'GET', 'GET', 'GET', 'GET', 'POST', 'HEAD', 'DELETE'] @codes = ['200', '204', '302', '403', '404', '501', '503', '502'] = ['shibuya', 'asakusa', 'tochigi'] end |
Instance Method Details
#code ⇒ Object
47 48 49 |
# File 'lib/fluent/loadgen/datagen.rb', line 47 def code @codes[@r.rand(@codes.length)] end |
#gen ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/fluent/loadgen/datagen.rb', line 58 def gen { :host => host, :user => "-", :method => method, :path => path, :code => code, :size => size, :referer => "", :agent => "", :time => time, :tag => tag } end |
#host ⇒ Object
38 39 40 |
# File 'lib/fluent/loadgen/datagen.rb', line 38 def host "#{@r.rand(256)}.#{@r.rand(256)}.#{@r.rand(256)}.#{@r.rand(256)}" end |
#method ⇒ Object
41 42 43 |
# File 'lib/fluent/loadgen/datagen.rb', line 41 def method @methods[@r.rand(@methods.length)] end |
#path ⇒ Object
44 45 46 |
# File 'lib/fluent/loadgen/datagen.rb', line 44 def path "/buckets/moriyoshi/object/riaklogo.png" end |
#size ⇒ Object
50 51 52 |
# File 'lib/fluent/loadgen/datagen.rb', line 50 def size @r.rand(1024).to_s end |
#tag ⇒ Object
56 57 |
# File 'lib/fluent/loadgen/datagen.rb', line 56 def tag end |
#time ⇒ Object
53 54 55 |
# File 'lib/fluent/loadgen/datagen.rb', line 53 def time Date.today.to_s end |