diff --git a/app/controllers/misc_controller.rb b/app/controllers/misc_controller.rb index 423f43b..e5a2fd5 100644 --- a/app/controllers/misc_controller.rb +++ b/app/controllers/misc_controller.rb @@ -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 diff --git a/app/models/fluentd/agent/common.rb b/app/models/fluentd/agent/common.rb index b22b94b..e1e0a9c 100644 --- a/app/models/fluentd/agent/common.rb +++ b/app/models/fluentd/agent/common.rb @@ -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 diff --git a/app/models/fluentd/agent/fluentd_gem.rb b/app/models/fluentd/agent/fluentd_gem.rb index 1e2572b..7c75fd2 100644 --- a/app/models/fluentd/agent/fluentd_gem.rb +++ b/app/models/fluentd/agent/fluentd_gem.rb @@ -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 diff --git a/app/models/fluentd/agent/td_agent.rb b/app/models/fluentd/agent/td_agent.rb index 53f217f..2e1e3a0 100644 --- a/app/models/fluentd/agent/td_agent.rb +++ b/app/models/fluentd/agent/td_agent.rb @@ -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 diff --git a/app/views/misc/information.html.haml b/app/views/misc/information.html.haml index c4fff1f..27b2c9f 100644 --- a/app/views/misc/information.html.haml +++ b/app/views/misc/information.html.haml @@ -24,7 +24,7 @@ %dt ruby %dd= RUBY_DESCRIPTION %dt fluentd - %dd= Fluent::VERSION + %dd= FluentdUI.fluentd_version %dt fluentd-ui %dd= FluentdUI::VERSION diff --git a/lib/fluentd-ui.rb b/lib/fluentd-ui.rb index b4e001f..0dcb7ef 100644 --- a/lib/fluentd-ui.rb +++ b/lib/fluentd-ui.rb @@ -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