Merge remote-tracking branch 'origin/master' into add_output_settings

* origin/master:
  Auto reload fluentd log by default
  Fix if fluentd is not installed
  Replace title with ENV
  Strict detetction fluent-gem command with setup fluentd/td-agent specific
  clickable whole heading element same as fluentd setting page
  Fix fluentd version (not bundle-installed fluentd version)
  Hide plugin pages until fluentd setup finished

Conflicts:
	app/views/shared/_global_nav.html.erb
This commit is contained in:
uu59 2014-07-22 14:09:06 +09:00
commit 5403234974
12 changed files with 42 additions and 12 deletions

View File

@ -6,7 +6,7 @@
new Vue({
el: "#fluent-log",
paramAttributes: ["logUrl"],
paramAttributes: ["logUrl", "initialAutoReload"],
data: {
"autoFetch": false,
"logs": [],
@ -15,6 +15,9 @@
},
created: function(){
if(this.initialAutoReload) {
this.autoFetch = true;
}
this.fetchLogs();
var self = this;

View File

@ -47,7 +47,7 @@ class MiscController < ApplicationController
end
zip.get_output_stream('versions.txt') do |f|
f.puts "ruby: #{RUBY_DESCRIPTION}"
f.puts "fluentd: #{Fluent::VERSION}"
f.puts "fluentd: #{FluentdUI.fluentd_version}"
f.puts "fluentd-ui: #{FluentdUI::VERSION}"
end
end

View File

@ -5,6 +5,10 @@ module ApplicationHelper
File.exist?("/etc/init.d/td-agent")
end
def fluentd_ui_title
ENV["FLUENTD_UI_TITLE"] || "Fluentd UI"
end
def language_name(locale)
# NOTE: these are fixed terms, not i18n-ed
{

View File

@ -66,7 +66,7 @@ class Fluentd
end
end
%w(running? log config config_write config_append log_tail configuration).each do |method|
%w(running? version log config config_write config_append log_tail configuration).each do |method|
define_method(method) do
raise NotImplementedError, "'#{method}' method is required to be defined"
end

View File

@ -41,6 +41,12 @@ class Fluentd
actual_reload
end
def version
Bundler.with_clean_env do
`fluentd --version`.strip
end
end
private
def options_to_argv

View File

@ -25,6 +25,10 @@ class Fluentd
# https://github.com/treasure-data/td-agent/blob/master/debian/td-agent.init#L156
system('/etc/init.d/td-agent restart')
end
def version
`td-agent --version`.strip
end
end
end
end

View File

@ -190,11 +190,16 @@ class Plugin
end
def fluent_gem_path
# On installed both td-agent and fluentd system, decide which fluent-gem command should be used depend on setup(Fluentd.instance)
if Fluentd.instance && Fluentd.instance.fluentd?
return "fluent-gem" # maybe `fluent-gem` command is in the $PATH
end
# NOTE: td-agent has a command under the /usr/lib{,64}, td-agent2 has under /opt/td-agent
%W(
fluent-gem
/opt/td-agent/embedded/bin/fluent-gem
/usr/lib/fluent/ruby/bin/fluent-gem
/usr/lib64/fluent/ruby/bin/fluent-gem
/opt/td-agent/embedded/bin/fluent-gem
).find do |path|
system("which #{path}", out: File::NULL, err: File::NULL)
end

View File

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Fluentd-UI
<% fluentd_ui_title %>
<% if content_for?(:page_title) %>
|
<%= content_for(:page_title) %>
@ -32,7 +32,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<%= link_to "fluentd-ui", root_path, class: "navbar-brand" %>
<%= link_to fluentd_ui_title, root_path, class: "navbar-brand" %>
</div>
<!-- /.navbar-header -->

View File

@ -24,7 +24,7 @@
%dt ruby
%dd= RUBY_DESCRIPTION
%dt fluentd
%dd= Fluent::VERSION
%dd= FluentdUI.fluentd_version
%dt fluentd-ui
%dd= FluentdUI::VERSION
@ -51,9 +51,8 @@
%div.col-lg-12
%div.panel.panel-default
%div.panel-heading
%h4
%a{"data-toggle" => "collapse", "href" => "#env-table"}
= icon('fa-caret-down')
%h4{"data-toggle" => "collapse", "href" => "#env-table"}
= icon('fa-caret-down')
= t('.env')
%table{class: "table table-hover collapse", id: "env-table"}
%thead

View File

@ -21,6 +21,7 @@
<% end %>
</li>
<% if fluentd_exists? %>
<li>
<a>
<%= icon("fa-cogs fa-fw") << t('terms.plugins') << icon('pull-right fa-caret-down') %>
@ -37,6 +38,7 @@
</li>
</ul>
</li>
<% end %>
<li>
<a>

View File

@ -1,5 +1,6 @@
<!-- vue.js -->
<div id="fluent-log" logUrl="<%= log_tail_fluentd_agent_path(fluentd) %>">
<% auto_reload ||= false %>
<div id="fluent-log" logUrl="<%= log_tail_fluentd_agent_path(fluentd) %>" initialAutoReload="<%= auto_reload ? "true" : "" %>">
<p>
<button class="btn btn-primary" v-on="click: fetchLogs">
<%= t "terms.reload_log" %>

View File

@ -13,4 +13,10 @@ module FluentdUI
current = Gem::Version.new(::FluentdUI::VERSION)
latest > current
end
def self.fluentd_version
setup_fluentd = Fluentd.instance
return nil unless setup_fluentd
setup_fluentd.agent.version
end
end