logstash-output-syslog 0.2.0 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: adf244fc4a07c51b9b7f855fd561c04904f07776
4
- data.tar.gz: 02c9b31239c8090938d623b19a091d0a67d7e446
3
+ metadata.gz: 7cd1c6f93332773cecd2bde660aeb2abccb1a06e
4
+ data.tar.gz: d289eee9433c4f862508899141950508fbcc6ce8
5
5
  SHA512:
6
- metadata.gz: 642bae90d7875e24535ec18c8162883f86b78a0eb6feed53124e20e182c3dd3dcf2b55cb0a327c5dfeb97dde765a2e996ad39044ed60d825b50f8866031ac9ec
7
- data.tar.gz: cdf6c9fdc485edde59acfc49c21eacd8b5a3a85fc20b50ca9ffc14186ad87526e36e787e4967ebfdc6e8fe792f94af3b46addbe17b9b0bf9d4ec2653ad9ec95d
6
+ metadata.gz: cebbcc9f6525888316022d6d7ced9aa64437ff9a5e187f3e828687cbbfe3d19885324f9bc82a6a898f92d8cfe9d67fe9a12d8da0a6c7ce0fa8d99577cfff5d19
7
+ data.tar.gz: 984d9deeceeff73ba0b912aa935391d9abb1f2449d65b72a5f104f413707c9251eaa98cb259ed4e7623db459142f576fb403c0c3ff4a666d0a213e6f0925396a
data/CHANGELOG.md CHANGED
@@ -0,0 +1,5 @@
1
+ ## 2.0.0
2
+ - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
3
+ instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
4
+ - Dependency on logstash-core update to 2.0
5
+
@@ -57,13 +57,10 @@ class LogStash::Outputs::Syslog < LogStash::Outputs::Base
57
57
 
58
58
  # syslog server address to connect to
59
59
  config :host, :validate => :string, :required => true
60
-
60
+
61
61
  # syslog server port to connect to
62
62
  config :port, :validate => :number, :required => true
63
63
 
64
- # when connection fails, retry interval in sec.
65
- config :reconnect_interval, :validate => :number, :default => 1
66
-
67
64
  # syslog server protocol. you can choose between udp and tcp
68
65
  config :protocol, :validate => ["tcp", "udp"], :default => "udp"
69
66
 
@@ -87,67 +84,71 @@ class LogStash::Outputs::Syslog < LogStash::Outputs::Base
87
84
 
88
85
  # message text to log
89
86
  config :message, :validate => :string, :default => "%{message}"
90
-
87
+
91
88
  # message id for syslog message
92
89
  config :msgid, :validate => :string, :default => "-"
93
90
 
94
91
  # syslog message format: you can choose between rfc3164 or rfc5424
95
92
  config :rfc, :validate => ["rfc3164", "rfc5424"], :default => "rfc3164"
96
93
 
94
+
95
+ public
97
96
  def register
98
- @client_socket = nil
97
+ @client_socket = nil
98
+ end
99
99
 
100
- facility_code = FACILITY_LABELS.index(@facility)
101
- severity_code = SEVERITY_LABELS.index(@severity)
102
- @priority = (facility_code * 8) + severity_code
100
+ private
101
+ def udp?
102
+ @protocol == "udp"
103
+ end
104
+
105
+ private
106
+ def rfc3164?
107
+ @rfc == "rfc3164"
108
+ end
103
109
 
104
- # use instance variable to avoid string comparison for each event
105
- @is_rfc3164 = (@rfc == "rfc3164")
110
+ private
111
+ def connect
112
+ if udp?
113
+ @client_socket = UDPSocket.new
114
+ @client_socket.connect(@host, @port)
115
+ else
116
+ @client_socket = TCPSocket.new(@host, @port)
117
+ end
106
118
  end
107
119
 
120
+ public
108
121
  def receive(event)
109
- return unless output?(event)
122
+
110
123
 
111
124
  appname = event.sprintf(@appname)
112
125
  procid = event.sprintf(@procid)
113
126
  sourcehost = event.sprintf(@sourcehost)
114
127
 
115
- if @is_rfc3164
128
+ facility_code = FACILITY_LABELS.index(@facility)
129
+
130
+ severity_code = SEVERITY_LABELS.index(@severity)
131
+
132
+ priority = (facility_code * 8) + severity_code
133
+
134
+ if rfc3164?
116
135
  timestamp = event.sprintf("%{+MMM dd HH:mm:ss}")
117
- syslog_msg = "<#{@priority.to_s}>#{timestamp} #{sourcehost} #{appname}[#{procid}]: #{event.sprintf(@message)}"
136
+ syslog_msg = "<"+priority.to_s()+">"+timestamp+" "+sourcehost+" "+appname+"["+procid+"]: "+event.sprintf(@message)
118
137
  else
119
138
  msgid = event.sprintf(@msgid)
120
139
  timestamp = event.sprintf("%{+YYYY-MM-dd'T'HH:mm:ss.SSSZZ}")
121
- syslog_msg = "<#{@priority.to_s}>1 #{timestamp} #{sourcehost} #{appname} #{procid} #{msgid} - #{event.sprintf(@message)}"
140
+ syslog_msg = "<"+priority.to_s()+">1 "+timestamp+" "+sourcehost+" "+appname+" "+procid+" "+msgid+" - "+event.sprintf(@message)
122
141
  end
123
142
 
124
143
  begin
125
- @client_socket ||= connect
144
+ connect unless @client_socket
126
145
  @client_socket.write(syslog_msg + "\n")
127
146
  rescue => e
128
- @logger.warn("syslog " + @protocol + " output exception: closing, reconnecting and resending event", :host => @host, :port => @port, :exception => e, :backtrace => e.backtrace, :event => event)
147
+ @logger.warn(@protocol+" output exception", :host => @host, :port => @port,
148
+ :exception => e, :backtrace => e.backtrace)
129
149
  @client_socket.close rescue nil
