From afcb2b8e0d9191b9d7d321d359befd60db57c6d1 Mon Sep 17 00:00:00 2001 From: Andreas John Date: Wed, 14 Sep 2016 19:14:46 +0200 Subject: [PATCH 1/2] Resolving the remote host name to IP only once at startup time. --- lib/fluent/plugin/out_remote_syslog.rb | 8 +++++++- test/plugin/out_remote_syslog.rb | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/fluent/plugin/out_remote_syslog.rb b/lib/fluent/plugin/out_remote_syslog.rb index 171b813..b68a7a6 100644 --- a/lib/fluent/plugin/out_remote_syslog.rb +++ b/lib/fluent/plugin/out_remote_syslog.rb @@ -26,6 +26,12 @@ def initialize @loggers = {} end + def start + super + require 'resolv' + @host_ip = Resolv.getaddress(@host) + end + def shutdown super @loggers.values.each(&:close) @@ -41,7 +47,7 @@ def emit(tag, es, chain) end tag = rewrite_tag!(tag.dup) - @loggers[tag] ||= RemoteSyslogLogger::UdpSender.new(@host, + @loggers[tag] ||= RemoteSyslogLogger::UdpSender.new(@host_ip, @port, facility: @facility, severity: @severity, diff --git a/test/plugin/out_remote_syslog.rb b/test/plugin/out_remote_syslog.rb index d23af7a..752b72f 100644 --- a/test/plugin/out_remote_syslog.rb +++ b/test/plugin/out_remote_syslog.rb @@ -14,7 +14,7 @@ def test_configure d = create_driver %[ type remote_syslog hostname foo.com - host example.com + host localhost port 5566 severity debug tag minitest @@ -29,7 +29,7 @@ def test_configure logger = loggers.values.first - assert_equal "example.com", logger.instance_variable_get(:@remote_hostname) + assert_equal "127.0.0.1", logger.instance_variable_get(:@remote_hostname) assert_equal 5566, logger.instance_variable_get(:@remote_port) p = logger.instance_variable_get(:@packet) From 2336227232931a9ef43e4641b2100ce4aa7d8396 Mon Sep 17 00:00:00 2001 From: Andreas John Date: Thu, 15 Sep 2016 08:35:48 +0200 Subject: [PATCH 2/2] Remote Syslog Port: Change the default port to 514. --- README.md | 2 +- lib/fluent/plugin/out_remote_syslog.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ac62da6..2687364 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ type remote_syslog host example.com - port 25 + port 514 severity debug tag fluentd diff --git a/lib/fluent/plugin/out_remote_syslog.rb b/lib/fluent/plugin/out_remote_syslog.rb index b68a7a6..6580210 100644 --- a/lib/fluent/plugin/out_remote_syslog.rb +++ b/lib/fluent/plugin/out_remote_syslog.rb @@ -14,7 +14,7 @@ class RemoteSyslogOutput < Fluent::Output include Fluent::Mixin::RewriteTagName config_param :host, :string - config_param :port, :integer, :default => 25 + config_param :port, :integer, :default => 514 config_param :facility, :string, :default => "user" config_param :severity, :string, :default => "notice"