Add in_syslog setting basis

This commit is contained in:
uu59 2014-07-11 12:50:39 +09:00
parent ee8e3e5407
commit 744c6a18ea
8 changed files with 107 additions and 0 deletions

View File

@ -0,0 +1,34 @@
class Fluentd::Settings::InSyslogController < ApplicationController
before_action :login_required
before_action :find_fluentd
def show
@setting = Fluentd::Setting::InSyslog.new({
bind: "0.0.0.0",
port: 5140,
})
end
def finish
@setting = Fluentd::Setting::InSyslog.new(setting_params)
unless @setting.valid?
return render "show"
end
@fluentd.agent.config_append @setting.to_conf
if @fluentd.agent.running?
unless @fluentd.agent.restart
@setting.errors.add(:base, @fluentd.agent.log_tail(1).first)
return render "show"
end
end
redirect_to fluentd_setting_path(@fluentd)
end
private
def setting_params
params.require(:fluentd_setting_in_syslog).permit(*Fluentd::Setting::InSyslog::KEYS)
end
end

View File

@ -0,0 +1,28 @@
class Fluentd
module Setting
class InSyslog
include ActiveModel::Model
include Common
KEYS = [
:port, :bind, :tag, :types
].freeze
attr_accessor(*KEYS)
validates :tag, presence: true
def to_conf
<<-XML.strip_heredoc.gsub(/^[ ]*\n/m, "")
<source>
type syslog
#{print_if_present :tag}
#{print_if_present :bind}
#{print_if_present :port}
#{print_if_present :types}
</source>
XML
end
end
end
end

View File

@ -0,0 +1,19 @@
- @setting.errors.full_messages.each do |msg|
= msg
= form_for(@setting, url: finish_fluentd_setting_in_syslog_path(@fluentd), html: {class: "ignore-rails-error-div"}) do |f|
.form-group
= f.label :tag
= f.text_field :tag
.form-group
= f.label :bind
= f.text_field :bind
.form-group
= f.label :port
= f.text_field :port
.form-group
= f.label :types
= f.text_field :types
= f.submit t('fluentd.common.finish') , class: "btn btn-lg btn-primary pull-right"
= f.submit t('terms.prev'), class: "btn btn-lg btn-default", name: "back"

View File

@ -0,0 +1,6 @@
- page_title t(".page_title")
.well
= raw t('fluentd.settings.in_syslog.option_guide')
= render "form"

View File

@ -19,6 +19,10 @@
= link_to(fluentd_setting_in_tail_path(@fluentd)) do
= icon('fa-file-text-o fa-lg')
= t("fluentd.common.setup_in_tail")
%p
= link_to(fluentd_setting_in_syslog_path(@fluentd)) do
= icon('fa-file-text-o fa-lg')
= t("fluentd.common.setup_in_syslog")
.col-lg-6
.panel.panel-default
.panel-heading

View File

@ -93,6 +93,7 @@ en:
config_file: Config file
page_title: "%{label}"
setup_in_tail: Setting file reading
setup_in_syslog: Setting Syslog readling
setup_out_td: Setting Treasure Data writing
setup_out_mongo: Setting MongoDB writing
finish: Update config
@ -138,6 +139,11 @@ en:
See also <a target="_blank" href="http://docs.fluentd.org/articles/out_mongo">out_mongo plugin</a>.
show:
page_title: Write to MongoDB setting
in_syslog:
option_guide: |
See also <a target="_blank" href="http://docs.fluentd.org/articles/in_syslog">in_syslog Plugin</a> page.
show:
page_title: Syslog読み込み設定
in_tail_option_guide: |
See <a target="_blank" href="http://docs.fluentd.org/articles/in_tail">in_tail Plugin</a> or
<a target="_blank" href="http://fluentular.herokuapp.com/">Fluentular</a> for more details.

View File

@ -93,6 +93,7 @@ ja:
config_file: 設定ファイル
page_title: "%{label}"
setup_in_tail: ファイル読み込みの設定
setup_in_syslog: syslog読み込みの設定
setup_out_td: Treasure Dataへの書き出し設定
setup_out_mongo: MongoDBへの書き出し設定
finish: 設定する
@ -139,6 +140,11 @@ ja:
<a target="_blank" href="http://docs.fluentd.org/ja/articles/out_mongo">out_mongoプラグインの解説</a>もご参照ください。
show:
page_title: MongoDB書き出し設定
in_syslog:
option_guide: |
<a target="_blank" href="http://docs.fluentd.org/ja/articles/in_syslog">in_syslogプラグイン解説ページ</a>もご参照ください。
show:
page_title: Syslog読み込み設定
in_tail_option_guide: |
<a target="_blank" href="http://docs.fluentd.org/ja/articles/in_tail">in_tailプラグインの解説ページ</a>や
<a target="_blank" href="http://fluentular.herokuapp.com/">Fluentular</a>もご参照ください。

View File

@ -18,6 +18,10 @@ Rails.application.routes.draw do
post "finish"
end
resource :in_syslog, only: ["show"], module: :settings, controller: :in_syslog do
post "finish"
end
resource :out_mongo, only: ["show"], module: :settings, controller: :out_mongo do
post "finish"
end