From 1fe9ff49e657b0c4bd1effb4b95b589a933ba746 Mon Sep 17 00:00:00 2001 From: uu59 Date: Thu, 10 Jul 2014 15:28:45 +0900 Subject: [PATCH 1/3] Add rubyzip --- Gemfile.lock | 2 ++ fluentd-ui.gemspec | 1 + 2 files changed, 3 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index e9178f1..161485f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,6 +16,7 @@ PATH kramdown-haml puma rails (= 4.1.4) + rubyzip sass-rails (~> 4.0.3) settingslogic sucker_punch (~> 1.0.5) @@ -175,6 +176,7 @@ GEM rspec-core (~> 2.99.0) rspec-expectations (~> 2.99.0) rspec-mocks (~> 2.99.0) + rubyzip (1.1.6) safe_yaml (1.0.3) sass (3.2.19) sass-rails (4.0.3) diff --git a/fluentd-ui.gemspec b/fluentd-ui.gemspec index dcd6999..9961e7f 100644 --- a/fluentd-ui.gemspec +++ b/fluentd-ui.gemspec @@ -36,4 +36,5 @@ Gem::Specification.new do |spec| spec.add_dependency "thor" spec.add_dependency "kramdown", "> 1.0.0" spec.add_dependency "kramdown-haml" + spec.add_dependency "rubyzip" end From e60ac201a50df560ff558770425ef68c68ca3cc0 Mon Sep 17 00:00:00 2001 From: uu59 Date: Thu, 10 Jul 2014 16:24:41 +0900 Subject: [PATCH 2/3] Add download system information button --- app/controllers/misc_controller.rb | 23 +++++++++++++++++++++++ app/views/misc/information.html.haml | 6 ++++++ config/locales/translation_en.yml | 1 + config/locales/translation_ja.yml | 1 + config/routes.rb | 1 + 5 files changed, 32 insertions(+) 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" From dfa3d014f2e7d1bda367e2aedf24bf55a691ea18 Mon Sep 17 00:00:00 2001 From: uu59 Date: Thu, 10 Jul 2014 17:00:44 +0900 Subject: [PATCH 3/3] Robust versioning for rubyzip --- Gemfile.lock | 2 +- fluentd-ui.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 161485f..eb0210b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,7 +16,7 @@ PATH kramdown-haml puma rails (= 4.1.4) - rubyzip + rubyzip (~> 1.1) sass-rails (~> 4.0.3) settingslogic sucker_punch (~> 1.0.5) diff --git a/fluentd-ui.gemspec b/fluentd-ui.gemspec index 9961e7f..63b67f9 100644 --- a/fluentd-ui.gemspec +++ b/fluentd-ui.gemspec @@ -36,5 +36,5 @@ Gem::Specification.new do |spec| spec.add_dependency "thor" spec.add_dependency "kramdown", "> 1.0.0" spec.add_dependency "kramdown-haml" - spec.add_dependency "rubyzip" + spec.add_dependency "rubyzip", "~> 1.1" # API changed as Zip::ZipFile -> Zip::File since v1.0.0 end