130
150
  @client_socket = nil
131
-
132
- sleep(@reconnect_interval)
133
- retry
134
- end
135
- end
136
-
137
- private
138
-
139
- def udp?
140
- @protocol == "udp"
141
- end
142
-
143
- def connect
144
- socket = nil
145
- if udp?
146
- socket = UDPSocket.new
147
- socket.connect(@host, @port)
148
- else
149
- socket = TCPSocket.new(@host, @port)
150
151
  end
151
- socket
152
152
  end
153
153
  end
154
+
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-output-syslog'
4
- s.version = '0.2.0'
4
+ s.version = '2.0.1'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Send events to a syslog server."
7
7
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.require_paths = ["lib"]
12
12
 
13
13
  # Files
14
- s.files = `git ls-files`.split($\)+::Dir.glob('vendor/*')
14
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
15
15
 
16
16
  # Tests
17
17
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
@@ -20,9 +20,8 @@ Gem::Specification.new do |s|
20
20
  s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
21
21
 
22
22
  # Gem dependencies
23
- s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
23
+ s.add_runtime_dependency "logstash-core", ">= 2.0.0.snapshot", "< 3.0.0"
24
24
 
25
25
  s.add_development_dependency 'logstash-devutils'
26
- s.add_development_dependency 'logstash-codec-plain'
27
26
  end
28
27
 
@@ -1,50 +1 @@
1
- # encoding: utf-8
2
-
3
1
  require "logstash/devutils/rspec/spec_helper"
4
- require "logstash/outputs/syslog"
5
-
6
- describe LogStash::Outputs::Syslog do
7
-
8
- it "should register without errors" do
9
- plugin = LogStash::Plugin.lookup("output", "syslog").new({"host" => "foo", "port" => "123", "facility" => "kernel", "severity" => "emergency"})
10
- expect { plugin.register }.to_not raise_error
11
- end
12
-
13
- subject do
14
- plugin = LogStash::Plugin.lookup("output", "syslog").new(options)
15
- plugin.register
16
- plugin
17
- end
18
-
19
- let(:socket) { double("fake socket") }
20
- let(:event) { LogStash::Event.new({"message" => "bar", "host" => "baz"}) }
21
-
22
- shared_examples "syslog output" do
23
- it "should write expected format" do
24
- expect(subject).to receive(:connect).and_return(socket)
25
- expect(socket).to receive(:write).with(output)
26
- subject.receive(event)
27
- end
28
- end
29
-
30
- context "rfc 3164 and udp by default" do
31
- let(:options) { {"host" => "foo", "port" => "123", "facility" => "kernel", "severity" => "emergency"} }
32
- let(:output) { /^<0>.+baz LOGSTASH\[-\]: bar\n/m }
33
-
34
- it_behaves_like "syslog output"
35
- end
36
-
37
- context "rfc 5424 and tcp" do
38
- let(:options) { {"rfc" => "rfc5424", "protocol" => "tcp", "host" => "foo", "port" => "123", "facility" => "kernel", "severity" => "emergency"} }
39
- let(:output) { /^<0>1 .+baz LOGSTASH - - - bar\n/m }
40
-
41
- it_behaves_like "syslog output"
42
- end
43
-
44
- context "calculate priority" do
45
- let(:options) { {"host" => "foo", "port" => "123", "facility" => "mail", "severity" => "critical"} }
46
- let(:output) { /^<18>.+baz LOGSTASH\[-\]: bar\n/m }
47
-
48
- it_behaves_like "syslog output"
49
- end
50
- end
metadata CHANGED
@@ -1,24 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-syslog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-18 00:00:00.000000000 Z
11
+ date: 2015-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - '>='
17
17
  - !ruby/object:Gem::Version
18
- version: 1.4.0
18
+ version: 2.0.0.snapshot
19
19
  - - <
20
20
  - !ruby/object:Gem::Version
21
- version: 2.0.0
21
+ version: 3.0.0
22
22
  name: logstash-core
23
23
  prerelease: false
24
24
  type: :runtime
@@ -26,10 +26,10 @@ dependencies:
26
26
  requirements:
27
27
  - - '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 1.4.0
29
+ version: 2.0.0.snapshot
30
30
  - - <
31
31
  - !ruby/object:Gem::Version
32
- version: 2.0.0
32
+ version: 3.0.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  requirements:
@@ -44,34 +44,18 @@ dependencies:
44
44
  - - '>='
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
- - !ruby/object:Gem::Dependency
48
- requirement: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - '>='
51
- - !ruby/object:Gem::Version
52
- version: '0'
53
- name: logstash-codec-plain
54
- prerelease: false
55
- type: :development
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - '>='
59
- - !ruby/object:Gem::Version
60
- version: '0'
61
47
  description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
62
48
  email: info@elastic.co
63
49
  executables: []
64
50
  extensions: []
65
51
  extra_rdoc_files: []
66
52
  files:
67
- - .gitignore
68
53
  - CHANGELOG.md
69
54
  - CONTRIBUTORS
70
55
  - Gemfile
71
56
  - LICENSE
72
57
  - NOTICE.TXT
73
58
  - README.md
74
- - Rakefile
75
59
  - lib/logstash/outputs/syslog.rb
76
60
  - logstash-output-syslog.gemspec
77
61
  - spec/outputs/syslog_spec.rb
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.gem
2
- Gemfile.lock
3
- .bundle
4
- vendor
data/Rakefile DELETED
@@ -1,7 +0,0 @@
1
- @files=[]
2
-
3
- task :default do
4
- system("rake -T")
5
- end
6
-
7
- require "logstash/devutils/rake"