syslog_generator 1.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 +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +13 -0
- data/README.md +24 -0
- data/Rakefile +2 -0
- data/bin/loggen +26 -0
- data/lib/syslog_generator.rb +38 -0
- data/lib/syslog_generator/version.rb +3 -0
- data/syslog_generator.gemspec +22 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 473f871cd315ade010145a4766290f9b92c75f26
|
4
|
+
data.tar.gz: 4e2f00de70ebb1e3161546e5939a982656a9d5b8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 39fa0afd097d4afe11b592a7b545a8bd2967439f05f5b173692b25bb274aeafcdbb40f903c1884e9ef2bf891d62e421d0292bd38017d2036fa2a8b30c68ae868
|
7
|
+
data.tar.gz: cbdacf22c60c26ec85812bc392d00045385a157f2b489028d26b46fb321a031df1b396f9c4e435ad2e5e1d122406acb9585dcb80e5bf520988b04f4a786dac78
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2015 Michael Parks
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# SyslogGenerator
|
2
|
+
|
3
|
+
A small tool which generates bogus syslog-formatted data for testing your logger configuration.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install it by running:
|
8
|
+
|
9
|
+
$ gem install syslog_generator
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
After installing, simply run loggen. By default, it will send 100 lines of
|
14
|
+
nonsense to your local machine on port 514/UDP.
|
15
|
+
|
16
|
+
Append --help for full usage information.
|
17
|
+
|
18
|
+
## Contributing
|
19
|
+
|
20
|
+
1. Fork it ( https://github.com/Karunamon/syslog_generator/fork )
|
21
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
22
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
23
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
24
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/loggen
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'syslog_generator'
|
3
|
+
require 'trollop'
|
4
|
+
|
5
|
+
opts = Trollop.options do
|
6
|
+
version 'log_generator v1.0.0 - Michael Parks <mparks@tkware.info>'
|
7
|
+
banner <<-EOS
|
8
|
+
Generate random syslog lines according to the provided options.
|
9
|
+
Absent any options, 100 lines of nonsense will be sent to the syslog port on localhost.
|
10
|
+
|
11
|
+
Usage: loggen [options]
|
12
|
+
|
13
|
+
Where [options] can be any of the following:
|
14
|
+
EOS
|
15
|
+
opt :count, 'Count of lines to generate. Set to -1 for infinite.', type: Integer, default: 100
|
16
|
+
opt :words, 'Words per line', type: Integer, default: 5
|
17
|
+
opt :progname, 'Program name attached to each log line', type: String, default: 'log_generator'
|
18
|
+
opt :test, 'Send lines to stdout rather than a remote server'
|
19
|
+
opt :server, 'Send lines to this remote server', type: String, default: 'localhost'
|
20
|
+
opt :facility, 'Syslog facility to use', type: String, default: 'local6'
|
21
|
+
opt :protocol, 'TCP or UDP', type: String, default: 'udp'
|
22
|
+
opt :port, 'Port number to send generated lines to', type: Integer, default: 514
|
23
|
+
end
|
24
|
+
|
25
|
+
logger = SyslogGenerator::Logger.new(opts)
|
26
|
+
logger.start
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "syslog_generator/version"
|
2
|
+
require 'random-word'
|
3
|
+
require 'syslog_protocol'
|
4
|
+
require 'socket'
|
5
|
+
|
6
|
+
# Initialize a new logger endpoint, setting up the appropriate socket from options.
|
7
|
+
module SyslogGenerator
|
8
|
+
class Logger
|
9
|
+
attr_accessor :options
|
10
|
+
|
11
|
+
def initialize(options)
|
12
|
+
self.options = options
|
13
|
+
@formatter = SyslogProtocol::Logger.new(`hostname`.strip, options[:progname], options[:facility])
|
14
|
+
@socket = case options[:protocol].downcase
|
15
|
+
when 'udp'
|
16
|
+
UDPSocket.new
|
17
|
+
when 'tcp'
|
18
|
+
TCPSocket.new
|
19
|
+
else fail 'Invalid protocol specified.'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def send(text)
|
24
|
+
text.is_a?(Array) ? @payload = @formatter.info(text.join(' ')) : @payload = @formatter.info(text)
|
25
|
+
self.options[:test] ? puts(@payload) : @socket.send(@payload, 0, self.options[:server], self.options[:port])
|
26
|
+
end
|
27
|
+
|
28
|
+
def start
|
29
|
+
if self.options[:count] != -1
|
30
|
+
self.options[:count].times { self.send RandomWord.nouns.take(self.options[:words]) }
|
31
|
+
else
|
32
|
+
loop { self.send RandomWord.nouns.take(self.options[:words]) }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'syslog_generator/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "syslog_generator"
|
8
|
+
spec.version = SyslogGenerator::VERSION
|
9
|
+
spec.authors = ["Michael Parks"]
|
10
|
+
spec.email = ["mparks@tkware.info"]
|
11
|
+
spec.summary = %q{Generates random syslog data for configuration testing}
|
12
|
+
spec.description = %q{Uses random_word to send configurable, nonsense syslog data at a server of your choice. Great for testing your logger configuration.}
|
13
|
+
spec.license = "Apache License v2.0"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: syslog_generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Parks
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-17 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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
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
|
+
description: Uses random_word to send configurable, nonsense syslog data at a server
|
42
|
+
of your choice. Great for testing your logger configuration.
|
43
|
+
email:
|
44
|
+
- mparks@tkware.info
|
45
|
+
executables:
|
46
|
+
- loggen
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".gitignore"
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- bin/loggen
|
56
|
+
- lib/syslog_generator.rb
|
57
|
+
- lib/syslog_generator/version.rb
|
58
|
+
- syslog_generator.gemspec
|
59
|
+
homepage:
|
60
|
+
licenses:
|
61
|
+
- Apache License v2.0
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.2.2
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Generates random syslog data for configuration testing
|
83
|
+
test_files: []
|