haproxy2rpm 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/haproxy2rpm.rb +1 -1
- data/lib/haproxy2rpm/rpm.rb +11 -7
- data/lib/haproxy2rpm/syslog.rb +3 -29
- data/lib/haproxy2rpm/version.rb +1 -1
- metadata +82 -53
data/Rakefile
CHANGED
@@ -19,6 +19,6 @@ namespace :test do
|
|
19
19
|
uri = ENV['uri'] || '/'
|
20
20
|
puts 'make sure the udp server is running'
|
21
21
|
|
22
|
-
`yes '<13>May 19 18:30:17
|
22
|
+
`yes '<13>May 19 18:30:17 haproxy[674]: 127.0.0.1:33319 [15/Oct/2003:08:31:57] relais-http Srv1 6559/100/7/147/6723 #{status_code} 243 - - ---- 1/3/5 0/0 "PUT #{uri} HTTP/1.0"' | nc -u -i 1 localhost #{port}`
|
23
23
|
end
|
24
24
|
end
|
data/lib/haproxy2rpm.rb
CHANGED
data/lib/haproxy2rpm/rpm.rb
CHANGED
@@ -9,14 +9,18 @@ module Haproxy2Rpm
|
|
9
9
|
@qt_stat = @stats_engine.get_stats_no_scope('WebFrontend/QueueTime')
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def process_and_send(line)
|
13
13
|
request = LineParser.new(line)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
params = {
|
15
|
+
'metric' => "Controller#{request.http_path}"
|
16
|
+
}
|
17
|
+
|
18
|
+
if request.is_error?
|
19
|
+
params['is_error'] = true
|
20
|
+
params['error_message'] = "#{request.uri} : Status code #{request.status_code}"
|
21
|
+
end
|
22
|
+
|
23
|
+
NewRelic::Agent.record_transaction(request.tr / 1000.0, params)
|
20
24
|
@qt_stat.record_data_point(request.tw / 1000.0)
|
21
25
|
end
|
22
26
|
end
|
data/lib/haproxy2rpm/syslog.rb
CHANGED
@@ -4,37 +4,11 @@ module Haproxy2Rpm
|
|
4
4
|
class SyslogHandler < EventMachine::Connection
|
5
5
|
def initialize
|
6
6
|
@rpm = Rpm.new
|
7
|
-
|
8
|
-
@buffer = BufferedTokenizer.new
|
9
|
-
@start = Time.now
|
10
|
-
|
11
|
-
# The syslog parsing stuff here taken from the 'logporter' gem.
|
12
|
-
pri = "(?:<(?<pri>[0-9]{1,3})>)?"
|
13
|
-
month = "(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"
|
14
|
-
day = "(?: [1-9]|[12][0-9]|3[01])"
|
15
|
-
hour = "(?:[01][0-9]|2[0-4])"
|
16
|
-
minute = "(?:[0-5][0-9])"
|
17
|
-
second = "(?:[0-5][0-9])"
|
18
|
-
time = [hour, minute, second].join(":")
|
19
|
-
timestamp = "(?<timestamp>#{month} #{day} #{time})"
|
20
|
-
hostname = "(?<hostname>[A-Za-z0-9_.:]+)"
|
21
|
-
header = timestamp + " " + hostname
|
22
|
-
message = "(?<message>[ -~]+)" # ascii 32 to 126
|
23
|
-
re = "^#{pri}#{header} #{message}$"
|
24
|
-
|
25
|
-
if RUBY_VERSION =~ /^1\.8/
|
26
|
-
# Ruby 1.8 doesn't support named captures
|
27
|
-
# replace (?<foo> with (
|
28
|
-
re = re.gsub(/\(\?<[^>]+>/, "(")
|
29
|
-
end
|
30
|
-
|
31
|
-
@syslog3164_re = Regexp.new(re)
|
32
|
-
end
|
7
|
+
end
|
33
8
|
|
34
9
|
def receive_data(data)
|
35
|
-
|
36
|
-
|
37
|
-
@rpm.send(m[:message])
|
10
|
+
message_start_index = data.index('haproxy')
|
11
|
+
@rpm.process_and_send(data[message_start_index..-1])
|
38
12
|
end
|
39
13
|
end
|
40
14
|
end
|
data/lib/haproxy2rpm/version.rb
CHANGED
metadata
CHANGED
@@ -1,71 +1,91 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: haproxy2rpm
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Patrick Huesler
|
9
14
|
- Martin Rehfeld
|
10
15
|
autorequire:
|
11
16
|
bindir: bin
|
12
17
|
cert_chain: []
|
13
|
-
|
18
|
+
|
19
|
+
date: 2011-07-11 00:00:00 +02:00
|
14
20
|
default_executable:
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
17
23
|
name: newrelic_rpm
|
18
|
-
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
26
|
none: false
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
version: "0"
|
24
34
|
type: :runtime
|
25
|
-
|
26
|
-
|
27
|
-
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
28
37
|
name: eventmachine-tail
|
29
|
-
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
40
|
none: false
|
31
|
-
requirements:
|
32
|
-
- -
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
35
48
|
type: :runtime
|
36
|
-
|
37
|
-
|
38
|
-
- !ruby/object:Gem::Dependency
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
39
51
|
name: rake
|
40
|
-
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
54
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
46
62
|
type: :development
|
47
|
-
|
48
|
-
|
49
|
-
- !ruby/object:Gem::Dependency
|
63
|
+
version_requirements: *id003
|
64
|
+
- !ruby/object:Gem::Dependency
|
50
65
|
name: shoulda-context
|
51
|
-
|
66
|
+
prerelease: false
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
68
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
57
76
|
type: :development
|
58
|
-
|
59
|
-
version_requirements: *2157712440
|
77
|
+
version_requirements: *id004
|
60
78
|
description: Sending haproxy logs to new relic rpm
|
61
|
-
email:
|
79
|
+
email:
|
62
80
|
- patrick.huesler@wooga.com
|
63
81
|
- martin.rehfeld@wooga.com
|
64
|
-
executables:
|
82
|
+
executables:
|
65
83
|
- haproxy2rpm
|
66
84
|
extensions: []
|
85
|
+
|
67
86
|
extra_rdoc_files: []
|
68
|
-
|
87
|
+
|
88
|
+
files:
|
69
89
|
- .gitignore
|
70
90
|
- Gemfile
|
71
91
|
- README.md
|
@@ -84,28 +104,37 @@ files:
|
|
84
104
|
has_rdoc: true
|
85
105
|
homepage: https://github.com/wooga/haproxy2rpm
|
86
106
|
licenses: []
|
107
|
+
|
87
108
|
post_install_message:
|
88
109
|
rdoc_options: []
|
89
|
-
|
110
|
+
|
111
|
+
require_paths:
|
90
112
|
- lib
|
91
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
114
|
none: false
|
93
|
-
requirements:
|
94
|
-
- -
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
|
97
|
-
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
hash: 3
|
119
|
+
segments:
|
120
|
+
- 0
|
121
|
+
version: "0"
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
123
|
none: false
|
99
|
-
requirements:
|
100
|
-
- -
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
hash: 3
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
version: "0"
|
103
131
|
requirements: []
|
132
|
+
|
104
133
|
rubyforge_project:
|
105
134
|
rubygems_version: 1.6.2
|
106
135
|
signing_key:
|
107
136
|
specification_version: 3
|
108
137
|
summary: Sending haproxy logs to new relic rpm
|
109
|
-
test_files:
|
138
|
+
test_files:
|
110
139
|
- test/haproxy2pm_test.rb
|
111
140
|
- test/test_helper.rb
|