tracelogger 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.
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ doc
6
+ rdoc
7
+ .yardoc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in dumb_tracer.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Tracelogger
2
+
3
+ A silly simple little dumb traceroute logger.
4
+
5
+ ## Usage
6
+
7
+ tracelogger name.com
8
+
9
+ ## What does it do?
10
+
11
+ 1. Finds `traceroute` on your system
12
+ 2. Runs `traceroute name.com 2>&1`
13
+ 3. Passes the above's output to localhost syslog's `LOG_DAEMON` facility.
14
+
15
+ That's all.
16
+
17
+ ## License
18
+
19
+ The MIT License
20
+
21
+ Copyright (c) 2011 Pavel Argentov, <http://argentoff.net>
22
+
23
+ Permission is hereby granted, free of charge, to any person obtaining a copy
24
+ of this software and associated documentation files (the "Software"), to deal
25
+ in the Software without restriction, including without limitation the rights
26
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27
+ copies of the Software, and to permit persons to whom the Software is
28
+ furnished to do so, subject to the following conditions:
29
+
30
+ The above copyright notice and this permission notice shall be included in
31
+ all copies or substantial portions of the Software.
32
+
33
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
39
+ THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,39 @@
1
+ = Tracelogger
2
+
3
+ A silly simple little dumb traceroute logger.
4
+
5
+ == Usage
6
+
7
+ tracelogger name.com
8
+
9
+ == What does it do?
10
+
11
+ 1. Finds `traceroute` on your system
12
+ 2. Runs `traceroute name.com 2>&1`
13
+ 3. Passes the above's output to localhost syslog's `LOG_DAEMON` facility.
14
+
15
+ That's all.
16
+
17
+ == License
18
+
19
+ The MIT License
20
+
21
+ Copyright (c) 2011 Pavel Argentov, <http://argentoff.net>
22
+
23
+ Permission is hereby granted, free of charge, to any person obtaining a copy
24
+ of this software and associated documentation files (the "Software"), to deal
25
+ in the Software without restriction, including without limitation the rights
26
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27
+ copies of the Software, and to permit persons to whom the Software is
28
+ furnished to do so, subject to the following conditions:
29
+
30
+ The above copyright notice and this permission notice shall be included in
31
+ all copies or substantial portions of the Software.
32
+
33
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
39
+ THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require "bundler/setup"
2
+ require "bundler/gem_tasks"
3
+
4
+ require "yard"
5
+
6
+ require 'rdoc/task'
7
+ Rake::RDocTask.new do |rdoc|
8
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
9
+
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = "Tracelogger #{version}"
12
+ rdoc.rdoc_files.include('README*')
13
+ rdoc.rdoc_files.include('lib/**/*.rb')
14
+ end
15
+
16
+ YARD::Rake::YardocTask.new
17
+
18
+ desc "Clean up the development-only stuff"
19
+ task :clean do
20
+ system "git clean -fd"
21
+ end
data/bin/tracelogger ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # for development purposes
4
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
5
+
6
+ require "rubygems"
7
+ require "tracelogger"
8
+
9
+ # The main application running script.
10
+
11
+ Tracelogger::App.new.run
@@ -0,0 +1,3 @@
1
+ module Tracelogger
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,104 @@
1
+ require "tracelogger/version"
2
+ require "optparse"
3
+ require 'log4r'
4
+ require 'log4r/outputter/syslogoutputter'
5
+
6
+ # Author:: Pavel Argentov (mailto:argentoff@gmail.com)
7
+ # License:: MIT (See README)
8
+ #
9
+ # This module contains all the classes needed by Tracelogger.
10
+ module Tracelogger
11
+
12
+ # Tracelogger's Configuration: used when running the app.
13
+ class Configuration
14
+ attr_accessor :options, :host
15
+ end
16
+
17
+ # This class wraps Log4r's Syslog logic.
18
+ # == Usage
19
+ # mylog = Log.new
20
+ # mylog.info "Some Message"
21
+ class Log
22
+
23
+ # @private
24
+ def initialize # :nodoc:
25
+ @log = Log4r::Logger.new "main"
26
+ @log.outputters = Log4r::SyslogOutputter.new("tracelogger", :facility => "LOG_DAEMON")
27
+ end
28
+
29
+ # @private
30
+ def method_missing(meth, *args, &block) # :nodoc:
31
+ @log.send meth, *args, &block
32
+ end
33
+ end
34
+
35
+ # Wraps `traceroute` run.
36
+ class Traceroute
37
+
38
+ # Finds the system's traceroute executable.
39
+ def initialize
40
+ @command = `which traceroute`.chomp
41
+ end
42
+
43
+ # Runs the found traceroute with the specified address and returns the
44
+ # result.
45
+ def trace host
46
+ `env #{@command} #{host} 2>&1`
47
+ end
48
+ end
49
+
50
+ # Application run scenario.
51
+ class App
52
+
53
+ # Initializes the app's settings and parses the CLI options.
54
+ def initialize
55
+ @config = Configuration.new
56
+ options = {}
57
+ OptionParser.new do |opts|
58
+ opts.banner = "Usage: dumb_tracer [options] host\n" +
59
+ " Traces the route to destination host and sends\n" +
60
+ " the traceroute result to SYSLOG's 'daemon' facility"
61
+
62
+ opts.separator ""
63
+ opts.separator "Optional parameters:"
64
+
65
+ opts.on_tail "-h", "--help", "Show this message" do
66
+ puts opts.help
67
+ end
68
+
69
+ end.parse!
70
+
71
+ @config.options = options
72
+ @config.host = ARGV.first
73
+
74
+ @log = Log.new
75
+ end
76
+
77
+ # Logs the message.
78
+ def log message # :nodoc:
79
+ @log.info message
80
+ end
81
+
82
+ # Executed right after the start.
83
+ def start # :nodoc:
84
+ log "Starting"
85
+ end
86
+
87
+ # Executed right before the end.
88
+ def wrapup # :nodoc:
89
+ log "Finishing"
90
+ end
91
+
92
+ # Logs the underlying traceroute's result.
93
+ def trace # :nodoc:
94
+ log Traceroute.new.trace @config.host
95
+ end
96
+
97
+ # Runs the app scenario.
98
+ def run
99
+ start
100
+ trace
101
+ wrapup
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "tracelogger/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "tracelogger"
7
+ s.version = Tracelogger::VERSION
8
+ s.authors = ["Pavel Argentov"]
9
+ s.email = ["argentoff@gmail.com"]
10
+ s.homepage = "https://github.com/argent-smith/tracelogger"
11
+ s.summary = %q{Simple traceroute logger}
12
+ s.description = %q{"tracelogger host" sends the results of `traceroute #{host}` to syslog.}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+ s.extra_rdoc_files = ['README.rdoc']
19
+
20
+ # specify any dependencies here; for example:
21
+ s.add_development_dependency "yard"
22
+ s.add_development_dependency "rdoc"
23
+ s.add_development_dependency "redcarpet"
24
+ s.add_development_dependency "rake"
25
+ s.add_runtime_dependency "log4r"
26
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tracelogger
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Pavel Argentov
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-12-22 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ type: :development
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ prerelease: false
32
+ name: yard
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ type: :development
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 0
44
+ version: "0"
45
+ prerelease: false
46
+ name: rdoc
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ type: :development
50
+ requirement: &id003 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ prerelease: false
60
+ name: redcarpet
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ type: :development
64
+ requirement: &id004 !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ prerelease: false
74
+ name: rake
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ type: :runtime
78
+ requirement: &id005 !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ prerelease: false
88
+ name: log4r
89
+ version_requirements: *id005
90
+ description: "\"tracelogger host\" sends the results of `traceroute #{host}` to syslog."
91
+ email:
92
+ - argentoff@gmail.com
93
+ executables:
94
+ - tracelogger
95
+ extensions: []
96
+
97
+ extra_rdoc_files:
98
+ - README.rdoc
99
+ files:
100
+ - .gitignore
101
+ - Gemfile
102
+ - README.md
103
+ - README.rdoc
104
+ - Rakefile
105
+ - bin/tracelogger
106
+ - lib/tracelogger.rb
107
+ - lib/tracelogger/version.rb
108
+ - tracelogger.gemspec
109
+ homepage: https://github.com/argent-smith/tracelogger
110
+ licenses: []
111
+
112
+ post_install_message:
113
+ rdoc_options: []
114
+
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ hash: 3
123
+ segments:
124
+ - 0
125
+ version: "0"
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ hash: 3
132
+ segments:
133
+ - 0
134
+ version: "0"
135
+ requirements: []
136
+
137
+ rubyforge_project:
138
+ rubygems_version: 1.8.12
139
+ signing_key:
140
+ specification_version: 3
141
+ summary: Simple traceroute logger
142
+ test_files: []
143
+
144
+ has_rdoc: