prometheus-splash 0.4.5 → 0.6.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +64 -2
- data/README.md +58 -60
- data/bin/splash +13 -5
- data/config/splash.yml +77 -7
- data/lib/splash/backends.rb +6 -0
- data/lib/splash/backends/file.rb +40 -0
- data/lib/splash/backends/redis.rb +47 -4
- data/lib/splash/cli.rb +31 -3
- data/lib/splash/cli/commands.rb +82 -33
- data/lib/splash/cli/config.rb +25 -4
- data/lib/splash/cli/daemon.rb +11 -14
- data/lib/splash/cli/documentation.rb +5 -2
- data/lib/splash/cli/logs.rb +27 -17
- data/lib/splash/cli/process.rb +103 -0
- data/lib/splash/cli/sequences.rb +112 -0
- data/lib/splash/cli/webadmin.rb +46 -0
- data/lib/splash/commands.rb +146 -120
- data/lib/splash/config.rb +170 -15
- data/lib/splash/config/flush.rb +30 -0
- data/lib/splash/config/sanitycheck.rb +7 -2
- data/lib/splash/config/service.rb +33 -0
- data/lib/splash/config/setup.rb +8 -3
- data/lib/splash/constants.rb +37 -8
- data/lib/splash/daemon.rb +6 -0
- data/lib/splash/daemon/controller.rb +136 -0
- data/lib/splash/daemon/metrics.rb +103 -0
- data/lib/splash/daemon/orchestrator.rb +182 -0
- data/lib/splash/daemon/orchestrator/grammar.rb +76 -0
- data/lib/splash/daemon/orchestrator/hooks.rb +28 -0
- data/lib/splash/dependencies.rb +17 -2
- data/lib/splash/exiter.rb +15 -0
- data/lib/splash/helpers.rb +91 -50
- data/lib/splash/loggers.rb +48 -17
- data/lib/splash/loggers/cli.rb +18 -3
- data/lib/splash/loggers/daemon.rb +23 -4
- data/lib/splash/loggers/dual.rb +35 -2
- data/lib/splash/loggers/web.rb +51 -0
- data/lib/splash/logs.rb +67 -53
- data/lib/splash/processes.rb +83 -0
- data/lib/splash/sequences.rb +105 -0
- data/lib/splash/templates.rb +10 -0
- data/lib/splash/transports.rb +9 -0
- data/lib/splash/transports/rabbitmq.rb +33 -4
- data/lib/splash/webadmin.rb +122 -0
- data/lib/splash/webadmin/api/routes/commands.rb +28 -0
- data/lib/splash/webadmin/api/routes/config.rb +10 -0
- data/lib/splash/webadmin/api/routes/init.rb +2 -0
- data/lib/splash/webadmin/api/routes/logs.rb +59 -0
- data/lib/splash/webadmin/api/routes/process.rb +60 -0
- data/lib/splash/webadmin/main.rb +26 -0
- data/lib/splash/webadmin/portal/controllers/commands.rb +7 -0
- data/lib/splash/webadmin/portal/controllers/documentation.rb +6 -0
- data/lib/splash/webadmin/portal/controllers/home.rb +12 -0
- data/lib/splash/webadmin/portal/controllers/logs.rb +14 -0
- data/lib/splash/webadmin/portal/controllers/notfound.rb +5 -0
- data/lib/splash/webadmin/portal/controllers/processes.rb +14 -0
- data/lib/splash/webadmin/portal/controllers/proxy.rb +28 -0
- data/lib/splash/webadmin/portal/controllers/restclient.rb +19 -0
- data/lib/splash/webadmin/portal/init.rb +11 -0
- data/lib/splash/webadmin/portal/public/css/ultragreen.css +8544 -0
- data/lib/splash/webadmin/portal/public/fonts/FontAwesome.otf +0 -0
- data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.ttf +0 -0
- data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff +0 -0
- data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff2 +0 -0
- data/lib/splash/webadmin/portal/public/images/logo_splash.png +0 -0
- data/lib/splash/webadmin/portal/public/images/logo_splash_reduce.png +0 -0
- data/lib/splash/webadmin/portal/public/images/logo_splash_tiny.png +0 -0
- data/lib/splash/webadmin/portal/views/commands.slim +49 -0
- data/lib/splash/webadmin/portal/views/documentation.slim +3 -0
- data/lib/splash/webadmin/portal/views/home.slim +78 -0
- data/lib/splash/webadmin/portal/views/layout.slim +43 -0
- data/lib/splash/webadmin/portal/views/logs.slim +32 -0
- data/lib/splash/webadmin/portal/views/nav.slim +17 -0
- data/lib/splash/webadmin/portal/views/not_found.slim +3 -0
- data/lib/splash/webadmin/portal/views/processes.slim +29 -0
- data/lib/splash/webadmin/portal/views/proxy.slim +13 -0
- data/lib/splash/webadmin/portal/views/restclient.slim +41 -0
- data/lib/splash/webadmin/portal/views/restclient_result.slim +29 -0
- data/prometheus-splash.gemspec +8 -1
- data/spec/helpers_spec.rb +119 -0
- data/templates/ansible-splash/Vagrantfile +1 -1
- data/templates/ansible-splash/deploy.yml +28 -1
- data/templates/ansible-splash/group_vars/DEV.yml +2 -0
- data/templates/ansible-splash/roles/mq/handlers/main.yml +1 -1
- data/templates/ansible-splash/roles/mq/tasks/main.yml +17 -1
- data/templates/ansible-splash/roles/mq/templates/rabbitmq-env.conf.j2 +13 -0
- data/templates/ansible-splash/roles/splash/handlers/main.yml +4 -0
- data/templates/ansible-splash/roles/splash/tasks/main.yml +25 -1
- data/templates/ansible-splash/roles/splash/templates/logrotate.splash.j2 +11 -0
- data/templates/ansible-splash/roles/splash/templates/splash.yml.j2 +1 -1
- data/templates/splashd.service +1 -1
- data/test.sh +42 -0
- metadata +159 -11
- data/lib/splash/controller.rb +0 -90
- data/lib/splash/orchestrator.rb +0 -100
- data/lib/splash/orchestrator/grammar.rb +0 -53
- data/lib/splash/orchestrator/hooks.rb +0 -16
- data/templates/ansible-splash/inventory.prod +0 -26
data/lib/splash/commands.rb
CHANGED
@@ -1,144 +1,170 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
3
|
+
# base Splash module
|
2
4
|
module Splash
|
3
|
-
class CommandWrapper
|
4
|
-
include Splash::Templates
|
5
|
-
include Splash::Config
|
6
|
-
include Splash::Helpers
|
7
|
-
include Splash::Backends
|
8
|
-
include Splash::Exiter
|
9
|
-
include Splash::Transports
|
10
5
|
|
6
|
+
# Splash Commands module/namespace
|
7
|
+
module Commands
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
# command execution wrapper
|
10
|
+
class CommandWrapper
|
11
|
+
include Splash::Templates
|
12
|
+
include Splash::Config
|
13
|
+
include Splash::Helpers
|
14
|
+
include Splash::Backends
|
15
|
+
include Splash::Exiter
|
16
|
+
include Splash::Transports
|
17
17
|
|
18
|
-
def initialize(name)
|
19
|
-
@config = get_config
|
20
|
-
@url = "http://#{@config.prometheus_pushgateway_host}:#{@config.prometheus_pushgateway_port}"
|
21
|
-
@name = name
|
22
|
-
unless @config.commands.keys.include? @name.to_sym then
|
23
|
-
splash_exit case: :not_found, more: "command #{@name} is not defined in configuration"
|
24
|
-
end
|
25
|
-
end
|
26
18
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
19
|
+
@@registry = Prometheus::Client::Registry::new
|
20
|
+
@@metric_exitcode = Prometheus::Client::Gauge.new(:errorcode, docstring: 'SPLASH metric batch errorcode')
|
21
|
+
@@metric_time = Prometheus::Client::Gauge.new(:exectime, docstring: 'SPLASH metric batch execution time')
|
22
|
+
@@registry.register(@@metric_exitcode)
|
23
|
+
@@registry.register(@@metric_time)
|
31
24
|
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
# Constructor
|
26
|
+
# @param [String] name the name of the command
|
27
|
+
def initialize(name)
|
28
|
+
@config = get_config
|
29
|
+
@url = @config.prometheus_pushgateway_url
|
30
|
+
@name = name
|
31
|
+
unless @config.commands.keys.include? @name.to_sym then
|
32
|
+
splash_exit case: :not_found, more: "command #{@name} is not defined in configuration"
|
33
|
+
end
|
35
34
|
end
|
36
|
-
@@metric_exitcode.set(value)
|
37
|
-
@@metric_time.set(time)
|
38
|
-
hostname = Socket.gethostname
|
39
|
-
Prometheus::Client::Push.new(@name, hostname, @url).add(@@registry)
|
40
|
-
get_logger.ok "Prometheus Gateway notified."
|
41
|
-
return { :case => :quiet_exit}
|
42
|
-
end
|
43
35
|
|
36
|
+
# wrapper for ack command ( return 0 to prometheus via notify)
|
37
|
+
def ack
|
38
|
+
get_logger.info "Sending ack for command : '#{@name}'"
|
39
|
+
notify(0,0)
|
40
|
+
end
|
44
41
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
begin
|
53
|
-
transport = get_default_client
|
54
|
-
if transport.class == Hash and transport.include? :case then
|
55
|
-
return transport
|
56
|
-
else
|
57
|
-
res = transport.execute({ :verb => :execute_command,
|
58
|
-
payload: {:name => @config.commands[@name.to_sym][:delegate_to][:remote_command].to_s},
|
59
|
-
:return_to => "splash.#{Socket.gethostname}.return",
|
60
|
-
:queue => "splash.#{@config.commands[@name.to_sym][:delegate_to][:host]}.input" })
|
61
|
-
exit_code = res[:exit_code]
|
62
|
-
log.receive "return with exitcode #{exit_code}"
|
63
|
-
|
64
|
-
end
|
42
|
+
# send metrics to Prometheus PushGateway
|
43
|
+
# @param [String] value numeric.to_s
|
44
|
+
# @param [String] time execution time numeric.to_s
|
45
|
+
# @return [Hash] Exiter case :quiet_exit
|
46
|
+
def notify(value,time)
|
47
|
+
unless verify_service url: @config.prometheus_pushgateway_url then
|
48
|
+
return { :case => :service_dependence_missing, :more => "Prometheus Notification not send."}
|
65
49
|
end
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
50
|
+
@@metric_exitcode.set(value)
|
51
|
+
@@metric_time.set(time)
|
52
|
+
hostname = Socket.gethostname
|
53
|
+
Prometheus::Client::Push.new(@name, hostname, @url).add(@@registry)
|
54
|
+
return { :case => :quiet_exit}
|
55
|
+
end
|
56
|
+
|
57
|
+
# execute commands or sequence via callbacks, remote or not, notify prometheus, templatize report to backends
|
58
|
+
# the big cheese
|
59
|
+
# @param [Hash] options
|
60
|
+
# @option options [String] :session a number of session in case of Daemon Logger
|
61
|
+
# @option options [String] :hostname for remote execution (can't be use with commands with delegate_to)
|
62
|
+
# @option options [Boolean] :notify to activate prometheus notifications
|
63
|
+
# @option options [Boolean] :trace to activate execution report
|
64
|
+
# @option options [Boolean] :callback to activate sequence and callbacks executions
|
65
|
+
# @return [Hash] Exiter case
|
66
|
+
def call_and_notify(options)
|
67
|
+
log = get_logger
|
68
|
+
session = (options[:session])? options[:session] : get_session
|
69
|
+
acase = { :case => :quiet_exit }
|
70
|
+
exit_code = 0
|
71
|
+
if @config.commands[@name.to_sym][:delegate_to] then
|
72
|
+
return { :case => :options_incompatibility, :more => '--hostname forbidden with delagate commands'} if options[:hostname]
|
73
|
+
log.send "Remote command : #{@name} execution delegate to : #{@config.commands[@name.to_sym][:delegate_to][:host]} as : #{@config.commands[@name.to_sym][:delegate_to][:remote_command]}", session
|
74
|
+
begin
|
75
|
+
transport = get_default_client
|
76
|
+
if transport.class == Hash and transport.include? :case then
|
77
|
+
return transport
|
78
|
+
else
|
79
|
+
res = transport.execute({ :verb => :execute_command,
|
80
|
+
payload: {:name => @config.commands[@name.to_sym][:delegate_to][:remote_command].to_s},
|
81
|
+
:return_to => "splash.#{Socket.gethostname}.return",
|
82
|
+
:queue => "splash.#{@config.commands[@name.to_sym][:delegate_to][:host]}.input" })
|
83
|
+
exit_code = res[:exit_code]
|
84
|
+
log.receive "return with exitcode #{exit_code}", session
|
85
|
+
|
86
|
+
end
|
87
|
+
rescue Interrupt
|
88
|
+
splash_exit case: :interrupt, more: "Remote command exection"
|
77
89
|
end
|
78
|
-
time = Time.now - start
|
79
|
-
exit_code = $?.exitstatus
|
80
90
|
else
|
81
|
-
log.
|
82
|
-
|
83
|
-
|
84
|
-
|
91
|
+
log.info "Executing command : '#{@name}' ", session
|
92
|
+
start = Time.now
|
93
|
+
start_date = DateTime.now.to_s
|
94
|
+
unless options[:trace] then
|
95
|
+
log.item "Traceless execution", session
|
96
|
+
if @config.commands[@name.to_sym][:user] then
|
97
|
+
log.item "Execute with user : #{@config.commands[@name.to_sym][:user]}.", session
|
98
|
+
system("sudo -u #{@config.commands[@name.to_sym][:user]} #{@config.commands[@name.to_sym][:command]} > /dev/null 2>&1")
|
99
|
+
else
|
100
|
+
system("#{@config.commands[@name.to_sym][:command]} > /dev/null 2>&1")
|
101
|
+
end
|
102
|
+
time = Time.now - start
|
103
|
+
exit_code = $?.exitstatus
|
85
104
|
else
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
if options[:notify] then
|
110
|
-
acase = notify(exit_code,time.to_i)
|
111
|
-
else
|
112
|
-
log.item "Without Prometheus notification"
|
113
|
-
end
|
114
|
-
end
|
105
|
+
log.item "Tracefull execution", session
|
106
|
+
if @config.commands[@name.to_sym][:user] then
|
107
|
+
log.item "Execute with user : #{@config.commands[@name.to_sym][:user]}.", session
|
108
|
+
stdout, stderr, status = Open3.capture3("sudo -u #{@config.commands[@name.to_sym][:user]} #{@config.commands[@name.to_sym][:command]}")
|
109
|
+
else
|
110
|
+
stdout, stderr, status = Open3.capture3(@config.commands[@name.to_sym][:command])
|
111
|
+
end
|
112
|
+
time = Time.now - start
|
113
|
+
tp = Template::new(
|
114
|
+
list_token: @config.execution_template_tokens,
|
115
|
+
template_file: @config.execution_template_path)
|
116
|
+
data = Hash::new
|
117
|
+
data[:start_date] = start_date
|
118
|
+
data[:end_date] = DateTime.now.to_s
|
119
|
+
data[:cmd_name] = @name
|
120
|
+
data[:cmd_line] = @config.commands[@name.to_sym][:command]
|
121
|
+
data[:desc] = @config.commands[@name.to_sym][:desc]
|
122
|
+
data[:status] = status.to_s
|
123
|
+
data[:stdout] = stdout
|
124
|
+
data[:stderr] = stderr
|
125
|
+
data[:exec_time] = time.to_s
|
126
|
+
backend = get_backend :execution_trace
|
127
|
+
key = @name
|
115
128
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
log.
|
121
|
-
if
|
122
|
-
|
123
|
-
|
129
|
+
backend.put key: key, value: data.to_yaml
|
130
|
+
exit_code = status.exitstatus
|
131
|
+
end
|
132
|
+
log.ok "Command executed", session
|
133
|
+
log.arrow "exitcode #{exit_code}", session
|
134
|
+
if options[:notify] then
|
135
|
+
acase = notify(exit_code,time.to_i)
|
136
|
+
get_logger.ok "Prometheus Gateway notified.",session
|
124
137
|
else
|
125
|
-
|
138
|
+
log.item "Without Prometheus notification", session
|
126
139
|
end
|
127
140
|
end
|
128
|
-
if
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
141
|
+
if options[:callback] then
|
142
|
+
on_failure = (@config.commands[@name.to_sym][:on_failure])? @config.commands[@name.to_sym][:on_failure] : false
|
143
|
+
on_success = (@config.commands[@name.to_sym][:on_success])? @config.commands[@name.to_sym][:on_success] : false
|
144
|
+
if on_failure and exit_code > 0 then
|
145
|
+
log.item "On failure callback : #{on_failure}", session
|
146
|
+
if @config.commands.keys.include? on_failure then
|
147
|
+
@name = on_failure.to_s
|
148
|
+
call_and_notify options
|
149
|
+
else
|
150
|
+
acase = { :case => :configuration_error , :more => "on_failure call error : #{on_failure} command inexistant."}
|
151
|
+
end
|
135
152
|
end
|
153
|
+
if on_success and exit_code == 0 then
|
154
|
+
log.item "On success callback : #{on_success}", session
|
155
|
+
if @config.commands.keys.include? on_success then
|
156
|
+
@name = on_success.to_s
|
157
|
+
call_and_notify options
|
158
|
+
else
|
159
|
+
acase = { :case => :configuration_error , :more => "on_success call error : #{on_failure} command inexistant."}
|
160
|
+
end
|
161
|
+
end
|
162
|
+
else
|
163
|
+
log.item "Without callbacks sequences", session
|
136
164
|
end
|
137
|
-
|
138
|
-
|
165
|
+
acase[:exit_code] = exit_code
|
166
|
+
return acase
|
139
167
|
end
|
140
|
-
acase[:exit_code] = exit_code
|
141
|
-
return acase
|
142
168
|
end
|
143
169
|
end
|
144
170
|
end
|
data/lib/splash/config.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
Dir[File.dirname(__FILE__) + '/config/*.rb'].each {|file| require file }
|
3
3
|
|
4
|
+
# base Splash Module
|
4
5
|
module Splash
|
6
|
+
|
7
|
+
# Config namespace
|
5
8
|
module Config
|
6
9
|
include Splash::Helpers
|
7
10
|
include Splash::Constants
|
@@ -12,19 +15,37 @@ module Splash
|
|
12
15
|
class Configuration < Hash
|
13
16
|
include Splash::Constants
|
14
17
|
|
18
|
+
# constructor : read config file and map against Constants
|
15
19
|
def initialize(config_file=CONFIG_FILE)
|
16
20
|
config_from_file = readconf config_file
|
17
21
|
self[:version] = VERSION
|
18
22
|
self[:author] = "#{AUTHOR} <#{EMAIL}>"
|
19
23
|
self[:copyright] = "#{COPYRIGHT} #{LICENSE}"
|
20
|
-
|
21
|
-
self[:
|
24
|
+
|
25
|
+
self[:prometheus_url] = (config_from_file[:prometheus][:url])? config_from_file[:prometheus][:url] : PROMETHEUS_URL
|
26
|
+
self[:prometheus_pushgateway_url] = (config_from_file[:prometheus][:pushgateway])? config_from_file[:prometheus][:pushgateway] : PROMETHEUS_PUSHGATEWAY_URL
|
27
|
+
|
22
28
|
self[:daemon_process_name] = (config_from_file[:daemon][:process_name])? config_from_file[:daemon][:process_name] : DAEMON_PROCESS_NAME
|
23
29
|
self[:daemon_logmon_scheduling] = (config_from_file[:daemon][:logmon_scheduling])? config_from_file[:daemon][:logmon_scheduling] : DAEMON_LOGMON_SCHEDULING
|
30
|
+
self[:daemon_metrics_scheduling] = (config_from_file[:daemon][:metrics_scheduling])? config_from_file[:daemon][:metrics_scheduling] : DAEMON_METRICS_SCHEDULING
|
31
|
+
self[:daemon_procmon_scheduling] = (config_from_file[:daemon][:procmon_scheduling])? config_from_file[:daemon][:procmon_scheduling] : DAEMON_PROCMON_SCHEDULING
|
32
|
+
|
33
|
+
|
34
|
+
self[:webadmin_port] = (config_from_file[:webadmin][:port])? config_from_file[:webadmin][:port] : WEBADMIN_PORT
|
35
|
+
self[:webadmin_ip] = (config_from_file[:webadmin][:ip])? config_from_file[:webadmin][:ip] : WEBADMIN_IP
|
36
|
+
self[:webadmin_proxy] = (config_from_file[:webadmin][:proxy])? config_from_file[:webadmin][:proxy] : WEBADMIN_PROXY
|
37
|
+
self[:webadmin_process_name] = (config_from_file[:webadmin][:process_name])? config_from_file[:webadmin][:process_name] : WEBADMIN_PROCESS_NAME
|
38
|
+
self[:webadmin_pid_file] = (config_from_file[:webadmin][:files][:pid_file])? config_from_file[:webadmin][:files][:pid_file] : WEBADMIN_PID_FILE
|
39
|
+
self[:webadmin_stdout_trace] = (config_from_file[:webadmin][:files][:stdout_trace])? config_from_file[:webadmin][:files][:stdout_trace] : WEBADMIN_STDOUT_TRACE
|
40
|
+
self[:webadmin_stderr_trace] = (config_from_file[:webadmin][:files][:stderr_trace])? config_from_file[:webadmin][:files][:stderr_trace] : WEBADMIN_STDERR_TRACE
|
41
|
+
|
42
|
+
|
43
|
+
self[:pid_path] = (config_from_file[:daemon][:paths][:pid_path])? config_from_file[:daemon][:paths][:pid_path] : PID_PATH
|
44
|
+
self[:trace_path] = (config_from_file[:daemon][:paths][:trace_path])? config_from_file[:daemon][:paths][:trace_path] : TRACE_PATH
|
45
|
+
|
46
|
+
|
24
47
|
self[:execution_template_tokens] = EXECUTION_TEMPLATE_TOKENS_LIST
|
25
48
|
self[:execution_template_path] = (config_from_file[:templates][:execution][:path])? config_from_file[:templates][:execution][:path] : EXECUTION_TEMPLATE
|
26
|
-
self[:pid_path] = (config_from_file[:daemon][:paths][:pid_path])? config_from_file[:daemon][:paths][:pid_path] : DAEMON_PID_PATH
|
27
|
-
self[:trace_path] = (config_from_file[:daemon][:paths][:trace_path])? config_from_file[:daemon][:paths][:trace_path] : TRACE_PATH
|
28
49
|
self[:pid_file] = (config_from_file[:daemon][:files][:pid_file])? config_from_file[:daemon][:files][:pid_file] : DAEMON_PID_FILE
|
29
50
|
self[:stdout_trace] = (config_from_file[:daemon][:files][:stdout_trace])? config_from_file[:daemon][:files][:stdout_trace] : DAEMON_STDOUT_TRACE
|
30
51
|
self[:stderr_trace] = (config_from_file[:daemon][:files][:stderr_trace])? config_from_file[:daemon][:files][:stderr_trace] : DAEMON_STDERR_TRACE
|
@@ -33,81 +54,206 @@ module Splash
|
|
33
54
|
self[:backends] = {} ; self[:backends].merge! BACKENDS_STRUCT ; self[:backends].merge! config_from_file[:backends] if config_from_file[:backends]
|
34
55
|
self[:loggers] = {} ; self[:loggers].merge! LOGGERS_STRUCT ; self[:loggers].merge! config_from_file[:loggers] if config_from_file[:loggers]
|
35
56
|
|
57
|
+
self[:processes] = (config_from_file[:processes])? config_from_file[:processes] : {}
|
36
58
|
self[:logs] = (config_from_file[:logs])? config_from_file[:logs] : {}
|
37
59
|
self[:commands] = (config_from_file[:commands])? config_from_file[:commands] : {}
|
60
|
+
self[:sequences] = (config_from_file[:sequences])? config_from_file[:sequences] : {}
|
38
61
|
|
39
62
|
end
|
40
63
|
|
41
64
|
# @!group accessors on configurations Items
|
42
65
|
|
66
|
+
# getter for full Config Hash
|
67
|
+
# @return [Hash]
|
68
|
+
def full
|
69
|
+
return self
|
70
|
+
end
|
71
|
+
|
72
|
+
# getter for loggers Hash Config sample
|
73
|
+
# @return [Hash]
|
43
74
|
def loggers
|
44
75
|
return self[:loggers]
|
45
76
|
end
|
46
77
|
|
78
|
+
# getter for backends Hash Config sample
|
79
|
+
# @return [Hash]
|
47
80
|
def backends
|
48
81
|
return self[:backends]
|
49
82
|
end
|
50
83
|
|
84
|
+
# getter for transports Hash Config sample
|
85
|
+
# @return [Hash]
|
51
86
|
def transports
|
52
87
|
return self[:transports]
|
53
88
|
end
|
54
89
|
|
90
|
+
# getter for daemon_logmon_scheduling Hash Config sample
|
91
|
+
# @return [Hash]
|
55
92
|
def daemon_logmon_scheduling
|
56
93
|
return self[:daemon_logmon_scheduling]
|
57
94
|
end
|
58
95
|
|
96
|
+
# getter for daemon_procmon_scheduling Hash Config sample
|
97
|
+
# @return [Hash]
|
98
|
+
def daemon_procmon_scheduling
|
99
|
+
return self[:daemon_procmon_scheduling]
|
100
|
+
end
|
101
|
+
|
102
|
+
# getter for daemon_metrics_scheduling Hash Config sample
|
103
|
+
# @return [Hash]
|
104
|
+
def daemon_metrics_scheduling
|
105
|
+
return self[:daemon_metrics_scheduling]
|
106
|
+
end
|
107
|
+
|
108
|
+
# getter for execution_template_path Hash Config sample
|
109
|
+
# @return [String]
|
59
110
|
def execution_template_path
|
60
111
|
return self[:execution_template_path]
|
61
112
|
end
|
113
|
+
|
114
|
+
# getter for execution_template_tokens Hash Config sample
|
115
|
+
# @return [Array]
|
62
116
|
def execution_template_tokens
|
63
117
|
return self[:execution_template_tokens]
|
64
118
|
end
|
119
|
+
|
120
|
+
|
121
|
+
# getter for webadmin_port Hash Config sample
|
122
|
+
# @return [Fixnum]
|
123
|
+
def webadmin_port
|
124
|
+
return self[:webadmin_port]
|
125
|
+
end
|
126
|
+
|
127
|
+
# getter for webadmin_ip Hash Config sample
|
128
|
+
# @return [String]
|
129
|
+
def webadmin_ip
|
130
|
+
return self[:webadmin_ip]
|
131
|
+
end
|
132
|
+
|
133
|
+
# getter for webadmin_proxy Hash Config sample
|
134
|
+
# @return [TrueClass|FalseClass]
|
135
|
+
def webadmin_proxy
|
136
|
+
return self[:webadmin_proxy]
|
137
|
+
end
|
138
|
+
|
139
|
+
# getter for webadmin_process_name Config sample
|
140
|
+
# @return [String]
|
141
|
+
def webadmin_process_name
|
142
|
+
return self[:webadmin_process_name]
|
143
|
+
end
|
144
|
+
|
145
|
+
# getter for webadmin_full_pid_path Config sample
|
146
|
+
# @return [String]
|
147
|
+
def webadmin_full_pid_path
|
148
|
+
return "#{self[:pid_path]}/#{self[:webadmin_pid_file]}"
|
149
|
+
end
|
150
|
+
|
151
|
+
# getter for webadmin_full_stdout_trace_path Config sample
|
152
|
+
# @return [String]
|
153
|
+
def webadmin_full_stdout_trace_path
|
154
|
+
return "#{self[:trace_path]}/#{self[:webadmin_stdout_trace]}"
|
155
|
+
end
|
156
|
+
|
157
|
+
# getter for webadmin_full_stderr_trace_path Config sample
|
158
|
+
# @return [String]
|
159
|
+
def webadmin_full_stderr_trace_path
|
160
|
+
return "#{self[:trace_path]}/#{self[:webadmin_stderr_trace]}"
|
161
|
+
end
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
# getter for logs Hash Config sample
|
167
|
+
# @return [Hash]
|
65
168
|
def logs
|
66
169
|
return self[:logs]
|
67
170
|
end
|
68
171
|
|
172
|
+
# getter for commands Hash Config sample
|
173
|
+
# @return [Hash]
|
69
174
|
def commands
|
70
175
|
return self[:commands]
|
71
176
|
end
|
72
177
|
|
178
|
+
# getter for processes Hash Config sample
|
179
|
+
# @return [Hash]
|
180
|
+
def processes
|
181
|
+
return self[:processes]
|
182
|
+
end
|
183
|
+
|
184
|
+
# getter for sequences Hash Config sample
|
185
|
+
# @return [Hash]
|
186
|
+
def sequences
|
187
|
+
return self[:sequences]
|
188
|
+
end
|
189
|
+
|
190
|
+
# getter for author Config sample
|
191
|
+
# @return [String]
|
73
192
|
def author
|
74
193
|
return self[:author]
|
75
194
|
end
|
76
195
|
|
196
|
+
# getter for copyright Config sample
|
197
|
+
# @return [String]
|
77
198
|
def copyright
|
78
199
|
return self[:copyright]
|
79
200
|
end
|
80
201
|
|
202
|
+
# getter for version Config sample
|
203
|
+
# @return [String]
|
81
204
|
def version
|
82
205
|
return self[:version]
|
83
206
|
end
|
84
207
|
|
85
|
-
|
86
|
-
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
# getter for prometheus_pushgateway_url Config sample
|
213
|
+
# @return [String]
|
214
|
+
def prometheus_pushgateway_url
|
215
|
+
return self[:prometheus_pushgateway_url]
|
87
216
|
end
|
88
217
|
|
89
|
-
|
90
|
-
|
218
|
+
# getter for prometheus_url Config sample
|
219
|
+
# @return [String]
|
220
|
+
def prometheus_url
|
221
|
+
return self[:prometheus_url]
|
91
222
|
end
|
92
|
-
|
93
|
-
|
223
|
+
|
224
|
+
|
225
|
+
# getter for daemon_process_name Config sample
|
226
|
+
# @return [String]
|
227
|
+
def daemon_process_name
|
228
|
+
return self[:daemon_process_name]
|
94
229
|
end
|
95
230
|
|
96
|
-
|
231
|
+
|
232
|
+
# getter for daemon_full_pid_path Config sample
|
233
|
+
# @return [String]
|
234
|
+
def daemon_full_pid_path
|
97
235
|
return "#{self[:pid_path]}/#{self[:pid_file]}"
|
98
236
|
end
|
99
237
|
|
100
|
-
|
238
|
+
# getter for daemon_full_stdout_trace_path Config sample
|
239
|
+
# @return [String]
|
240
|
+
def daemon_full_stdout_trace_path
|
101
241
|
return "#{self[:trace_path]}/#{self[:stdout_trace]}"
|
102
242
|
end
|
103
243
|
|
104
|
-
|
244
|
+
# getter for daemon_full_stderr_trace_path Config sample
|
245
|
+
# @return [String]
|
246
|
+
def daemon_full_stderr_trace_path
|
105
247
|
return "#{self[:trace_path]}/#{self[:stderr_trace]}"
|
106
248
|
end
|
107
249
|
|
108
250
|
# @!endgroup
|
109
251
|
|
110
252
|
private
|
253
|
+
|
254
|
+
# read config file
|
255
|
+
# @param [String] file default from CONFIG_FILE
|
256
|
+
# @return [Hash] The config global Hash from YAML
|
111
257
|
def readconf(file = CONFIG_FILE)
|
112
258
|
return YAML.load_file(file)[:splash]
|
113
259
|
end
|
@@ -115,14 +261,23 @@ module Splash
|
|
115
261
|
|
116
262
|
end
|
117
263
|
|
264
|
+
|
265
|
+
|
266
|
+
@@config=nil
|
267
|
+
|
118
268
|
# factory of Configuration Class instance
|
119
269
|
# @param [String] config_file the path of the YAML Config file
|
120
270
|
# @return [SPlash::Config::Configuration]
|
121
271
|
def get_config(config_file=CONFIG_FILE)
|
122
|
-
return Configuration::new
|
272
|
+
return @@config ||= Configuration::new(config_file)
|
123
273
|
end
|
124
274
|
|
125
|
-
|
275
|
+
# reset of Configuration Class instance
|
276
|
+
# @param [String] config_file the path of the YAML Config file
|
277
|
+
# @return [SPlash::Config::Configuration]
|
278
|
+
def rehash_config(config_file=CONFIG_FILE)
|
279
|
+
return @@config = Configuration::new(config_file)
|
280
|
+
end
|
126
281
|
|
127
282
|
|
128
283
|
end
|