haproxy2rpm 0.1.0 → 0.1.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/CHANGELOG.md +4 -0
- data/lib/haproxy2rpm/syslog.rb +3 -2
- data/lib/haproxy2rpm/version.rb +1 -1
- data/test/syslog_test.rb +14 -2
- data/test/test_helper.rb +2 -1
- metadata +4 -4
data/CHANGELOG.md
CHANGED
data/lib/haproxy2rpm/syslog.rb
CHANGED
@@ -14,7 +14,7 @@ module Haproxy2Rpm
|
|
14
14
|
second = "(?:[0-5][0-9])"
|
15
15
|
time = [hour, minute, second].join(":")
|
16
16
|
timestamp = "(?<timestamp>#{month} #{day} #{time})"
|
17
|
-
hostname = "(?<hostname>[A-Za-z0-9_
|
17
|
+
hostname = "(?<hostname>[A-Za-z0-9_.:\-]+)"
|
18
18
|
header = timestamp + " " + hostname
|
19
19
|
tag = '(?<tag>[a-zA-Z_\-\/\.0-9\[\]]+)'
|
20
20
|
message = "(?<message>[ -~]+)" # ascii 32 to 126
|
@@ -31,9 +31,10 @@ module Haproxy2Rpm
|
|
31
31
|
|
32
32
|
def receive_data(data)
|
33
33
|
match = parse_data(data)
|
34
|
-
puts match.inspect
|
35
34
|
message = match ? match[5] : ""
|
36
35
|
Haproxy2Rpm.logger.debug "RECEIVED (syslog): #{data}"
|
36
|
+
Haproxy2Rpm.logger.debug "PARSED DATA (syslog): #{match.inspect}"
|
37
|
+
Haproxy2Rpm.logger.debug "PARSED PAYLOAD (syslog): #{message}"
|
37
38
|
Haproxy2Rpm.rpm.process_and_send(message)
|
38
39
|
end
|
39
40
|
|
data/lib/haproxy2rpm/version.rb
CHANGED
data/test/syslog_test.rb
CHANGED
@@ -2,7 +2,7 @@ $LOAD_PATH.unshift( File.dirname(__FILE__) )
|
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
|
-
FIXTURE_SYSLOG_MESSAGE = "<12>Jan 3 16:18:58 rechenschieber.local nodejs[36180]:
|
5
|
+
FIXTURE_SYSLOG_MESSAGE = "<12>Jan 3 16:18:58 rechenschieber.local nodejs[36180]: OPTIONS / 200 1"
|
6
6
|
|
7
7
|
class RpmTest < Test::Unit::TestCase
|
8
8
|
context 'regex maching' do
|
@@ -27,7 +27,19 @@ class RpmTest < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
|
29
29
|
should 'match the message' do
|
30
|
-
assert_equal '
|
30
|
+
assert_equal 'OPTIONS / 200 1', @match[5]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'valid hostnames' do
|
35
|
+
setup do
|
36
|
+
@parser = Haproxy2Rpm::SyslogHandler.new(self)
|
37
|
+
end
|
38
|
+
|
39
|
+
should 'support hostnames with hyphens' do
|
40
|
+
expected_hostname = 's-app-2'
|
41
|
+
actual_hostname = @parser.parse_data(syslog_entry(:hostname => expected_hostname))[3]
|
42
|
+
assert_equal expected_hostname, actual_hostname
|
31
43
|
end
|
32
44
|
end
|
33
45
|
end
|
data/test/test_helper.rb
CHANGED
@@ -19,6 +19,7 @@ Haproxy2Rpm.logger = DummyLogger.new
|
|
19
19
|
|
20
20
|
def syslog_entry(options = {})
|
21
21
|
defaults = {
|
22
|
+
:hostname => 'localhost',
|
22
23
|
:tq => 6559,
|
23
24
|
:tw => 100,
|
24
25
|
:tc => 7,
|
@@ -31,7 +32,7 @@ def syslog_entry(options = {})
|
|
31
32
|
}
|
32
33
|
defaults.merge!(options)
|
33
34
|
log_line = <<LOG_LINE
|
34
|
-
Aug 1 15:28:03
|
35
|
+
<113>Aug 1 15:28:03 #{defaults[:hostname]} haproxy[674]: 127.0.0.1:33319 [15/Oct/2003:08:31:57] relais-http Srv1 #{defaults[:tq]}/#{defaults[:tw]}/#{defaults[:tc]}/#{defaults[:tr]}/#{defaults[:tt]} #{defaults[:status_code]} 243 - - ---- 1/3/5 0/0 "#{defaults[:http_method]} #{defaults[:http_path]}#{defaults[:http_query] ? "?#{defaults[:http_query]}" : ''} HTTP/1.0"
|
35
36
|
LOG_LINE
|
36
37
|
end
|
37
38
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haproxy2rpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Patrick Huesler
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-01-
|
19
|
+
date: 2012-01-04 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|