diff --git a/app/controllers/misc_controller.rb b/app/controllers/misc_controller.rb index b90a305..423f43b 100644 --- a/app/controllers/misc_controller.rb +++ b/app/controllers/misc_controller.rb @@ -1,4 +1,5 @@ require "fluent/version" +require "zip" class MiscController < ApplicationController after_action :update!, only: [:update_fluentd_ui] @@ -31,6 +32,28 @@ class MiscController < ApplicationController end end + def download_info + fluentd = Fluentd.instance + path = Rails.root.join("tmp/system_info.zip") + File.unlink(path) if File.exists?(path) + + Zip::File.open(path, Zip::File::CREATE) do |zip| + zip.get_output_stream('fluentd.log') {|f| f.puts fluentd.agent.log } + zip.add("fluentd-ui.log", Rails.root.join("log/#{Rails.env}.log")) + zip.get_output_stream('env.txt') do |f| + ENV.to_a.each do |(key, value)| + f.puts "#{key}=#{value}" + end + end + zip.get_output_stream('versions.txt') do |f| + f.puts "ruby: #{RUBY_DESCRIPTION}" + f.puts "fluentd: #{Fluent::VERSION}" + f.puts "fluentd-ui: #{FluentdUI::VERSION}" + end + end + send_file path + end + private def update! diff --git a/app/views/misc/information.html.haml b/app/views/misc/information.html.haml index 2f07f1a..c4fff1f 100644 --- a/app/views/misc/information.html.haml +++ b/app/views/misc/information.html.haml @@ -8,6 +8,12 @@ = t('.update_fluentd_ui', version: FluentdUI.latest_version) = t('.update_fluentd_ui_caution') +.row + .col-lg-12 + %p + =link_to misc_download_info_path, class: "btn btn-default" do + = t('.download_system_information') + .row %div.col-lg-6 %div.panel.panel-default diff --git a/config/locales/translation_en.yml b/config/locales/translation_en.yml index 535e49d..1ede59c 100644 --- a/config/locales/translation_en.yml +++ b/config/locales/translation_en.yml @@ -189,6 +189,7 @@ en: page_title: System Information update_fluentd_ui: Update fluentd-ui update_fluentd_ui_caution: "Note: fluentd will not restart" + download_system_information: Download system information update_fluentd_ui: <<: *misc_common update_title: Updating fluentd-ui diff --git a/config/locales/translation_ja.yml b/config/locales/translation_ja.yml index 2f5b4a7..10b4528 100644 --- a/config/locales/translation_ja.yml +++ b/config/locales/translation_ja.yml @@ -185,6 +185,7 @@ ja: page_title: システム情報 update_fluentd_ui: fluentd-uiを更新 update_fluentd_ui_caution: ※fluentdは再起動されません + download_system_information: システム情報をダウンロード update_fluentd_ui: <<: *misc_common update_title: fluentd-ui 更新 diff --git a/config/routes.rb b/config/routes.rb index da70d3f..858c8f0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -39,6 +39,7 @@ Rails.application.routes.draw do get "misc/information" post "misc/update_fluentd_ui" get "misc/upgrading_status" + get "misc/download_info" namespace :polling do get "alerts"