dummy_log_generator 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +26 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +127 -0
- data/Rakefile +15 -0
- data/bin/dummy_log_generator +16 -0
- data/dummy_log_generator.conf +11 -0
- data/dummy_log_generator.gemspec +31 -0
- data/lib/dummy_log_generator/cli.rb +89 -0
- data/lib/dummy_log_generator/dsl.rb +61 -0
- data/lib/dummy_log_generator/error.rb +3 -0
- data/lib/dummy_log_generator/generator.rb +93 -0
- data/lib/dummy_log_generator/version.rb +3 -0
- data/lib/dummy_log_generator/worker.rb +40 -0
- data/lib/dummy_log_generator.rb +7 -0
- metadata +188 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 239561651394dd1e8a834b4d6c96d4b40aa2477d
|
4
|
+
data.tar.gz: 5359dbbd8aac2e4a62f6d6eceaac9bd8bbc39013
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 71dc67b5580ff0ece0e3d908728b3babfdc35755235e6577f94d3ff2b84dd45a93491f85117c4439d596bc0d54f48ef7aad69ba37e57c4d6408bffe40c077917
|
7
|
+
data.tar.gz: 345b86a8f396f711ad09886df24af56eecc4f9c30edb63acb16b7d51b48c7b4557ff257c7646c2caa29ef39dfbd993616b2055f412a6780724dab4a56b4ff297
|
data/.gitignore
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
~*
|
4
|
+
#*
|
5
|
+
*~
|
6
|
+
.bundle
|
7
|
+
Gemfile.lock
|
8
|
+
.rbenv-version
|
9
|
+
.ruby-version
|
10
|
+
vendor
|
11
|
+
doc/*
|
12
|
+
tmp/*
|
13
|
+
.yardoc
|
14
|
+
pkg
|
15
|
+
.config
|
16
|
+
.yardoc
|
17
|
+
InstalledFiles
|
18
|
+
_yardoc
|
19
|
+
coverage
|
20
|
+
doc/
|
21
|
+
lib/bundler/man
|
22
|
+
rdoc
|
23
|
+
spec/reports
|
24
|
+
test/tmp
|
25
|
+
test/version_tmp
|
26
|
+
tmp
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 sonots
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
# DummyLogGenerator
|
2
|
+
|
3
|
+
Generates dummy log data for Fluentd benchmark
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'dummy_log_generator'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install dummy_log_generator
|
18
|
+
|
19
|
+
Run as
|
20
|
+
|
21
|
+
$ dummy_log_generator -c dummy_data_generator.conf
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Sample configuration is as follows:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
# dummy_log_generator.conf
|
29
|
+
configure 'sample' do
|
30
|
+
rate 500
|
31
|
+
delimiter "\t"
|
32
|
+
labeled false
|
33
|
+
field :time, type: :datetime, format: "[%Y-%m-%d %H:%M:%S]", random: true
|
34
|
+
field :level, type: :string, any: %w[DEBUG INFO WARN ERROR]
|
35
|
+
field :method, type: :string, any: %w[GET POST PUT]
|
36
|
+
field :uri, type: :string, any: %w[/api/v1/people /api/v1/textdata /api/v1/messages]
|
37
|
+
field :reqtime, type: :float, range: 0.1..5.0
|
38
|
+
field :foobar, type: :string, length: 8
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
Running dummy_log_generator outputs like
|
43
|
+
|
44
|
+
```
|
45
|
+
[1984-05-25 05:10:03] DEBUG GET /api/v1/people 4.451362369925074 fl8nmh4f
|
46
|
+
[2027-11-04 02:58:01] INFO GET /api/v1/people 3.984084722909503 WhsvwEeF
|
47
|
+
[1973-02-17 09:09:34] WARN GET /api/v1/people 2.290704255755689 3UyK3jgi
|
48
|
+
```
|
49
|
+
|
50
|
+
## Configuration Parameters
|
51
|
+
|
52
|
+
Following parameters for configuration is available
|
53
|
+
|
54
|
+
* rate
|
55
|
+
|
56
|
+
Specify how many messages to generate per second. Default: 500 msgs / sec
|
57
|
+
|
58
|
+
* delimiter
|
59
|
+
|
60
|
+
Specify the delimiter between each columns. Default: tab
|
61
|
+
|
62
|
+
* labeled
|
63
|
+
|
64
|
+
Add label or not. Default: true
|
65
|
+
|
66
|
+
* field
|
67
|
+
|
68
|
+
Define data fields to generate
|
69
|
+
|
70
|
+
## Data Types
|
71
|
+
|
72
|
+
You can specify following data types to your `field` parameters:
|
73
|
+
|
74
|
+
* :datetime
|
75
|
+
|
76
|
+
* :format
|
77
|
+
|
78
|
+
You can specify format of datetime as `%Y-%m-%d %H:%M:%S`. See [Time#strftime](http://www.ruby-doc.org/core-2.0.0/Time.html#method-i-strftime) for details.
|
79
|
+
|
80
|
+
* :random
|
81
|
+
|
82
|
+
Generate datetime randomly or not (Time.now). Default: false
|
83
|
+
|
84
|
+
* :string
|
85
|
+
|
86
|
+
* :any
|
87
|
+
|
88
|
+
You can specify an array of strings, then the generator picks one from them randomly
|
89
|
+
|
90
|
+
* :length
|
91
|
+
|
92
|
+
You can specify the length of string to generate randomly
|
93
|
+
|
94
|
+
* :integer
|
95
|
+
|
96
|
+
* :range
|
97
|
+
|
98
|
+
You can specify a range of integers, then the generator picks one in the range (uniform) randomly
|
99
|
+
|
100
|
+
* :float
|
101
|
+
|
102
|
+
* :range
|
103
|
+
|
104
|
+
You can specify a range of integers, then the generator picks one in the range (uniform) randomly
|
105
|
+
|
106
|
+
## Relatives
|
107
|
+
|
108
|
+
There is a [fluent-plugin-dummydata-producer](https://github.com/tagomoris/fluent-plugin-dummydata-producer), but I wanted to output dummy data to a log file, and I wanted a standalone tool.
|
109
|
+
|
110
|
+
## ToDO
|
111
|
+
|
112
|
+
1. write tests
|
113
|
+
2. make it slim (remove active_support, etc)
|
114
|
+
3. outputs to a file (currently, outputs to STDOUT)
|
115
|
+
|
116
|
+
## Contributing
|
117
|
+
|
118
|
+
1. Fork it
|
119
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
120
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
121
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
122
|
+
5. Create new Pull Request
|
123
|
+
|
124
|
+
## Licenses
|
125
|
+
|
126
|
+
See [LICENSE.txt](LICENSE.txt)
|
127
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
require 'rspec/core'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
7
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
8
|
+
end
|
9
|
+
task :default => :spec
|
10
|
+
|
11
|
+
desc 'Open an irb session preloaded with the gem library'
|
12
|
+
task :console do
|
13
|
+
sh 'irb -rubygems -I lib -r dummy_log_generator.rb'
|
14
|
+
end
|
15
|
+
task :c => :console
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'yohoushi' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load File.expand_path("../../lib/dummy_log_generator/cli.rb", __FILE__)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
configure 'sample' do
|
2
|
+
rate 500
|
3
|
+
delimiter "\t"
|
4
|
+
labeled false
|
5
|
+
field :time, type: :datetime, format: "[%Y-%m-%d %H:%M:%S]", random: true
|
6
|
+
field :level, type: :string, any: %w[DEBUG INFO WARN ERROR]
|
7
|
+
field :method, type: :string, any: %w[GET POST PUT]
|
8
|
+
field :uri, type: :string, any: %w[/api/v1/people /api/v1/textdata /api/v1/messages]
|
9
|
+
field :reqtime, type: :float, range: 0.1..5.0
|
10
|
+
field :foobar, type: :string, length: 8
|
11
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dummy_log_generator/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "dummy_log_generator"
|
8
|
+
spec.version = DummyLogGenerator::VERSION
|
9
|
+
spec.authors = ["sonots"]
|
10
|
+
spec.email = ["sonots@gmail.com"]
|
11
|
+
spec.description = %q{Generates dummy log data for Fluentd benchmark}
|
12
|
+
spec.summary = %q{Generates dummy log data for Fluentd benchmark}
|
13
|
+
spec.homepage = "https://github.com/sonots/dummy_log_generator"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "thor"
|
22
|
+
spec.add_dependency "serverengine"
|
23
|
+
spec.add_dependency "active_support"
|
24
|
+
spec.add_dependency "i18n"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
27
|
+
spec.add_development_dependency "rake"
|
28
|
+
spec.add_development_dependency "rspec"
|
29
|
+
spec.add_development_dependency "pry"
|
30
|
+
spec.add_development_dependency "pry-nav"
|
31
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'dummy_log_generator'
|
3
|
+
require 'active_support/core_ext'
|
4
|
+
|
5
|
+
module DummyLogGenerator
|
6
|
+
class CLI < Thor
|
7
|
+
class_option :config, :aliases => ["-c"], :type => :string, :default => 'dummy_log_generator.conf'
|
8
|
+
default_command :start
|
9
|
+
|
10
|
+
def initialize(args = [], opts = [], config = {})
|
11
|
+
super(args, opts, config)
|
12
|
+
|
13
|
+
@options = @options.dup # avoid frozen
|
14
|
+
if options[:config] && File.exists?(options[:config])
|
15
|
+
dsl = instance_eval(File.read(options[:config]), options[:config])
|
16
|
+
@options[:formatter] = dsl.formatter
|
17
|
+
@options[:rate] = dsl.config.rate
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "start", "Start a dummy_log_generator"
|
22
|
+
option :require, :aliases => ["-r"], :type => :string
|
23
|
+
option :daemonize, :aliases => ["-d"], :type => :boolean
|
24
|
+
option :module_name, :aliases => ["-m"], :type => :string, :default => 'DummyLogGenerator::Worker'
|
25
|
+
# options for dummy_log_generator
|
26
|
+
option :rate, :aliases => ["-i"], :type => :numeric
|
27
|
+
def start
|
28
|
+
opts = @options.symbolize_keys.except(:require, :config, :module_name)
|
29
|
+
|
30
|
+
se = ServerEngine.create(nil, @options["module_name"].constantize, opts)
|
31
|
+
se.run
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "stop", "Stops a dummy_log_generator"
|
35
|
+
option :pid_path, :aliases => ["-p"], :type => :string
|
36
|
+
def stop
|
37
|
+
pid = File.read(@options["pid_path"]).to_i
|
38
|
+
|
39
|
+
begin
|
40
|
+
Process.kill("QUIT", pid)
|
41
|
+
puts "Stopped #{pid}"
|
42
|
+
rescue Errno::ESRCH
|
43
|
+
puts "DummyLogGenerator #{pid} not running"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "graceful_stop", "Gracefully stops a dummy_log_generator"
|
48
|
+
option :pid_path, :aliases => ["-p"], :type => :string
|
49
|
+
def graceful_stop
|
50
|
+
pid = File.read(@options["pid_path"]).to_i
|
51
|
+
|
52
|
+
begin
|
53
|
+
Process.kill("TERM", pid)
|
54
|
+
puts "Gracefully stopped #{pid}"
|
55
|
+
rescue Errno::ESRCH
|
56
|
+
puts "DummyLogGenerator #{pid} not running"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "restart", "Restarts a dummy_log_generator"
|
61
|
+
option :pid_path, :aliases => ["-p"], :type => :string
|
62
|
+
def restart
|
63
|
+
pid = File.read(@options["pid_path"]).to_i
|
64
|
+
|
65
|
+
begin
|
66
|
+
Process.kill("HUP", pid)
|
67
|
+
puts "Restarted #{pid}"
|
68
|
+
rescue Errno::ESRCH
|
69
|
+
puts "DummyLogGenerator #{pid} not running"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
desc "graceful_restart", "Graceful restarts a dummy_log_generator"
|
74
|
+
option :pid_path, :aliases => ["-p"], :type => :string
|
75
|
+
def graceful_restart
|
76
|
+
pid = File.read(@options["pid_path"]).to_i
|
77
|
+
|
78
|
+
begin
|
79
|
+
Process.kill("USR1", pid)
|
80
|
+
puts "Gracefully restarted #{pid}"
|
81
|
+
rescue Errno::ESRCH
|
82
|
+
puts "DummyLogGenerator #{pid} not running"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
DummyLogGenerator::CLI.start(ARGV)
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module DummyLogGenerator
|
2
|
+
class Config
|
3
|
+
attr_accessor :rate
|
4
|
+
|
5
|
+
def initiaize
|
6
|
+
@rate = 500
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Formatter
|
11
|
+
attr_accessor :labeled, :delimiter, :fields
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@labeled = true
|
15
|
+
@delimiter = "\t"
|
16
|
+
@fields = {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def output(generated_params)
|
20
|
+
if labeled
|
21
|
+
generated_params.map {|key, val| "#{key}:#{val}" }.join(delimiter)
|
22
|
+
else
|
23
|
+
generated_params.values.join(delimiter)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
module DummyLogGenerator
|
30
|
+
class Dsl
|
31
|
+
attr_reader :formatter
|
32
|
+
attr_reader :config
|
33
|
+
|
34
|
+
def initialize
|
35
|
+
@formatter = Formatter.new
|
36
|
+
@config = Config.new
|
37
|
+
end
|
38
|
+
|
39
|
+
def rate(rate)
|
40
|
+
config.rate = rate
|
41
|
+
end
|
42
|
+
|
43
|
+
def field(name, opts)
|
44
|
+
formatter.fields[name] = opts
|
45
|
+
end
|
46
|
+
|
47
|
+
def delimiter(delimiter)
|
48
|
+
formatter.delimiter = delimiter
|
49
|
+
end
|
50
|
+
|
51
|
+
def labeled(labeled)
|
52
|
+
formatter.labeled = labeled
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def configure(title, &block)
|
58
|
+
dsl = DummyLogGenerator::Dsl.new
|
59
|
+
dsl.instance_eval(&block)
|
60
|
+
dsl
|
61
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module DummyLogGenerator
|
2
|
+
class Generator
|
3
|
+
attr_reader :formatter
|
4
|
+
attr_reader :rand
|
5
|
+
|
6
|
+
def initialize(formatter)
|
7
|
+
@formatter = formatter
|
8
|
+
@rand = ::DummyLogGenerator::Random.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate
|
12
|
+
fields = {}
|
13
|
+
formatter.fields.each do |key, opts|
|
14
|
+
opts = opts.dup
|
15
|
+
type = opts.delete(:type)
|
16
|
+
fields[key] = case type
|
17
|
+
when :datetime
|
18
|
+
rand.datetime(opts)
|
19
|
+
when :string
|
20
|
+
rand.string(opts)
|
21
|
+
when :integer
|
22
|
+
rand.integer(opts)
|
23
|
+
when :float
|
24
|
+
rand.float(opts)
|
25
|
+
else
|
26
|
+
raise ConfigError.new(type)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
formatter.output(fields)
|
30
|
+
end
|
31
|
+
alias_method :gen, :generate
|
32
|
+
end
|
33
|
+
|
34
|
+
class Random
|
35
|
+
def initialize
|
36
|
+
@rand = ::Random.new(0)
|
37
|
+
@chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a # no symbols and multi-bytes for now
|
38
|
+
end
|
39
|
+
|
40
|
+
def string(length: 8, any: nil)
|
41
|
+
unless any.nil?
|
42
|
+
self.any(any)
|
43
|
+
else
|
44
|
+
Array.new(length){@chars[rand(@chars.size-1)]}.join
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def interger(range: nil)
|
49
|
+
unless range.nil?
|
50
|
+
self.range(range)
|
51
|
+
else
|
52
|
+
rand(0..2,147,483,647)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def float(range: nil)
|
57
|
+
unless range.nil?
|
58
|
+
self.range(range)
|
59
|
+
else
|
60
|
+
r = rand(1..358)
|
61
|
+
r * Math.cos(r) # cheat
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def datetime(format: "%Y-%m-%d %H:%M:%S.%3N", random: false)
|
66
|
+
time = if random
|
67
|
+
y = rand(1970..2037);
|
68
|
+
m = rand(1..12);
|
69
|
+
d = rand(1..27);
|
70
|
+
h = rand(0..23);
|
71
|
+
min = rand(0..59);
|
72
|
+
s = rand(0..59);
|
73
|
+
usec = rand(0..999999);
|
74
|
+
Time.local(y, m, d, h, min, s, usec)
|
75
|
+
else
|
76
|
+
Time.now
|
77
|
+
end
|
78
|
+
time.strftime(format)
|
79
|
+
end
|
80
|
+
|
81
|
+
def range(range)
|
82
|
+
rand(range)
|
83
|
+
end
|
84
|
+
|
85
|
+
def any(any)
|
86
|
+
any[rand(any.size-1)]
|
87
|
+
end
|
88
|
+
|
89
|
+
def rand(arg = nil)
|
90
|
+
@rand.rand(arg)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'serverengine'
|
2
|
+
|
3
|
+
module DummyLogGenerator
|
4
|
+
module Worker
|
5
|
+
def initialize
|
6
|
+
reload
|
7
|
+
end
|
8
|
+
|
9
|
+
def reload
|
10
|
+
@rate = config[:rate] || 500 # msgs / sec
|
11
|
+
@formatter = config[:formatter]
|
12
|
+
@generator = Generator.new(@formatter)
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
batch_num = (@rate / 9).to_i + 1
|
17
|
+
while !@stop
|
18
|
+
current_time = Time.now.to_i
|
19
|
+
rate_count = 0
|
20
|
+
|
21
|
+
while !@stop && rate_count < @rate && Time.now.to_i == current_time
|
22
|
+
batch_num.times do
|
23
|
+
# ToDo: what if generation is slower than I/O?
|
24
|
+
STDOUT.puts @generator.generate
|
25
|
+
end
|
26
|
+
rate_count += batch_num
|
27
|
+
sleep 0.1
|
28
|
+
end
|
29
|
+
# wait for next second
|
30
|
+
while !@stop && Time.now.to_i == current_time
|
31
|
+
sleep 0.04
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def stop
|
37
|
+
@stop = true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dummy_log_generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sonots
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: serverengine
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: active_support
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: i18n
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry-nav
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: Generates dummy log data for Fluentd benchmark
|
140
|
+
email:
|
141
|
+
- sonots@gmail.com
|
142
|
+
executables:
|
143
|
+
- dummy_log_generator
|
144
|
+
extensions: []
|
145
|
+
extra_rdoc_files: []
|
146
|
+
files:
|
147
|
+
- .gitignore
|
148
|
+
- .travis.yml
|
149
|
+
- CHANGELOG.md
|
150
|
+
- Gemfile
|
151
|
+
- LICENSE.txt
|
152
|
+
- README.md
|
153
|
+
- Rakefile
|
154
|
+
- bin/dummy_log_generator
|
155
|
+
- dummy_log_generator.conf
|
156
|
+
- dummy_log_generator.gemspec
|
157
|
+
- lib/dummy_log_generator.rb
|
158
|
+
- lib/dummy_log_generator/cli.rb
|
159
|
+
- lib/dummy_log_generator/dsl.rb
|
160
|
+
- lib/dummy_log_generator/error.rb
|
161
|
+
- lib/dummy_log_generator/generator.rb
|
162
|
+
- lib/dummy_log_generator/version.rb
|
163
|
+
- lib/dummy_log_generator/worker.rb
|
164
|
+
homepage: https://github.com/sonots/dummy_log_generator
|
165
|
+
licenses:
|
166
|
+
- MIT
|
167
|
+
metadata: {}
|
168
|
+
post_install_message:
|
169
|
+
rdoc_options: []
|
170
|
+
require_paths:
|
171
|
+
- lib
|
172
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - '>='
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
177
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
requirements: []
|
183
|
+
rubyforge_project:
|
184
|
+
rubygems_version: 2.0.3
|
185
|
+
signing_key:
|
186
|
+
specification_version: 4
|
187
|
+
summary: Generates dummy log data for Fluentd benchmark
|
188
|
+
test_files: []
|