Display current setting

This commit is contained in:
uu59 2014-11-12 12:50:20 +09:00
parent 72a4daf1bc
commit 22dd9c4bdb
5 changed files with 58 additions and 2 deletions

View File

@ -15,4 +15,8 @@ class Fluentd::SettingsController < ApplicationController
@fluentd.agent.restart if @fluentd.agent.running?
redirect_to daemon_setting_path(@fluentd)
end
def source_and_output
@config = Fluentd::Setting::Config.new(@fluentd.config_file)
end
end

View File

@ -0,0 +1,27 @@
require 'fluent/config'
class Fluentd
module Setting
class Config
attr_reader :config, :file
def initialize(config_file)
config = Fluent::Config.parse(IO.read(config_file), config_file, nil, true)
@config = config
@file = config_file
end
def sources
config.elements.find_all do |elm|
elm.name == "source"
end
end
def matches
config.elements.find_all do |elm|
elm.name == "match"
end
end
end
end
end

View File

@ -1,7 +1,5 @@
- page_title t('.page_title')
%h2
.row.fluentd-setting-inout
.col-xs-4
.panel.panel-default
@ -47,3 +45,28 @@
= link_to(daemon_setting_out_forward_path(@fluentd)) do
= icon('fa-file-text-o fa-lg')
= t("fluentd.common.setup_out_forward")
%h2= t('.current')
.row
.col-xs-6
%h3= t('.in')
- @config.sources.each_with_index do |elm, idx|
.panel.panel-default
.panel-heading{"data-toggle" => "collapse", "href" => "#source#{idx}", "title" => elm.inspect}
= elm["type"]
= icon('fa-caret-down')
.panel-body.collapse{"id" => "source#{idx}"}
%pre= elm.to_s
.col-xs-6
%h3= t('.out')
- @config.matches.each_with_index do |elm, idx|
.panel.panel-default
.panel-heading{"data-toggle" => "collapse", "href" => "#match#{idx}", "title" => elm.inspect}
= elm["type"]
(
= elm.arg
)
= icon('fa-caret-down')
.panel-body.collapse{"id" => "match#{idx}"}
%pre= elm.to_s

View File

@ -125,6 +125,7 @@ en:
page_title: Add Source and Output
in: Source
out: Output
current: Current setting
show:
page_title: Config File
in_out_head: In/Out setting

View File

@ -124,6 +124,7 @@ ja:
page_title: ソースと出力先の追加
in: 入力
out: 出力
current: 現在の設定
show:
page_title: 設定ファイルの編集
edit: