fluentd-ui 0.3.10 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of fluentd-ui might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/ChangeLog +3 -0
- data/Gemfile.lock +1 -1
- data/app/controllers/fluentd/settings/histories_controller.rb +26 -0
- data/app/controllers/fluentd/settings/running_backup_controller.rb +19 -0
- data/app/controllers/fluentd/settings_controller.rb +5 -0
- data/app/models/fluentd.rb +0 -8
- data/app/models/fluentd/agent.rb +0 -1
- data/app/models/fluentd/agent/common.rb +28 -0
- data/app/models/fluentd/agent/fluentd_gem.rb +5 -1
- data/app/models/fluentd/agent/local_common.rb +33 -0
- data/app/models/fluentd/agent/td_agent/macosx.rb +3 -1
- data/app/models/fluentd/agent/td_agent/unix.rb +3 -1
- data/app/models/fluentd/setting/backup_file.rb +41 -0
- data/app/models/fluentd/setting/config.rb +2 -1
- data/app/views/fluentd/settings/histories/_list.html.haml +6 -0
- data/app/views/fluentd/settings/histories/index.html.haml +3 -0
- data/app/views/fluentd/settings/histories/show.html.haml +11 -0
- data/app/views/fluentd/settings/running_backup/show.html.haml +15 -0
- data/app/views/fluentd/settings/show.html.haml +13 -0
- data/config/application.yml +2 -0
- data/config/locales/translation_en.yml +15 -0
- data/config/locales/translation_ja.yml +15 -0
- data/config/routes.rb +8 -0
- data/lib/fluentd-ui/version.rb +1 -1
- data/spec/features/fluentd/setting/hisotries_spec.rb +48 -0
- data/spec/features/fluentd/setting/ranning_backup_spec.rb +48 -0
- data/spec/features/setting_spec.rb +17 -0
- data/spec/models/fluentd/agent/local_common_spec.rb +45 -0
- data/spec/models/fluentd/agent_spec.rb +43 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/config_histories.rb +57 -0
- metadata +57 -91
- data/app/models/fluentd/agent/remote.rb +0 -7
- data/app/models/fluentd/api.rb +0 -6
- data/app/models/fluentd/api/http.rb +0 -26
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ea1ab2d5ce725a63c27f10c40a0327cc35f7b430
|
4
|
+
data.tar.gz: 5b61d101c19bec0e603c0497debbb5e89fb012a0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 048827d25bbb3e971bdc13dfda18165718ab6babda3da181fc16ad76fb9ce6f0067a87a1bbf6b4fa2219511e2923cd5621b2bf0f08f7a10a0effe6194a20c666
|
7
|
+
data.tar.gz: d24f8c0065fd5ecd5d62a23dffff0dbeece212bcc0effd442b1f2ca545d54176a6eb7ff7594bb3914d2a039a74244dac817a1942244533cea028b35152ec3263
|
data/ChangeLog
CHANGED
data/Gemfile.lock
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
class Fluentd::Settings::HistoriesController < ApplicationController
|
2
|
+
before_action :login_required
|
3
|
+
before_action :find_fluentd
|
4
|
+
before_action :find_backup_file, only: [:show, :reuse]
|
5
|
+
|
6
|
+
def index
|
7
|
+
@backup_files = @fluentd.agent.backup_files_in_new_order.map do |file_path|
|
8
|
+
Fluentd::Setting::BackupFile.new(file_path)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def show
|
13
|
+
end
|
14
|
+
|
15
|
+
def reuse
|
16
|
+
@fluentd.agent.config_write @backup_file.content
|
17
|
+
redirect_to daemon_setting_path, flash: { success: t('messages.config_successfully_copied', brand: fluentd_ui_brand) }
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def find_backup_file
|
23
|
+
#Do not use BackupFile.new(params[:id]) because params[:id] can be any path.
|
24
|
+
@backup_file = Fluentd::Setting::BackupFile.find_by_file_id(@fluentd.agent.config_backup_dir, params[:id])
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Fluentd::Settings::RunningBackupController < ApplicationController
|
2
|
+
before_action :login_required
|
3
|
+
before_action :find_fluentd
|
4
|
+
before_action :find_backup_file, only: [:show, :reuse]
|
5
|
+
|
6
|
+
def show
|
7
|
+
end
|
8
|
+
|
9
|
+
def reuse
|
10
|
+
@fluentd.agent.config_write @backup_file.content
|
11
|
+
redirect_to daemon_setting_path, flash: { success: t('messages.config_successfully_copied', brand: fluentd_ui_brand) }
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def find_backup_file
|
17
|
+
@backup_file = Fluentd::Setting::BackupFile.new(@fluentd.agent.running_config_backup_file)
|
18
|
+
end
|
19
|
+
end
|
@@ -6,6 +6,11 @@ class Fluentd::SettingsController < ApplicationController
|
|
6
6
|
before_action :set_config, only: [:show, :edit, :update]
|
7
7
|
|
8
8
|
def show
|
9
|
+
@backup_files = @fluentd.agent.backup_files_in_new_order.first(Settings.histories_count_in_preview).map do |file_path|
|
10
|
+
Fluentd::Setting::BackupFile.new(file_path)
|
11
|
+
end
|
12
|
+
|
13
|
+
@running_backedup_file = Fluentd::Setting::BackupFile.new(@fluentd.agent.running_config_backup_file)
|
9
14
|
end
|
10
15
|
|
11
16
|
def edit
|
data/app/models/fluentd.rb
CHANGED
@@ -73,14 +73,6 @@ class Fluentd
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
def api
|
77
|
-
Api::Http.new(api_endpoint)
|
78
|
-
end
|
79
|
-
|
80
|
-
def api_endpoint
|
81
|
-
# TODO: autodetect from parsed configuration, but unused for now
|
82
|
-
end
|
83
|
-
|
84
76
|
def label
|
85
77
|
"fluentd" # NOTE: for multiple fluentd management, but only single fluentd manage now
|
86
78
|
end
|
data/app/models/fluentd/agent.rb
CHANGED
@@ -57,6 +57,21 @@ class Fluentd
|
|
57
57
|
extra_options[:config_file] || self.class.default_options[:config_file]
|
58
58
|
end
|
59
59
|
|
60
|
+
def config_backup_dir
|
61
|
+
dir = File.join(FluentdUI.data_dir, "#{Rails.env}_confg_backups")
|
62
|
+
FileUtils.mkdir_p(dir)
|
63
|
+
dir
|
64
|
+
end
|
65
|
+
|
66
|
+
def running_config_backup_dir
|
67
|
+
dir = File.join(FluentdUI.data_dir, "#{Rails.env}_running_confg_backup")
|
68
|
+
FileUtils.mkdir_p(dir)
|
69
|
+
dir
|
70
|
+
end
|
71
|
+
|
72
|
+
def running_config_backup_file
|
73
|
+
File.join(running_config_backup_dir, "running.conf")
|
74
|
+
end
|
60
75
|
|
61
76
|
# define these methods on each Agent class
|
62
77
|
|
@@ -71,6 +86,19 @@ class Fluentd
|
|
71
86
|
raise NotImplementedError, "'#{method}' method is required to be defined"
|
72
87
|
end
|
73
88
|
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def backup_running_config
|
93
|
+
#back up config file only when start success
|
94
|
+
return unless yield
|
95
|
+
|
96
|
+
return unless File.exists? config_file
|
97
|
+
|
98
|
+
FileUtils.cp config_file, running_config_backup_file
|
99
|
+
|
100
|
+
true
|
101
|
+
end
|
74
102
|
end
|
75
103
|
end
|
76
104
|
end
|
@@ -15,7 +15,10 @@ class Fluentd
|
|
15
15
|
# return value is status_after_this_method_called == started
|
16
16
|
def start
|
17
17
|
return true if running?
|
18
|
-
|
18
|
+
|
19
|
+
backup_running_config do
|
20
|
+
actual_start
|
21
|
+
end
|
19
22
|
end
|
20
23
|
|
21
24
|
# return value is status_after_this_method_called == stopped
|
@@ -67,6 +70,7 @@ class Fluentd
|
|
67
70
|
Bundler.with_clean_env do
|
68
71
|
spawn("fluentd #{options_to_argv}")
|
69
72
|
end
|
73
|
+
|
70
74
|
wait_starting
|
71
75
|
end
|
72
76
|
|
@@ -20,12 +20,14 @@ class Fluentd
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def config_write(content)
|
23
|
+
backup_config
|
23
24
|
File.open(config_file, "w") do |f|
|
24
25
|
f.write content
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
29
|
def config_append(content)
|
30
|
+
backup_config
|
29
31
|
File.open(config_file, "a") do |f|
|
30
32
|
f.write "\n"
|
31
33
|
f.write content
|
@@ -59,8 +61,39 @@ class Fluentd
|
|
59
61
|
File.read(pid_file).to_i rescue nil
|
60
62
|
end
|
61
63
|
|
64
|
+
def backup_files
|
65
|
+
Dir.glob(File.join("#{config_backup_dir}", "*.conf"))
|
66
|
+
end
|
67
|
+
|
68
|
+
def backup_files_in_old_order
|
69
|
+
backup_files.sort
|
70
|
+
end
|
71
|
+
|
72
|
+
def backup_files_in_new_order
|
73
|
+
backup_files_in_old_order.reverse
|
74
|
+
end
|
75
|
+
|
62
76
|
private
|
63
77
|
|
78
|
+
def backup_config
|
79
|
+
return unless File.exists? config_file
|
80
|
+
|
81
|
+
FileUtils.cp config_file, File.join(config_backup_dir, "#{Time.zone.now.strftime('%Y%m%d_%H%M%S')}.conf")
|
82
|
+
|
83
|
+
remove_over_backup_files
|
84
|
+
end
|
85
|
+
|
86
|
+
def remove_over_backup_files
|
87
|
+
over_file_count = backup_files.size - ::Settings.max_backup_files_count
|
88
|
+
|
89
|
+
return if over_file_count <= 0
|
90
|
+
|
91
|
+
backup_files_in_old_order.first(over_file_count).each do |file|
|
92
|
+
next unless File.exist? file
|
93
|
+
FileUtils.rm(file)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
64
97
|
def logged_errors(&block)
|
65
98
|
return [] unless File.exist?(log_file)
|
66
99
|
buf = []
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class Fluentd
|
2
|
+
module Setting
|
3
|
+
class BackupFile
|
4
|
+
attr_accessor :file_path
|
5
|
+
|
6
|
+
def self.find_by_file_id(backup_dir, file_id)
|
7
|
+
file_path = Pathname.new(backup_dir).join("#{file_id}.conf")
|
8
|
+
raise "No such a file #{file_path}" unless File.exist?(file_path)
|
9
|
+
|
10
|
+
new(file_path)
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(file_path)
|
14
|
+
@file_path = file_path
|
15
|
+
end
|
16
|
+
|
17
|
+
def file_id
|
18
|
+
@file_id ||= with_file { name.gsub(/.conf\Z/,'') }
|
19
|
+
end
|
20
|
+
|
21
|
+
def name
|
22
|
+
@name ||= with_file { File.basename(file_path) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def content
|
26
|
+
@content ||= with_file { File.open(file_path, "r") { |f| f.read } }
|
27
|
+
end
|
28
|
+
|
29
|
+
def ctime
|
30
|
+
with_file { File.ctime(file_path) }
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def with_file
|
36
|
+
return nil unless file_path && File.exist?(file_path)
|
37
|
+
yield
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
- page_title t('.page_title', label: @fluentd.label) do
|
2
|
+
- link_to reuse_daemon_setting_history_path(id: @backup_file.file_id), method: 'post', class: "btn btn-primary pull-right" do
|
3
|
+
= icon('fa-pencil')
|
4
|
+
= t("terms.reuse")
|
5
|
+
|
6
|
+
.row
|
7
|
+
.col-xs-12
|
8
|
+
%pre
|
9
|
+
= preserve do
|
10
|
+
= @backup_file.content
|
11
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
- page_title t('.page_title', label: @fluentd.label) do
|
2
|
+
- if @backup_file.content
|
3
|
+
- link_to reuse_daemon_setting_running_backup_path, method: 'post', class: "btn btn-primary pull-right" do
|
4
|
+
= icon('fa-pencil')
|
5
|
+
= t("terms.reuse")
|
6
|
+
|
7
|
+
.row
|
8
|
+
.col-xs-12
|
9
|
+
- if @backup_file.content
|
10
|
+
%pre
|
11
|
+
= preserve do
|
12
|
+
= @backup_file.content
|
13
|
+
- else
|
14
|
+
%p
|
15
|
+
=t('fluentd.common.never_started_yet', brand: fluentd_ui_brand)
|
@@ -8,3 +8,16 @@
|
|
8
8
|
%pre
|
9
9
|
= preserve do
|
10
10
|
= @config
|
11
|
+
|
12
|
+
.row
|
13
|
+
.col-xs-12
|
14
|
+
%h3= link_to(t('fluentd.settings.running_backup.title'), daemon_setting_running_backup_path)
|
15
|
+
%p
|
16
|
+
%label= t('terms.backup_time')
|
17
|
+
= @running_backedup_file.ctime.try(:strftime, I18n.t('time.formats.default')) || t('fluentd.common.never_started_yet', brand: fluentd_ui_brand)
|
18
|
+
|
19
|
+
.row
|
20
|
+
.col-xs-12
|
21
|
+
%h3= t('fluentd.settings.history')
|
22
|
+
= render '/fluentd/settings/histories/list'
|
23
|
+
.link= link_to t('.link_to_histories'), daemon_setting_histories_path
|
data/config/application.yml
CHANGED
@@ -11,6 +11,7 @@ en:
|
|
11
11
|
password_successfully_updated: "Your password has been changed successfully."
|
12
12
|
fluentd_status_running: Running
|
13
13
|
fluentd_status_stopped: Stopped
|
14
|
+
config_successfully_copied: "Config has been copied successfully. Please restart %{brand} to use the new config"
|
14
15
|
|
15
16
|
terms: &terms
|
16
17
|
name: Name
|
@@ -58,6 +59,8 @@ en:
|
|
58
59
|
notice_restart_for_config_edit: "NOTICE: running %{brand} will restart after update config"
|
59
60
|
lines: Lines
|
60
61
|
languages: Language
|
62
|
+
backup_time: Backed up at
|
63
|
+
reuse: reuse
|
61
64
|
|
62
65
|
plugins:
|
63
66
|
view_on_rubygems_org: View on rubygems.org
|
@@ -117,6 +120,7 @@ en:
|
|
117
120
|
Delete %{brand} setting.
|
118
121
|
|
119
122
|
<p>Running %{brand} will be stopped, but log and config file are still exists.</p>
|
123
|
+
never_started_yet: "%{brand} had never been started yet."
|
120
124
|
show:
|
121
125
|
page_title: Dashboard
|
122
126
|
new:
|
@@ -138,6 +142,7 @@ en:
|
|
138
142
|
show:
|
139
143
|
page_title: Config File
|
140
144
|
in_out_head: In/Out setting
|
145
|
+
link_to_histories: See more histories
|
141
146
|
edit:
|
142
147
|
page_title: Edit Config File
|
143
148
|
out_forward:
|
@@ -245,6 +250,16 @@ en:
|
|
245
250
|
page_title: "Config Parameters"
|
246
251
|
confirm:
|
247
252
|
page_title: "Confirmation"
|
253
|
+
history: "Setting History"
|
254
|
+
histories:
|
255
|
+
index:
|
256
|
+
page_title: "Setting Histories"
|
257
|
+
show:
|
258
|
+
page_title: "Reuse Setting History"
|
259
|
+
running_backup:
|
260
|
+
title: "Running Config"
|
261
|
+
show:
|
262
|
+
page_title: "Running Config"
|
248
263
|
|
249
264
|
misc:
|
250
265
|
information:
|
@@ -11,6 +11,7 @@ ja:
|
|
11
11
|
password_successfully_updated: "パスワードを変更しました。"
|
12
12
|
fluentd_status_running: 稼働中
|
13
13
|
fluentd_status_stopped: 停止中
|
14
|
+
config_successfully_copied: "設定をコピーしました。反映させるには、 %{brand}を再起動してください。"
|
14
15
|
|
15
16
|
terms: &terms
|
16
17
|
name: アカウント名
|
@@ -58,6 +59,8 @@ ja:
|
|
58
59
|
notice_restart_for_config_edit: "※更新すると稼働中の%{brand}が再起動されます"
|
59
60
|
lines: 行
|
60
61
|
languages: 言語
|
62
|
+
backup_time: バックアップ日時
|
63
|
+
reuse: 再利用
|
61
64
|
|
62
65
|
plugins:
|
63
66
|
view_on_rubygems_org: rubygems.orgで見る
|
@@ -116,6 +119,7 @@ ja:
|
|
116
119
|
%{brand}の設定を削除します。
|
117
120
|
|
118
121
|
<p>起動中の%{brand}は停止し、ログや設定ファイルはそのまま残存します。</p>
|
122
|
+
never_started_yet: "%{brand} は起動されたことがありません。"
|
119
123
|
show:
|
120
124
|
page_title: "ダッシュボード"
|
121
125
|
new:
|
@@ -136,6 +140,7 @@ ja:
|
|
136
140
|
setting_empty: 設定されていません
|
137
141
|
show:
|
138
142
|
page_title: 設定ファイルの編集
|
143
|
+
link_to_histories: さらに過去の履歴をみる
|
139
144
|
edit:
|
140
145
|
page_title: 設定ファイルの編集
|
141
146
|
out_forward:
|
@@ -250,6 +255,16 @@ ja:
|
|
250
255
|
page_title: "ファイル読み込み | その他の設定"
|
251
256
|
confirm:
|
252
257
|
page_title: "ファイル読み込み | 確認"
|
258
|
+
history: 設定履歴
|
259
|
+
histories:
|
260
|
+
index:
|
261
|
+
page_title: "設定履歴 | 一覧"
|
262
|
+
show:
|
263
|
+
page_title: "設定履歴 | 詳細"
|
264
|
+
running_backup:
|
265
|
+
title: "使用中の設定"
|
266
|
+
show:
|
267
|
+
page_title: "使用中の設定"
|
253
268
|
|
254
269
|
misc:
|
255
270
|
information:
|