nginx-watcher 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 +4 -0
- data/Gemfile +4 -0
- data/README +0 -0
- data/Rakefile +2 -0
- data/bin/nginx-watcher +41 -0
- data/lib/nginx-watcher.rb +12 -0
- data/lib/nginx-watcher/version.rb +5 -0
- data/nginx-watcher.gemspec +26 -0
- metadata +138 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README
ADDED
File without changes
|
data/Rakefile
ADDED
data/bin/nginx-watcher
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "nginx-watcher"
|
4
|
+
require "nginx-watcher/version"
|
5
|
+
require "commander/import"
|
6
|
+
require 'daemons'
|
7
|
+
|
8
|
+
|
9
|
+
program :name, "Nginx Watcher"
|
10
|
+
program :version, Nginx::Watcher::VERSION
|
11
|
+
program :description, 'Watches nginx and reports what it is doing'
|
12
|
+
default_command :watch
|
13
|
+
|
14
|
+
command :watch do |c|
|
15
|
+
c.syntax = 'nginx-watcher watch /path/to/log1 /path/to/log2 ... [options]'
|
16
|
+
c.description = 'Watches nginx and reports what it is doing'
|
17
|
+
c.option '--host HOST', String, 'host to report to'
|
18
|
+
c.option '--path PATH', String, 'path to report to'
|
19
|
+
c.option '--port PORT', Integer, 'port to report to'
|
20
|
+
c.action do |args, options|
|
21
|
+
options.default :host => "127.0.0.1", :port => 80, :path => ""
|
22
|
+
|
23
|
+
EventMachine.run do
|
24
|
+
args.each do |path|
|
25
|
+
EventMachine::file_tail(path) do |filetail, line|
|
26
|
+
info = {}
|
27
|
+
if ip = Nginx::Watcher::IP.match(line)
|
28
|
+
info[:ip] = ip[1]
|
29
|
+
end
|
30
|
+
if localtime = Nginx::Watcher::LOCALTIME.match(line)
|
31
|
+
info[:localtime] = localtime[1]
|
32
|
+
end
|
33
|
+
http = EventMachine::HttpRequest.new("http://#{options.host}:#{options.port}/#{options.path}").post(
|
34
|
+
:body => info,
|
35
|
+
:timeout => 2
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "eventmachine"
|
2
|
+
require "eventmachine-tail"
|
3
|
+
require 'em-http'
|
4
|
+
|
5
|
+
module Nginx
|
6
|
+
module Watcher
|
7
|
+
IP = /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s/
|
8
|
+
LOCALTIME = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s-\s.*\s\[(.*)\]/
|
9
|
+
|
10
|
+
# Your code goes here...
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "nginx-watcher/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "nginx-watcher"
|
7
|
+
s.version = Nginx::Watcher::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Sean Cashin"]
|
10
|
+
s.email = ["scashin133@gmail.com"]
|
11
|
+
s.homepage = "http://github.com/scashin133/nginx-watcher"
|
12
|
+
s.summary = %q{Watches an nginx log and posts what it finds to a server}
|
13
|
+
s.description = %q{Watches an nginx log and posts what it finds to a server}
|
14
|
+
|
15
|
+
s.add_dependency(%q<eventmachine>, ["~> 0.12.10"])
|
16
|
+
s.add_dependency(%q<em-http-request>, ["~> 0.3.0"])
|
17
|
+
s.add_dependency(%q<eventmachine-tail>, ["~> 0.5.20110118081348"])
|
18
|
+
s.add_dependency(%q<commander>, ["~> 4.0.3"])
|
19
|
+
|
20
|
+
s.rubyforge_project = "nginx-watcher"
|
21
|
+
|
22
|
+
s.files = `git ls-files`.split("\n")
|
23
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
25
|
+
s.require_paths = ["lib"]
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nginx-watcher
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Sean Cashin
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-02-01 00:00:00 -08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: eventmachine
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 59
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 12
|
33
|
+
- 10
|
34
|
+
version: 0.12.10
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: em-http-request
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 19
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 3
|
49
|
+
- 0
|
50
|
+
version: 0.3.0
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: eventmachine-tail
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 40220236162691
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
- 5
|
65
|
+
- 20110118081348
|
66
|
+
version: 0.5.20110118081348
|
67
|
+
type: :runtime
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: commander
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 57
|
78
|
+
segments:
|
79
|
+
- 4
|
80
|
+
- 0
|
81
|
+
- 3
|
82
|
+
version: 4.0.3
|
83
|
+
type: :runtime
|
84
|
+
version_requirements: *id004
|
85
|
+
description: Watches an nginx log and posts what it finds to a server
|
86
|
+
email:
|
87
|
+
- scashin133@gmail.com
|
88
|
+
executables:
|
89
|
+
- nginx-watcher
|
90
|
+
extensions: []
|
91
|
+
|
92
|
+
extra_rdoc_files: []
|
93
|
+
|
94
|
+
files:
|
95
|
+
- .gitignore
|
96
|
+
- Gemfile
|
97
|
+
- README
|
98
|
+
- Rakefile
|
99
|
+
- bin/nginx-watcher
|
100
|
+
- lib/nginx-watcher.rb
|
101
|
+
- lib/nginx-watcher/version.rb
|
102
|
+
- nginx-watcher.gemspec
|
103
|
+
has_rdoc: true
|
104
|
+
homepage: http://github.com/scashin133/nginx-watcher
|
105
|
+
licenses: []
|
106
|
+
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
hash: 3
|
118
|
+
segments:
|
119
|
+
- 0
|
120
|
+
version: "0"
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
hash: 3
|
127
|
+
segments:
|
128
|
+
- 0
|
129
|
+
version: "0"
|
130
|
+
requirements: []
|
131
|
+
|
132
|
+
rubyforge_project: nginx-watcher
|
133
|
+
rubygems_version: 1.3.7
|
134
|
+
signing_key:
|
135
|
+
specification_version: 3
|
136
|
+
summary: Watches an nginx log and posts what it finds to a server
|
137
|
+
test_files: []
|
138
|
+
|