lumbersexual 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzVlYTg1YjgyNDdhZTA4OWVkZDE4MWJmNjM4ZDA5OTg0YWUyOTkzNQ==
4
+ OWRkYjM5NGMwOTFjMjVkNjhmNWI4YWU0MzI2ODE4MzE1ZDRmMWY1ZQ==
5
5
  data.tar.gz: !binary |-
6
- YTcwZjk2MWE2MWI3ZGU5YzZiMDVjZTE2ZmM1OTcwYmY3NjQ4YzYxOA==
6
+ MTQxY2JhMDZkNDlkNjk1ZWI5NmUzMzMyZDQ2MjY2ZjY2NzhmN2QxZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjI5YmRlZDhkM2UyM2U1ZWVkMzBiNjdkZTYyMmYxYjJiOTU4ZWFmNWZhNTAx
10
- ZmQ2NTJmZWRhNDVlYWNmZmFmOGM4ZjFlMDA4MjQ3N2ZhZWE0ZDYxZTYxOTVj
11
- MDc2ODJhM2I4M2FhODFiYjNmYjU3ZDk1OGY2OWVkMTJmOGJkMGE=
9
+ YTkxNTNlZWE3ZWE0NTJjZWU3MjJiMzBmZTJiOGUyZWFmYzdkZDhhYjRkMDM3
10
+ Njk4ZWIwY2IwMTZlYWUxYzM1ODI3YTRjYzYwZTc0Y2ZmZmVjM2ViODljOTQ2
11
+ M2M4NTk1NzFmMDFhYjdjZWU3MmI4NDAzZGM0MTk3Zjc2YmJiMzg=
12
12
  data.tar.gz: !binary |-
13
- ZDBjNjJjM2VjMDBmZGY3OTc2ODcwM2VkNGZjOTkwOTVkNzExNjljMmM4OWE4
14
- YWY4OGQwNTA3YTdlZGE0MWY3ZjRlNzE0MDAyNzMzZDZhZDljNTI3MDFlMWQx
15
- MWVkOTBhZThjMDk2NzM3ZDE2OTFjOGFmNzBlNDgxNmRlMzM0ZDE=
13
+ NTkzNGQxZTE3ZTMxMDFmMzVkYWJlZmM0NTAxN2M3ZDk3MzZkNWJlYjdhMjYx
14
+ MWI0NjE1MWE4MzFiYjUwMjUwMjAzYjJhZTI3MWNmY2ZkMWU3NGEyNjdhNGIx
15
+ OWI2YWU4ZGFkYmMwNDVkMmI2ZTQxNDRiYjUzODQzY2ZmZGVkMzI=
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+ cache: bundler
2
3
  rvm:
3
4
  - 2.3.0
