prometheus-splash 0.5.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -0
- data/README.md +58 -60
- data/bin/splash +3 -0
- data/config/splash.yml +106 -10
- data/lib/splash/backends.rb +7 -0
- data/lib/splash/backends/file.rb +36 -0
- data/lib/splash/backends/redis.rb +44 -1
- data/lib/splash/cli.rb +16 -4
- data/lib/splash/cli/commands.rb +12 -5
- data/lib/splash/cli/config.rb +9 -1
- data/lib/splash/cli/daemon.rb +49 -2
- data/lib/splash/cli/documentation.rb +5 -2
- data/lib/splash/cli/logs.rb +21 -13
- data/lib/splash/cli/process.rb +103 -0
- data/lib/splash/cli/sequences.rb +114 -0
- data/lib/splash/cli/transfers.rb +206 -0
- data/lib/splash/cli/webadmin.rb +46 -0
- data/lib/splash/commands.rb +26 -4
- data/lib/splash/config.rb +184 -23
- data/lib/splash/config/flush.rb +9 -1
- data/lib/splash/config/sanitycheck.rb +7 -2
- data/lib/splash/config/service.rb +8 -1
- data/lib/splash/config/setup.rb +8 -3
- data/lib/splash/constants.rb +41 -10
- data/lib/splash/daemon.rb +5 -1
- data/lib/splash/daemon/controller.rb +31 -11
- data/lib/splash/daemon/metrics.rb +47 -22
- data/lib/splash/daemon/orchestrator.rb +141 -36
- data/lib/splash/daemon/orchestrator/grammar.rb +40 -5
- data/lib/splash/daemon/orchestrator/hooks.rb +10 -0
- data/lib/splash/dependencies.rb +19 -0
- data/lib/splash/exiter.rb +14 -0
- data/lib/splash/helpers.rb +93 -46
- data/lib/splash/loggers.rb +30 -4
- data/lib/splash/loggers/cli.rb +18 -11
- data/lib/splash/loggers/daemon.rb +14 -3
- data/lib/splash/loggers/dual.rb +14 -1
- data/lib/splash/loggers/web.rb +51 -0
- data/lib/splash/logs.rb +16 -5
- data/lib/splash/processes.rb +83 -0
- data/lib/splash/sequences.rb +105 -0
- data/lib/splash/templates.rb +10 -0
- data/lib/splash/transfers.rb +224 -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/api/routes/sequences.rb +28 -0
- data/lib/splash/webadmin/main.rb +27 -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 +31 -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 +36 -0
- data/lib/splash/webadmin/portal/controllers/restclient.rb +19 -0
- data/lib/splash/webadmin/portal/controllers/sequences.rb +7 -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 +123 -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 +16 -0
- data/lib/splash/webadmin/portal/views/restclient.slim +41 -0
- data/lib/splash/webadmin/portal/views/restclient_result.slim +29 -0
- data/lib/splash/webadmin/portal/views/sequences.slim +50 -0
- data/prometheus-splash.gemspec +12 -3
- data/spec/helpers_spec.rb +119 -0
- metadata +196 -8
data/lib/splash/commands.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
3
|
+
# base Splash module
|
2
4
|
module Splash
|
5
|
+
|
6
|
+
# Splash Commands module/namespace
|
3
7
|
module Commands
|
8
|
+
|
9
|
+
# command execution wrapper
|
4
10
|
class CommandWrapper
|
5
11
|
include Splash::Templates
|
6
12
|
include Splash::Config
|
@@ -16,22 +22,29 @@ module Splash
|
|
16
22
|
@@registry.register(@@metric_exitcode)
|
17
23
|
@@registry.register(@@metric_time)
|
18
24
|
|
25
|
+
# Constructor
|
26
|
+
# @param [String] name the name of the command
|
19
27
|
def initialize(name)
|
20
28
|
@config = get_config
|
21
|
-
@url =
|
29
|
+
@url = @config.prometheus_pushgateway_url
|
22
30
|
@name = name
|
23
31
|
unless @config.commands.keys.include? @name.to_sym then
|
24
32
|
splash_exit case: :not_found, more: "command #{@name} is not defined in configuration"
|
25
33
|
end
|
26
34
|
end
|
27
35
|
|
36
|
+
# wrapper for ack command ( return 0 to prometheus via notify)
|
28
37
|
def ack
|
29
38
|
get_logger.info "Sending ack for command : '#{@name}'"
|
30
39
|
notify(0,0)
|
31
40
|
end
|
32
41
|
|
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
|
33
46
|
def notify(value,time)
|
34
|
-
unless verify_service
|
47
|
+
unless verify_service url: @config.prometheus_pushgateway_url then
|
35
48
|
return { :case => :service_dependence_missing, :more => "Prometheus Notification not send."}
|
36
49
|
end
|
37
50
|
@@metric_exitcode.set(value)
|
@@ -41,7 +54,15 @@ module Splash
|
|
41
54
|
return { :case => :quiet_exit}
|
42
55
|
end
|
43
56
|
|
44
|
-
|
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
|
45
66
|
def call_and_notify(options)
|
46
67
|
log = get_logger
|
47
68
|
session = (options[:session])? options[:session] : get_session
|
@@ -63,6 +84,8 @@ module Splash
|
|
63
84
|
log.receive "return with exitcode #{exit_code}", session
|
64
85
|
|
65
86
|
end
|
87
|
+
rescue Interrupt
|
88
|
+
splash_exit case: :interrupt, more: "Remote command exection"
|
66
89
|
end
|
67
90
|
else
|
68
91
|
log.info "Executing command : '#{@name}' ", session
|
@@ -115,7 +138,6 @@ module Splash
|
|
115
138
|
log.item "Without Prometheus notification", session
|
116
139
|
end
|
117
140
|
end
|
118
|
-
|
119
141
|
if options[:callback] then
|
120
142
|
on_failure = (@config.commands[@name.to_sym][:on_failure])? @config.commands[@name.to_sym][:on_failure] : false
|
121
143
|
on_success = (@config.commands[@name.to_sym][:on_success])? @config.commands[@name.to_sym][:on_success] : false
|
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,107 +15,259 @@ 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
|
+
self[:prometheus_alertmanager_url] = (config_from_file[:prometheus][:alertmanager])? config_from_file[:prometheus][:alertmanager] : PROMETHEUS_ALERTMANAGER_URL
|
28
|
+
|
22
29
|
self[:daemon_process_name] = (config_from_file[:daemon][:process_name])? config_from_file[:daemon][:process_name] : DAEMON_PROCESS_NAME
|
23
30
|
self[:daemon_logmon_scheduling] = (config_from_file[:daemon][:logmon_scheduling])? config_from_file[:daemon][:logmon_scheduling] : DAEMON_LOGMON_SCHEDULING
|
24
31
|
self[:daemon_metrics_scheduling] = (config_from_file[:daemon][:metrics_scheduling])? config_from_file[:daemon][:metrics_scheduling] : DAEMON_METRICS_SCHEDULING
|
32
|
+
self[:daemon_procmon_scheduling] = (config_from_file[:daemon][:procmon_scheduling])? config_from_file[:daemon][:procmon_scheduling] : DAEMON_PROCMON_SCHEDULING
|
33
|
+
self[:daemon_pid_file] = (config_from_file[:daemon][:files][:pid_file])? config_from_file[:daemon][:files][:pid_file] : DAEMON_PID_FILE
|
34
|
+
self[:daemon_stdout_trace] = (config_from_file[:daemon][:files][:stdout_trace])? config_from_file[:daemon][:files][:stdout_trace] : DAEMON_STDOUT_TRACE
|
35
|
+
self[:daemon_stderr_trace] = (config_from_file[:daemon][:files][:stderr_trace])? config_from_file[:daemon][:files][:stderr_trace] : DAEMON_STDERR_TRACE
|
36
|
+
|
37
|
+
|
38
|
+
self[:webadmin_port] = (config_from_file[:webadmin][:port])? config_from_file[:webadmin][:port] : WEBADMIN_PORT
|
39
|
+
self[:webadmin_ip] = (config_from_file[:webadmin][:ip])? config_from_file[:webadmin][:ip] : WEBADMIN_IP
|
40
|
+
self[:webadmin_proxy] = (config_from_file[:webadmin][:proxy])? config_from_file[:webadmin][:proxy] : WEBADMIN_PROXY
|
41
|
+
self[:webadmin_process_name] = (config_from_file[:webadmin][:process_name])? config_from_file[:webadmin][:process_name] : WEBADMIN_PROCESS_NAME
|
42
|
+
self[:webadmin_pid_file] = (config_from_file[:webadmin][:files][:pid_file])? config_from_file[:webadmin][:files][:pid_file] : WEBADMIN_PID_FILE
|
43
|
+
self[:webadmin_stdout_trace] = (config_from_file[:webadmin][:files][:stdout_trace])? config_from_file[:webadmin][:files][:stdout_trace] : WEBADMIN_STDOUT_TRACE
|
44
|
+
self[:webadmin_stderr_trace] = (config_from_file[:webadmin][:files][:stderr_trace])? config_from_file[:webadmin][:files][:stderr_trace] : WEBADMIN_STDERR_TRACE
|
45
|
+
|
46
|
+
|
47
|
+
self[:pid_path] = (config_from_file[:paths][:pid_path])? config_from_file[:paths][:pid_path] : PID_PATH
|
48
|
+
self[:trace_path] = (config_from_file[:paths][:trace_path])? config_from_file[:paths][:trace_path] : TRACE_PATH
|
49
|
+
|
50
|
+
|
25
51
|
self[:execution_template_tokens] = EXECUTION_TEMPLATE_TOKENS_LIST
|
26
52
|
self[:execution_template_path] = (config_from_file[:templates][:execution][:path])? config_from_file[:templates][:execution][:path] : EXECUTION_TEMPLATE
|
27
|
-
self[:pid_path] = (config_from_file[:daemon][:paths][:pid_path])? config_from_file[:daemon][:paths][:pid_path] : DAEMON_PID_PATH
|
28
|
-
self[:trace_path] = (config_from_file[:daemon][:paths][:trace_path])? config_from_file[:daemon][:paths][:trace_path] : TRACE_PATH
|
29
|
-
self[:pid_file] = (config_from_file[:daemon][:files][:pid_file])? config_from_file[:daemon][:files][:pid_file] : DAEMON_PID_FILE
|
30
|
-
self[:stdout_trace] = (config_from_file[:daemon][:files][:stdout_trace])? config_from_file[:daemon][:files][:stdout_trace] : DAEMON_STDOUT_TRACE
|
31
|
-
self[:stderr_trace] = (config_from_file[:daemon][:files][:stderr_trace])? config_from_file[:daemon][:files][:stderr_trace] : DAEMON_STDERR_TRACE
|
32
53
|
|
33
54
|
self[:transports] = {} ; self[:transports].merge! TRANSPORTS_STRUCT ; self[:transports].merge! config_from_file[:transports] if config_from_file[:transports]
|
34
55
|
self[:backends] = {} ; self[:backends].merge! BACKENDS_STRUCT ; self[:backends].merge! config_from_file[:backends] if config_from_file[:backends]
|
35
56
|
self[:loggers] = {} ; self[:loggers].merge! LOGGERS_STRUCT ; self[:loggers].merge! config_from_file[:loggers] if config_from_file[:loggers]
|
36
57
|
|
58
|
+
self[:processes] = (config_from_file[:processes])? config_from_file[:processes] : {}
|
37
59
|
self[:logs] = (config_from_file[:logs])? config_from_file[:logs] : {}
|
38
60
|
self[:commands] = (config_from_file[:commands])? config_from_file[:commands] : {}
|
61
|
+
self[:sequences] = (config_from_file[:sequences])? config_from_file[:sequences] : {}
|
62
|
+
self[:transfers] = (config_from_file[:transfers])? config_from_file[:transfers] : {}
|
39
63
|
|
40
64
|
end
|
41
65
|
|
42
66
|
# @!group accessors on configurations Items
|
43
67
|
|
68
|
+
# getter for full Config Hash
|
69
|
+
# @return [Hash]
|
70
|
+
def full
|
71
|
+
return self
|
72
|
+
end
|
73
|
+
|
74
|
+
# getter for loggers Hash Config sample
|
75
|
+
# @return [Hash]
|
44
76
|
def loggers
|
45
77
|
return self[:loggers]
|
46
78
|
end
|
47
79
|
|
80
|
+
# getter for backends Hash Config sample
|
81
|
+
# @return [Hash]
|
48
82
|
def backends
|
49
83
|
return self[:backends]
|
50
84
|
end
|
51
85
|
|
86
|
+
# getter for transports Hash Config sample
|
87
|
+
# @return [Hash]
|
52
88
|
def transports
|
53
89
|
return self[:transports]
|
54
90
|
end
|
55
91
|
|
92
|
+
# getter for transfers Hash Config sample
|
93
|
+
# @return [Hash]
|
94
|
+
def transfers
|
95
|
+
return self[:transfers]
|
96
|
+
end
|
97
|
+
|
98
|
+
# getter for daemon_logmon_scheduling Hash Config sample
|
99
|
+
# @return [Hash]
|
56
100
|
def daemon_logmon_scheduling
|
57
101
|
return self[:daemon_logmon_scheduling]
|
58
102
|
end
|
59
103
|
|
104
|
+
# getter for daemon_procmon_scheduling Hash Config sample
|
105
|
+
# @return [Hash]
|
106
|
+
def daemon_procmon_scheduling
|
107
|
+
return self[:daemon_procmon_scheduling]
|
108
|
+
end
|
109
|
+
|
110
|
+
# getter for daemon_metrics_scheduling Hash Config sample
|
111
|
+
# @return [Hash]
|
60
112
|
def daemon_metrics_scheduling
|
61
113
|
return self[:daemon_metrics_scheduling]
|
62
114
|
end
|
63
115
|
|
116
|
+
# getter for daemon_process_name Config sample
|
117
|
+
# @return [String]
|
118
|
+
def daemon_process_name
|
119
|
+
return self[:daemon_process_name]
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
# getter for daemon_full_pid_path Config sample
|
124
|
+
# @return [String]
|
125
|
+
def daemon_full_pid_path
|
126
|
+
return "#{self[:pid_path]}/#{self[:daemon_pid_file]}"
|
127
|
+
end
|
128
|
+
|
129
|
+
# getter for daemon_full_stdout_trace_path Config sample
|
130
|
+
# @return [String]
|
131
|
+
def daemon_full_stdout_trace_path
|
132
|
+
return "#{self[:trace_path]}/#{self[:daemon_stdout_trace]}"
|
133
|
+
end
|
134
|
+
|
135
|
+
# getter for daemon_full_stderr_trace_path Config sample
|
136
|
+
# @return [String]
|
137
|
+
def daemon_full_stderr_trace_path
|
138
|
+
return "#{self[:trace_path]}/#{self[:daemon_stderr_trace]}"
|
139
|
+
end
|
140
|
+
|
141
|
+
# getter for execution_template_path Hash Config sample
|
142
|
+
# @return [String]
|
64
143
|
def execution_template_path
|
65
144
|
return self[:execution_template_path]
|
66
145
|
end
|
146
|
+
|
147
|
+
# getter for execution_template_tokens Hash Config sample
|
148
|
+
# @return [Array]
|
67
149
|
def execution_template_tokens
|
68
150
|
return self[:execution_template_tokens]
|
69
151
|
end
|
152
|
+
|
153
|
+
|
154
|
+
# getter for webadmin_port Hash Config sample
|
155
|
+
# @return [Fixnum]
|
156
|
+
def webadmin_port
|
157
|
+
return self[:webadmin_port]
|
158
|
+
end
|
159
|
+
|
160
|
+
# getter for webadmin_ip Hash Config sample
|
161
|
+
# @return [String]
|
162
|
+
def webadmin_ip
|
163
|
+
return self[:webadmin_ip]
|
164
|
+
end
|
165
|
+
|
166
|
+
# getter for webadmin_proxy Hash Config sample
|
167
|
+
# @return [TrueClass|FalseClass]
|
168
|
+
def webadmin_proxy
|
169
|
+
return self[:webadmin_proxy]
|
170
|
+
end
|
171
|
+
|
172
|
+
# getter for webadmin_process_name Config sample
|
173
|
+
# @return [String]
|
174
|
+
def webadmin_process_name
|
175
|
+
return self[:webadmin_process_name]
|
176
|
+
end
|
177
|
+
|
178
|
+
# getter for webadmin_full_pid_path Config sample
|
179
|
+
# @return [String]
|
180
|
+
def webadmin_full_pid_path
|
181
|
+
return "#{self[:pid_path]}/#{self[:webadmin_pid_file]}"
|
182
|
+
end
|
183
|
+
|
184
|
+
# getter for webadmin_full_stdout_trace_path Config sample
|
185
|
+
# @return [String]
|
186
|
+
def webadmin_full_stdout_trace_path
|
187
|
+
return "#{self[:trace_path]}/#{self[:webadmin_stdout_trace]}"
|
188
|
+
end
|
189
|
+
|
190
|
+
# getter for webadmin_full_stderr_trace_path Config sample
|
191
|
+
# @return [String]
|
192
|
+
def webadmin_full_stderr_trace_path
|
193
|
+
return "#{self[:trace_path]}/#{self[:webadmin_stderr_trace]}"
|
194
|
+
end
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
# getter for logs Hash Config sample
|
200
|
+
# @return [Hash]
|
70
201
|
def logs
|
71
202
|
return self[:logs]
|
72
203
|
end
|
73
204
|
|
205
|
+
# getter for commands Hash Config sample
|
206
|
+
# @return [Hash]
|
74
207
|
def commands
|
75
208
|
return self[:commands]
|
76
209
|
end
|
77
210
|
|
211
|
+
# getter for processes Hash Config sample
|
212
|
+
# @return [Hash]
|
213
|
+
def processes
|
214
|
+
return self[:processes]
|
215
|
+
end
|
216
|
+
|
217
|
+
# getter for sequences Hash Config sample
|
218
|
+
# @return [Hash]
|
219
|
+
def sequences
|
220
|
+
return self[:sequences]
|
221
|
+
end
|
222
|
+
|
223
|
+
# getter for author Config sample
|
224
|
+
# @return [String]
|
78
225
|
def author
|
79
226
|
return self[:author]
|
80
227
|
end
|
81
228
|
|
229
|
+
# getter for copyright Config sample
|
230
|
+
# @return [String]
|
82
231
|
def copyright
|
83
232
|
return self[:copyright]
|
84
233
|
end
|
85
234
|
|
235
|
+
# getter for version Config sample
|
236
|
+
# @return [String]
|
86
237
|
def version
|
87
238
|
return self[:version]
|
88
239
|
end
|
89
240
|
|
90
|
-
def daemon_process_name
|
91
|
-
return self[:daemon_process_name]
|
92
|
-
end
|
93
241
|
|
94
|
-
def prometheus_pushgateway_host
|
95
|
-
return self[:prometheus_pushgateway_host]
|
96
|
-
end
|
97
|
-
def prometheus_pushgateway_port
|
98
|
-
return self[:prometheus_pushgateway_port]
|
99
|
-
end
|
100
242
|
|
101
|
-
|
102
|
-
|
243
|
+
|
244
|
+
|
245
|
+
# getter for prometheus_pushgateway_url Config sample
|
246
|
+
# @return [String]
|
247
|
+
def prometheus_pushgateway_url
|
248
|
+
return self[:prometheus_pushgateway_url]
|
103
249
|
end
|
104
250
|
|
105
|
-
|
106
|
-
|
251
|
+
# getter for prometheus_alertmanager_url Config sample
|
252
|
+
# @return [String]
|
253
|
+
def prometheus_alertmanager_url
|
254
|
+
return self[:prometheus_alertmanager_url]
|
107
255
|
end
|
108
256
|
|
109
|
-
|
110
|
-
|
257
|
+
|
258
|
+
# getter for prometheus_url Config sample
|
259
|
+
# @return [String]
|
260
|
+
def prometheus_url
|
261
|
+
return self[:prometheus_url]
|
111
262
|
end
|
112
263
|
|
113
264
|
# @!endgroup
|
114
265
|
|
115
266
|
private
|
267
|
+
|
268
|
+
# read config file
|
269
|
+
# @param [String] file default from CONFIG_FILE
|
270
|
+
# @return [Hash] The config global Hash from YAML
|
116
271
|
def readconf(file = CONFIG_FILE)
|
117
272
|
return YAML.load_file(file)[:splash]
|
118
273
|
end
|
@@ -123,6 +278,7 @@ module Splash
|
|
123
278
|
|
124
279
|
|
125
280
|
@@config=nil
|
281
|
+
|
126
282
|
# factory of Configuration Class instance
|
127
283
|
# @param [String] config_file the path of the YAML Config file
|
128
284
|
# @return [SPlash::Config::Configuration]
|
@@ -130,7 +286,12 @@ module Splash
|
|
130
286
|
return @@config ||= Configuration::new(config_file)
|
131
287
|
end
|
132
288
|
|
133
|
-
|
289
|
+
# reset of Configuration Class instance
|
290
|
+
# @param [String] config_file the path of the YAML Config file
|
291
|
+
# @return [SPlash::Config::Configuration]
|
292
|
+
def rehash_config(config_file=CONFIG_FILE)
|
293
|
+
return @@config = Configuration::new(config_file)
|
294
|
+
end
|
134
295
|
|
135
296
|
|
136
297
|
end
|
data/lib/splash/config/flush.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
# Base Splash module
|
1
4
|
module Splash
|
5
|
+
|
6
|
+
# module for Configuration utilities
|
2
7
|
module ConfigUtilities
|
3
8
|
include Splash::Constants
|
4
9
|
|
5
|
-
|
10
|
+
# clean backend action method
|
11
|
+
# @param [Hash] options
|
12
|
+
# @option options [Symbol] :name the name of the backend (:redis, :file)
|
13
|
+
# @return [Hash] An Exiter case hash (:quiet_exit or :configuration_error)
|
6
14
|
def flush_backend(options ={})
|
7
15
|
config = get_config
|
8
16
|
self.extend Splash::Backends
|
@@ -1,12 +1,17 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
3
|
+
# Base Splash module
|
2
4
|
module Splash
|
5
|
+
|
6
|
+
# moudle for Configuration utilities
|
3
7
|
module ConfigUtilities
|
4
8
|
include Splash::Constants
|
5
9
|
|
6
10
|
|
7
11
|
|
8
12
|
# Sanitycheck action method for testing installation of Splash
|
9
|
-
# @
|
13
|
+
# @param [Hash] options
|
14
|
+
# @return [Hash] An Exiter case hash (:splash_sanitycheck_success or :splash_sanitycheck_error)
|
10
15
|
def checkconfig(options ={})
|
11
16
|
self.extend Splash::Loggers
|
12
17
|
log = get_logger
|
@@ -45,7 +50,7 @@ module Splash
|
|
45
50
|
end
|
46
51
|
|
47
52
|
target = "Prometheus PushGateway Service running"
|
48
|
-
if verify_service
|
53
|
+
if verify_service url: config.prometheus_pushgateway_url then
|
49
54
|
log.ok target
|
50
55
|
else
|
51
56
|
log.ko target
|
@@ -1,11 +1,18 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
# Base Splash module
|
4
4
|
module Splash
|
5
|
+
|
6
|
+
# moudle for Configuration utilities
|
5
7
|
module ConfigUtilities
|
6
8
|
include Splash::Constants
|
7
9
|
include Splash::Helpers
|
8
10
|
|
11
|
+
|
12
|
+
# clean backend configured
|
13
|
+
# @param [Hash] options
|
14
|
+
# @option options [Symbol] :name the name of the backend (:redis, :file)
|
15
|
+
# @return [Hash] An Exiter case hash (:quiet_exit or :configuration_error)
|
9
16
|
def addservice(options = {})
|
10
17
|
local_service_file = search_file_in_gem "prometheus-splash", "templates/splashd.service"
|
11
18
|
config = get_config
|