Merge pull request #48 from treasure-data/zip

Download system information as zip
This commit is contained in:
uu59 2014-07-11 10:50:32 +09:00
commit 82adda962d
7 changed files with 35 additions and 0 deletions

View File

@ -16,6 +16,7 @@ PATH
kramdown-haml
puma
rails (= 4.1.4)
rubyzip (~> 1.1)
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)

View File

@ -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!

View File

@ -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

View File

@ -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

View File

@ -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 更新

View File

@ -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"

View File

@ -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", "~> 1.1" # API changed as Zip::ZipFile -> Zip::File since v1.0.0
end