Class: Fluent::Loadgen::ApacheLogGen

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/loadgen/datagen.rb

Instance Method Summary collapse

Constructor Details

#initializeApacheLogGen

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']
  @tags = ['shibuya', 'asakusa', 'tochigi']
end

Instance Method Details

#codeObject



47
48
49
# File 'lib/fluent/loadgen/datagen.rb', line 47

def code
  @codes[@r.rand(@codes.length)]
end

#genObject



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

#hostObject



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

#methodObject



41
42
43
# File 'lib/fluent/loadgen/datagen.rb', line 41

def method
  @methods[@r.rand(@methods.length)]
end

#pathObject



44
45
46
# File 'lib/fluent/loadgen/datagen.rb', line 44

def path
  "/buckets/moriyoshi/object/riaklogo.png"
end

#sizeObject



50
51
52
# File 'lib/fluent/loadgen/datagen.rb', line 50

def size
  @r.rand(1024).to_s
end

#tagObject



56
57
# File 'lib/fluent/loadgen/datagen.rb', line 56

def tag
end

#timeObject



53
54
55
# File 'lib/fluent/loadgen/datagen.rb', line 53

def time
  Date.today.to_s
end