4
5
  - jruby-9.0.5.0
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Lumbersexual [![Build Status](https://travis-ci.org/sampointer/lumbersexual.svg?branch=master)](https://travis-ci.org/sampointer/lumbersexual)
1
+ # Lumbersexual [![Build Status](https://travis-ci.org/sampointer/lumbersexual.svg?branch=master)](https://travis-ci.org/sampointer/lumbersexual) [![Gem Version](https://badge.fury.io/rb/lumbersexual.svg)](https://badge.fury.io/rb/lumbersexual)
2
2
 
3
3
  <img align="right" width="158" height="144" src="etc/assets/lumber-156795_960_720.png" alt="Lumbersexual" />
4
4
  This gem generates random-enough syslog entries for the purposes of testing syslog throughput, aggregated logging infrastructures and log index performance.
@@ -15,6 +15,20 @@ A dictionary file is needed from which to generate the randomized messages. Unde
15
15
  $ lumbersexual --help
16
16
  ```
17
17
 
18
+ ## Telemetry
19
+ By supplying the switch `--statsdhost` with a hostname you can turn on statsd metric generation. Lumbersexual will assume it can write to a statsd-like daemon on UDP 8125 and will supply 2 types of telemetry.
20
+
21
+ * During a run each thread will increment a counter at the path `lumbersexual.thread.<UUID>` (where UUID is a randomized string for each thread) each time a message is successfully sent.
22
+ * At the end of a run the following metric paths will be produced:
23
+
24
+ ```
25
+ lumbersexual.run.messages_total # gauge
26
+ lumbersexual.run.elapsed # timer
27
+ lumbersexual.run.rate # gauge
28
+ ```
29
+
30
+ It is up to you to use the aggregation functions of telemetry system to combine these into a form you find acceptable.
31
+
18
32
  ## Development
19
33
 
20
34
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec lumbersexual` to use the gem in this directory, ignoring other installed copies of this gem.
data/exe/lumbersexual CHANGED
@@ -6,6 +6,8 @@ require "syslog"
6
6
  require "thread"
7
7
  require "timeout"
8
8
  require "etc"
9
+ require "statsd-ruby"
10
+ require "securerandom"
9
11
 
10
12
  options = Slop.parse do |o|
11
13
  o.string '-D', '--dictionaryfile', 'path to dictionary file (default: /etc/dictionaries-common/words)', default: '/etc/dictionaries-common/words'
@@ -15,6 +17,7 @@ options = Slop.parse do |o|
15
17
  o.integer '-m', '--minwords', 'minimum number of words per message (default: 3)', default: 3
16
18
  o.array '-p', '--priorities', 'additional comma-seperated priorities', default: []
17
19
  o.integer '-r', '--rate', 'messages per second per thread (default: 0, unlimited)', default: 0
20
+ o.string '-s', '--statsdhost', 'send statsd telemetry to the named host (default: off)', default: nil
18
21
  o.integer '-T', '--threads', 'number of threads (defaults to number of cores * 2)', default: Etc.nprocessors * 2
19
22
  o.integer '-t', '--timeout', 'length of execution. 0 for forever (default: 0)', default: 0
20
23
  end
@@ -55,36 +58,43 @@ puts "Rate per thread: #{options[:rate]}/s"
55
58
  puts "Total rate: #{options[:rate] * options[:threads]}/s"
56
59
  puts "Minimum words per message: #{options[:minwords]}"
57
60
  puts "Maximum words per message: #{options[:maxwords]}"
61
+ puts "Statsd host: #{options[:statsdhost]}" if options[:statsdhost]
58
62
  puts "Running ..."
59
63
 
60
64
  # Run until we're done
61
65
  global_count = 0
62
66
  threads = []
63
67
  mutex = Mutex.new
68
+ statsd_global = Statsd.new if options[:statsdhost]
64
69
  start_time = Time.now
65
70
 
66
71
  begin
67
72
  options[:threads].times do
68
73
  threads << Thread.new {
74
+ # Configure telemetry
75
+ statsd = Statsd.new(options[:statsdhost]).tap { |s| s.namespace = "lumbersexual.thread.#{SecureRandom.uuid}" } if options[:statsdhost]
76
+
69
77
  while true do
70
- # Connect to syslog with some sane options and log a message
71
- message = String.new
72
- number_of_words = rand(options[:minwords]..options[:maxwords])
73
- words.sample(number_of_words).each { |w| message << "#{w} " }
74
- ident = "lumbersexual-#{words.sample}"
75
- facility = facilities.sample
76
- priority = priorities.sample
77
-
78
- sleep pause
79
- mutex.synchronize {
80
- syslog = Syslog.open(ident, Syslog::LOG_CONS | Syslog::LOG_NDELAY | Syslog::LOG_PID, priority)
81
- syslog.log(facility, message)
82
- global_count += 1
83
- syslog.close
84
- }
78
+ # Connect to syslog with some sane options and log a message
79
+ message = String.new
80
+ number_of_words = rand(options[:minwords]..options[:maxwords])
81
+ words.sample(number_of_words).each { |w| message << "#{w} " }
82
+ ident = "lumbersexual-#{words.sample}"
83
+ facility = facilities.sample
84
+ priority = priorities.sample
85
+
86
+ sleep pause
87
+ mutex.synchronize {
88
+ syslog = Syslog.open(ident, Syslog::LOG_CONS | Syslog::LOG_NDELAY | Syslog::LOG_PID, priority)
89
+ syslog.log(facility, message)
90
+ global_count += 1
91
+ statsd.increment [ facility, priority, 'messages_sent' ].join('.') if options[:statsdhost]
92
+ syslog.close
93
+ }
85
94
 
86
95
  end
87
96
  }
97
+
88
98
  end
89
99
 
90
100
  Timeout::timeout(options[:timeout]) {
@@ -94,9 +104,14 @@ begin
94
104
  rescue Timeout::Error, Interrupt
95
105
  end_time = Time.now
96
106
  elapsed = end_time - start_time
97
- puts "Sent: #{global_count}"
107
+ rate = global_count / elapsed
108
+ statsd_global = Statsd.new(options[:statsdhost]).tap { |s| s.namespace = "lumbersexual.run" } if options[:statsdhost]
109
+ puts "Sent: #{global_count}"
110
+ statsd_global.gauge 'messages_total', global_count if options[:statsdhost]
98
111
  puts "Elapsed time: #{elapsed}"
99
- puts "Messages per second: #{global_count / elapsed}"
112
+ statsd_global.timing 'elapsed', elapsed if options[:statsdhost]
113
+ puts "Messages per second: #{rate}"
114
+ statsd_global.gauge 'rate', rate if options[:statsdhost]
100
115
  puts "Complete"
101
116
  exit 0
102
117
  end
@@ -1,3 +1,3 @@
1
1
  module Lumbersexual
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/lumbersexual.gemspec CHANGED
@@ -31,6 +31,6 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "rake", "~> 10.0"
32
32
  spec.add_development_dependency "rspec"
33
33
 
34
-
35
34
  spec.add_dependency "slop", "~> 4.3.0"
35
+ spec.add_dependency "statsd-ruby", "~> 1.3.0"
36
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lumbersexual
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Pointer
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: 4.3.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: statsd-ruby
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 1.3.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 1.3.0
69
83
  description: This gem generates random-enough syslog entries for the purposes of testing
70
84
  syslog throughput, aggregated logging infrastructures and log index performance.
71
85
  email: