lumbersexual 0.1.0

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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZWU2NDlkMTQ0ZmI5MWYwYzJkZjIwMTQ0Y2FhNmFjNjIyY2QxMjY2OQ==
5
+ data.tar.gz: !binary |-
6
+ MGE2YTVkNDUwMDFhMzk5NmIxZGVkMGIyODJmNTI2ZGY0ZmYzNDI3Yw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ Njg3OWEwMmRjYTU2MDY5OGU1MjZlNWE0MTk1ZTVhNmJkYTYxZjA5YTFiOWYw
10
+ Nzc1NThjZDNlM2JlOWE5MmNlM2M4MzlhOWQ0NmFlMGNlNjJmZTg5YTI2OGJh
11
+ MzJmZWZkZjc4YTA2MjgwZjU1ODg5ZDNiYmIzNzg3NmU3NzdjZWU=
12
+ data.tar.gz: !binary |-
13
+ Y2ExNjk0ZWY1MDgxOWIwOWY3MjdmOWVlOWY0ZmE1OGFlY2NlOWFiNThhMDA0
14
+ ZjM4NzgwOGY1ZjhmMTk4NGRjMzliNzg0NjEyZjcwN2ZiMTVlYTIwYTQ2YjIz
15
+ NTY3Mzc5MzQxZTUzMzdlNTc5MDZkY2YyZTk3Y2M2ZWFkOTUwODI=
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.0
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ - jruby-9.0.5.0
5
+ before_install: gem install bundler -v 1.10.6
6
+ deploy:
7
+ provider: rubygems
8
+ api_key:
9
+ secure: qpkX3I/j5aXJvD5pBdiddZ63uCxMsQFeTsWkingDkLsxV/DPAiTn9orwmU3XnYfZfr7tU2z8UztHzqPtIfFmTD/v6FLDqLUzYL8SpfZIuu4BgzbFhQ7fpw2me6a1ISOGz5wkMQ34klZMuPZjX2x9KjrkDh8ZSsZziHi2cpkbj0JLW91ezW+W8yrQvOm/dch0uXMLEOlbxbjPjHr76bFQqvkc2Z0YprxK2j525t3+SEnVN51DiVGimPlUrIQ+mtjGOqbZYCMw4rBex+BdQS9T4as6pG/BT1Tk92MFE/gRMJg9QO/DqwolB3mGNBEYR+3skGktz2UBMSGu6XDFxEOqOgK0joe+ehfiL1Oq2hnp482vHODl06HjYIjVlsXGT7aD7C4TcA2yrRW5hg8UaYoVkIbiZz26GrXX8vEZ4C4HgRruQkyt31cLvhdRPJvStkXzgQQXbwmS6P3lkRE3gxwYyeuzblpbprg2Nolmt9GO//1yQ497YUsY18tK9fOZr8vz/xiCuDMQRuJcheA9C27Z9nJZB2iH4xTNwNl53eFYhWMVYdkw16JYWJ17xMg+VnWUwkA/jODU0GlXEvNHNFRaDA9qyedIk5ainAnzGJpExCsWuKFJvJl1Qn2bD3/neruCIBoCaxQOdBrGd/579ALyjkujRmgZTOiaqRh4DaYHGrg=
10
+ gem: lumbersexual
11
+ on:
12
+ tags: true
13
+ repo: sampointer/lumbersexual
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in lumbersexual.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Sam Pointer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Lumbersexual [![Build Status](https://travis-ci.org/sampointer/lumbersexual.svg?branch=master)](https://travis-ci.org/sampointer/lumbersexual)
2
+
3
+ <img align="right" width="158" height="144" src="etc/assets/lumber-156795_960_720.png" alt="Lumbersexual" />
4
+ This gem generates random-enough syslog entries for the purposes of testing syslog throughput, aggregated logging infrastructures and log index performance.
5
+
6
+ ## Requirements
7
+
8
+ Whilst `lumbersexual` will run correctly under MRI 2.3.0 the best performance at scale can be obtained by using jruby-9.0.5.0 or later under Java 7. Furthermore throughput is greatest and most accurate with machines with 2 cores or more. By default twice as many threads as cores will be used.
9
+
10
+ A dictionary file is needed from which to generate the randomized messages. Under Debian-derived distributions `apt-get install dictionaries-common` is not a bad place to start.
11
+
12
+ ## Usage
13
+
14
+ ```bash
15
+ $ lumbersexual --help
16
+ ```
17
+
18
+ ## Development
19
+
20
+ 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.
21
+
22
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
23
+
24
+ ## Contributing
25
+
26
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sampointer/lumbersexual.
27
+
28
+ ## License
29
+
30
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "lumbersexual"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/exe/lumbersexual ADDED
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "lumbersexual"
4
+ require "slop"
5
+ require "syslog"
6
+ require "thread"
7
+ require "timeout"
8
+
9
+ options = Slop.parse do |o|
10
+ o.string '-D', '--dictionaryfile', 'path to dictionary file (default: /etc/dictionaries-common/words)', default: '/etc/dictionaries-common/words'
11
+ o.array '-f', '--facilities', 'additional comma-seperated facilities', default: []
12
+ o.bool '-h', '--help', 'print this message'
13
+ o.integer '-M', '--maxwords', 'maximum number of words per message (default: 20)', default: 20
14
+ o.integer '-m', '--minwords', 'minimum number of words per message (default: 3)', default: 3
15
+ o.array '-p', '--priorities', 'additional comma-seperated priorities', default: []
16
+ o.integer '-r', '--rate', 'messages per second per thread (default: 0, unlimited)', default: 0
17
+ o.integer '-T', '--threads', 'number of threads (defaults to number of cores * 2)', default: Etc.nprocessors * 2
18
+ o.integer '-t', '--timeout', 'length of execution. 0 for forever (default: 0)', default: 0
19
+ end
20
+
21
+ if options.help?
22
+ puts options
23
+ exit
24
+ end
25
+
26
+ trap('INT') {
27
+ raise Interrupt
28
+ }
29
+
30
+ # Get our word corpus and define the priorities and facilities we can use
31
+ facilities = [ Syslog::LOG_ALERT, Syslog::LOG_CRIT, Syslog::LOG_ERR, Syslog::LOG_WARNING, Syslog::LOG_NOTICE, Syslog::LOG_INFO ]
32
+ options[:facilities].each { |f| facilities << Object.const_get('Syslog').const_get("LOG_#{f.upcase}") }
33
+
34
+ priorities = [ Syslog::LOG_AUTHPRIV, Syslog::LOG_CRON, Syslog::LOG_DAEMON, Syslog::LOG_FTP, Syslog::LOG_LPR, Syslog::LOG_MAIL, Syslog::LOG_NEWS, Syslog::LOG_SYSLOG, Syslog::LOG_USER, Syslog::LOG_UUCP]
35
+ 0..7.times { |n| priorities << Object.const_get('Syslog').const_get("LOG_LOCAL#{n}")}
36
+ options[:priorities].each { |p| priorities << Object.const_get('Syslog').const_get("LOG_#{p.upcase}") }
37
+
38
+ words = []
39
+ raise "Unable to find dictionary file at #{options[:dictionaryfile]}" unless File.exist?(options[:dictionaryfile])
40
+ File.open(options[:dictionaryfile]).each_line { |l| words << l.chomp }
41
+
42
+ case options[:rate]
43
+ when 0
44
+ pause = 0.0
45
+ else
46
+ pause = 1.0 / options[:rate]
47
+ end
48
+
49
+ puts "Runtime: #{RUBY_VERSION} #{RUBY_PLATFORM}"
50
+ puts "Loaded #{words.size} words"
51
+ puts "Timeout: #{options[:timeout]}"
52
+ puts "Threads: #{options[:threads]}"
53
+ puts "Rate per thread: #{options[:rate]}/s"
54
+ puts "Total rate: #{options[:rate] * options[:threads]}/s"
55
+ puts "Minimum words per message: #{options[:minwords]}"
56
+ puts "Maximum words per message: #{options[:maxwords]}"
57
+ puts "Running ..."
58
+
59
+ # Run until we're done
60
+ global_count = 0
61
+ threads = []
62
+ mutex = Mutex.new
63
+ start_time = Time.now
64
+
65
+ begin
66
+ options[:threads].times do
67
+ threads << Thread.new {
68
+ while true do
69
+ # Connect to syslog with some sane options and log a message
70
+ message = String.new
71
+ number_of_words = rand(options[:minwords]..options[:maxwords])
72
+ words.sample(number_of_words).each { |w| message << "#{w} " }
73
+ ident = "lumbersexual-#{words.sample}"
74
+ facility = facilities.sample
75
+ priority = priorities.sample
76
+
77
+ sleep pause
78
+ mutex.synchronize {
79
+ syslog = Syslog.open(ident, Syslog::LOG_CONS | Syslog::LOG_NDELAY | Syslog::LOG_PID, priority)
80
+ syslog.log(facility, message)
81
+ global_count += 1
82
+ syslog.close
83
+ }
84
+
85
+ end
86
+ }
87
+ end
88
+
89
+ Timeout::timeout(options[:timeout]) {
90
+ threads.each {|t| t.join}
91
+ }
92
+
93
+ rescue Timeout::Error, Interrupt
94
+ end_time = Time.now
95
+ elapsed = end_time - start_time
96
+ puts "Sent: #{global_count}"
97
+ puts "Elapsed time: #{elapsed}"
98
+ puts "Messages per second: #{global_count / elapsed}"
99
+ puts "Complete"
100
+ exit 0
101
+ end
@@ -0,0 +1,3 @@
1
+ module Lumbersexual
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "lumbersexual/version"
2
+
3
+ module Lumbersexual
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'lumbersexual/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lumbersexual"
8
+ spec.version = Lumbersexual::VERSION
9
+ spec.authors = ["Sam Pointer"]
10
+ spec.email = ["sam.pointer@outsidethe.net"]
11
+
12
+ spec.summary = %q{Generate randomized syslog messages}
13
+ spec.description = %q{This gem generates random-enough syslog entries for the purposes of testing syslog throughput, aggregated logging infrastructures and log index performance.}
14
+ spec.homepage = "https://github.com/sampointer/lumbersexual"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.10"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec"
33
+
34
+
35
+ spec.add_dependency "slop", "~> 4.3.0"
36
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lumbersexual
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sam Pointer
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-04-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
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: slop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 4.3.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 4.3.0
69
+ description: This gem generates random-enough syslog entries for the purposes of testing
70
+ syslog throughput, aggregated logging infrastructures and log index performance.
71
+ email:
72
+ - sam.pointer@outsidethe.net
73
+ executables:
74
+ - lumbersexual
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - .gitignore
79
+ - .rspec
80
+ - .ruby-version
81
+ - .travis.yml
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/setup
88
+ - etc/assets/lumber-156795_960_720.png
89
+ - exe/lumbersexual
90
+ - lib/lumbersexual.rb
91
+ - lib/lumbersexual/version.rb
92
+ - lumbersexual.gemspec
93
+ homepage: https://github.com/sampointer/lumbersexual
94
+ licenses:
95
+ - MIT
96
+ metadata:
97
+ allowed_push_host: ! 'TODO: Set to ''http://mygemserver.com'''
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.4.5
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Generate randomized syslog messages
118
+ test_files: []