prometheus-splash 0.6.1 → 0.8.3
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 +43 -1
- data/README.md +1 -1
- data/config/splash.yml +45 -5
- data/lib/splash/backends.rb +1 -0
- data/lib/splash/cli.rb +2 -1
- data/lib/splash/cli/commands.rb +125 -5
- data/lib/splash/cli/daemon.rb +41 -1
- data/lib/splash/cli/logs.rb +111 -47
- data/lib/splash/cli/process.rb +112 -52
- data/lib/splash/cli/sequences.rb +2 -0
- data/lib/splash/cli/transfers.rb +213 -0
- data/lib/splash/cli/webadmin.rb +3 -3
- data/lib/splash/commands.rb +85 -19
- data/lib/splash/config.rb +142 -52
- data/lib/splash/constants.rb +7 -3
- data/lib/splash/daemon/metrics.rb +6 -6
- data/lib/splash/daemon/orchestrator.rb +76 -36
- data/lib/splash/daemon/orchestrator/grammar.rb +16 -1
- data/lib/splash/dependencies.rb +6 -1
- data/lib/splash/exiter.rb +1 -1
- data/lib/splash/helpers.rb +12 -3
- data/lib/splash/loggers/cli.rb +2 -10
- data/lib/splash/logs.rb +90 -16
- data/lib/splash/processes.rb +87 -16
- data/lib/splash/transfers.rb +229 -0
- data/lib/splash/webadmin.rb +3 -3
- data/lib/splash/webadmin/api/routes/commands.rb +2 -2
- data/lib/splash/webadmin/api/routes/config.rb +53 -2
- data/lib/splash/webadmin/api/routes/logs.rb +32 -17
- data/lib/splash/webadmin/api/routes/process.rb +4 -4
- data/lib/splash/webadmin/api/routes/sequences.rb +28 -0
- data/lib/splash/webadmin/main.rb +1 -0
- data/lib/splash/webadmin/portal/controllers/commands.rb +2 -0
- data/lib/splash/webadmin/portal/controllers/documentation.rb +3 -1
- data/lib/splash/webadmin/portal/controllers/home.rb +24 -0
- data/lib/splash/webadmin/portal/controllers/logs.rb +44 -1
- data/lib/splash/webadmin/portal/controllers/processes.rb +2 -0
- data/lib/splash/webadmin/portal/controllers/proxy.rb +13 -4
- data/lib/splash/webadmin/portal/controllers/restclient.rb +7 -2
- data/lib/splash/webadmin/portal/controllers/sequences.rb +9 -0
- data/lib/splash/webadmin/portal/init.rb +2 -2
- data/lib/splash/webadmin/portal/public/css/ultragreen.css +6 -0
- data/lib/splash/webadmin/portal/public/favicon.ico +0 -0
- data/lib/splash/webadmin/portal/views/commands.slim +1 -1
- data/lib/splash/webadmin/portal/views/documentation.slim +1 -1
- data/lib/splash/webadmin/portal/views/home.slim +53 -9
- data/lib/splash/webadmin/portal/views/layout.slim +2 -2
- data/lib/splash/webadmin/portal/views/logs.slim +68 -21
- data/lib/splash/webadmin/portal/views/logs_form.slim +24 -0
- data/lib/splash/webadmin/portal/views/nav.slim +1 -1
- data/lib/splash/webadmin/portal/views/not_found.slim +1 -1
- data/lib/splash/webadmin/portal/views/processes.slim +1 -1
- data/lib/splash/webadmin/portal/views/proxy.slim +5 -2
- data/lib/splash/webadmin/portal/views/restclient.slim +7 -4
- data/lib/splash/webadmin/portal/views/restclient_result.slim +24 -20
- data/lib/splash/webadmin/portal/views/sequences.slim +50 -0
- data/prometheus-splash.gemspec +7 -4
- data/ultragreen_roodi_coding_convention.yml +4 -4
- metadata +75 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7da11971391d77ffc6bf37228938bba227880e8748ce605cfa3c33ab16855121
|
4
|
+
data.tar.gz: f3a1b196f64ea586a2d604c799ca1a11f9f966471e8938ba56803b1067852b85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 729ffa39b3dcafb9c70631d6c0c02dc3ba67ce78c1d97fff9b665bff3b1ff311aaa24ed79f43cfb414550da022f8cc7f7cc40de96928c1c44731bd9211e36932
|
7
|
+
data.tar.gz: 85dd4b338e46736d8bc68d3b33b5325f18c6276bf2a1e90ac3731e0bb86741d25f1574f333f1a77f23889bb0de8bcf5b2f763bb75bf1c0e4f75c5b00910ddd86
|
data/CHANGELOG.md
CHANGED
@@ -124,4 +124,46 @@
|
|
124
124
|
### FEATURE
|
125
125
|
|
126
126
|
* processes monitoring #23
|
127
|
-
|
127
|
+
|
128
|
+
## V 0.6.0 2020/10/10
|
129
|
+
|
130
|
+
### FEATURE
|
131
|
+
|
132
|
+
* read only WebAdmin (Major update)
|
133
|
+
* API REST
|
134
|
+
* refactoring
|
135
|
+
|
136
|
+
## V 0.7.0
|
137
|
+
|
138
|
+
### FEATURE
|
139
|
+
|
140
|
+
* sequences
|
141
|
+
* API sequences
|
142
|
+
* UI sequences
|
143
|
+
* Transfers
|
144
|
+
* API Transfers
|
145
|
+
* UI Transfers
|
146
|
+
|
147
|
+
## V 0.8.0
|
148
|
+
|
149
|
+
### FEATURE
|
150
|
+
* orchestrator rebuild
|
151
|
+
* reshash config and reset + grammar and Cli
|
152
|
+
* refacto config
|
153
|
+
|
154
|
+
## V 0.8.1
|
155
|
+
|
156
|
+
### FEATURE
|
157
|
+
* full Web UI features for Logs (R/W)
|
158
|
+
* API Logs Full
|
159
|
+
|
160
|
+
## V 0.8.2
|
161
|
+
|
162
|
+
### FIX
|
163
|
+
* WebAdmin UI bugs and cosmetics
|
164
|
+
* API (constants CLONE for exiter)
|
165
|
+
|
166
|
+
## V 0.8.3
|
167
|
+
|
168
|
+
### SECURITY
|
169
|
+
* kramdown dependencies update
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ SPLASH is **Supervision with Prometheus of Logs and Asynchronous tasks orchestra
|
|
9
9
|
* Web : http://www.ultragreen.net
|
10
10
|
* Github : https://github.com/Ultragreen/prometheus-splash
|
11
11
|
* Rubygems : https://rubygems.org/gems/prometheus-splash
|
12
|
-
* DOC yardoc : https://www.rubydoc.info/gems/prometheus-splash/0.
|
12
|
+
* DOC yardoc : https://www.rubydoc.info/gems/prometheus-splash/0.8.3
|
13
13
|
|
14
14
|
Prometheus Logs and Batchs supervision over PushGateway
|
15
15
|
|
data/config/splash.yml
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
:splash:
|
3
3
|
|
4
4
|
### Main Configuration
|
5
|
+
:paths:
|
6
|
+
:pid_path: /var/run/splash
|
7
|
+
:trace_path: /var/run/splash/traces
|
5
8
|
:loggers:
|
6
9
|
:level: :info
|
7
10
|
:daemon:
|
@@ -23,6 +26,16 @@
|
|
23
26
|
# :port: 6379
|
24
27
|
# #:auth: "mykey"
|
25
28
|
# :base: 1
|
29
|
+
:transfers_trace:
|
30
|
+
:type: :file
|
31
|
+
:path: /var/run/splash/transfers
|
32
|
+
:logs_trace:
|
33
|
+
:type: :file
|
34
|
+
:path: /var/run/splash/logs
|
35
|
+
:process_trace:
|
36
|
+
:type: :file
|
37
|
+
:path: /var/run/splash/process
|
38
|
+
|
26
39
|
:transports:
|
27
40
|
:active: :rabbitmq
|
28
41
|
:rabbitmq:
|
@@ -39,16 +52,14 @@
|
|
39
52
|
:procmon_scheduling:
|
40
53
|
:every: 20s
|
41
54
|
:process_name: "Splash : daemon."
|
42
|
-
:paths:
|
43
|
-
:pid_path: /var/run/splash
|
44
|
-
:trace_path: /var/run/splash/traces
|
45
55
|
:files:
|
46
56
|
:stdout_trace: stdout.txt
|
47
57
|
:stderr_trace: stderr.txt
|
48
58
|
:pid_file: splash.pid
|
49
59
|
:prometheus:
|
50
|
-
:pushgateway: 'http://localhost:9091
|
51
|
-
:url: 'http://localhost:9090
|
60
|
+
:pushgateway: 'http://localhost:9091'
|
61
|
+
:url: 'http://localhost:9090'
|
62
|
+
:alertmanager: 'http://localhost:9093'
|
52
63
|
:webadmin:
|
53
64
|
:port: 9234
|
54
65
|
:ip: 127.0.0.1
|
@@ -117,15 +128,21 @@
|
|
117
128
|
- :label: :log_app_1
|
118
129
|
:log: /tmp/test
|
119
130
|
:pattern: ERROR
|
131
|
+
:retention:
|
132
|
+
:hours: 5
|
120
133
|
- :label: :log_app_2
|
121
134
|
:log: /tmp/test2
|
122
135
|
:pattern: ERROR
|
136
|
+
:retention:
|
137
|
+
:hours: 5
|
123
138
|
|
124
139
|
### configuration of monitored processes
|
125
140
|
:processes:
|
126
141
|
- :process: cron
|
127
142
|
:patterns:
|
128
143
|
- cron
|
144
|
+
:retention:
|
145
|
+
:hours: 5
|
129
146
|
|
130
147
|
|
131
148
|
###
|
@@ -175,4 +192,27 @@
|
|
175
192
|
- :step: exec echo3
|
176
193
|
:command: :echo3
|
177
194
|
|
195
|
+
### Transfers
|
196
|
+
:transfers:
|
197
|
+
- :name: :transfer_text
|
198
|
+
:desc: "List of text files"
|
199
|
+
:pattern: '*.txt'
|
200
|
+
:backup: true
|
201
|
+
:type: :push
|
202
|
+
:retention:
|
203
|
+
:hours: 1
|
204
|
+
:local:
|
205
|
+
:path: /tmp/transferts
|
206
|
+
:user: root
|
207
|
+
:remote:
|
208
|
+
:user: root
|
209
|
+
:host: localhost
|
210
|
+
:path: /tmp/
|
211
|
+
:post:
|
212
|
+
:remote_command: 'ls'
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
178
218
|
###
|
data/lib/splash/backends.rb
CHANGED
@@ -13,6 +13,7 @@ module Splash
|
|
13
13
|
# @param [Symbol] store the name of the store actually in [:execution_trace]
|
14
14
|
# @return [Splash::Backends::<Type>|Hash] with type in [:redis,:file] or Exiter case :configuration_error
|
15
15
|
def get_backend(store)
|
16
|
+
splash_exit case: :configuration_error, more: "backend definition failure" if get_config[:backends][:stores][store].nil?
|
16
17
|
backend = get_config[:backends][:stores][store][:type].to_s
|
17
18
|
aclass = "Splash::Backends::#{backend.capitalize}"
|
18
19
|
begin
|
data/lib/splash/cli.rb
CHANGED
@@ -43,6 +43,7 @@ class CLI < Thor
|
|
43
43
|
subcommand "documentation", Documentation
|
44
44
|
desc "webadmin SUBCOMMAND ...ARGS", "Splash Webadmin daemon controller"
|
45
45
|
subcommand "webadmin", WebAdmin
|
46
|
-
|
46
|
+
desc "transfers SUBCOMMAND ...ARGS", "Managing transfers"
|
47
|
+
subcommand "transfers", Transfers
|
47
48
|
|
48
49
|
end
|
data/lib/splash/cli/commands.rb
CHANGED
@@ -93,6 +93,9 @@ module CLISplash
|
|
93
93
|
option :at, :type => :string
|
94
94
|
option :in, :type => :string
|
95
95
|
def schedule(name)
|
96
|
+
unless is_root? then
|
97
|
+
splash_exit case: :not_root, :more => "Command scheduling"
|
98
|
+
end
|
96
99
|
log = get_logger
|
97
100
|
log.level = :fatal if options[:quiet]
|
98
101
|
hostname = (options[:hostname])? options[:hostname] : Socket.gethostname
|
@@ -129,6 +132,9 @@ module CLISplash
|
|
129
132
|
LONGDESC
|
130
133
|
option :hostname, :type => :string, :aliases => "-H"
|
131
134
|
def treeview(command)
|
135
|
+
unless is_root? then
|
136
|
+
splash_exit case: :not_root, :more => "Command treeview"
|
137
|
+
end
|
132
138
|
depht = 0
|
133
139
|
log = get_logger
|
134
140
|
if options[:hostname] then
|
@@ -179,6 +185,9 @@ module CLISplash
|
|
179
185
|
option :detail, :type => :boolean, :aliases => "-D"
|
180
186
|
option :hostname, :type => :string, :aliases => "-H"
|
181
187
|
def list
|
188
|
+
unless is_root? then
|
189
|
+
splash_exit case: :not_root, :more => "Command list"
|
190
|
+
end
|
182
191
|
log = get_logger
|
183
192
|
list = {}
|
184
193
|
if options[:hostname] then
|
@@ -227,6 +236,9 @@ module CLISplash
|
|
227
236
|
LONGDESC
|
228
237
|
option :hostname, :type => :string, :aliases => "-H"
|
229
238
|
def show(command)
|
239
|
+
unless is_root? then
|
240
|
+
splash_exit case: :not_root, :more => "Command show specifications"
|
241
|
+
end
|
230
242
|
log = get_logger
|
231
243
|
list = {}
|
232
244
|
if options[:hostname] then
|
@@ -265,6 +277,57 @@ module CLISplash
|
|
265
277
|
end
|
266
278
|
end
|
267
279
|
|
280
|
+
|
281
|
+
|
282
|
+
# Thor method : show commands executions history
|
283
|
+
long_desc <<-LONGDESC
|
284
|
+
show commands executions history for LABEL\n
|
285
|
+
LONGDESC
|
286
|
+
option :table, :type => :boolean, :aliases => "-t"
|
287
|
+
desc "history LABEL", "show commands executions history"
|
288
|
+
def history(command)
|
289
|
+
if is_root? then
|
290
|
+
log = get_logger
|
291
|
+
log.info "Log : #{command}#"
|
292
|
+
config = get_config
|
293
|
+
if options[:table] then
|
294
|
+
table = TTY::Table.new do |t|
|
295
|
+
t << ["Start Date","Status", "end_date", "Execution time","STDOUT empty ? ", "STDERR empty ? "]
|
296
|
+
t << ['','','','','','']
|
297
|
+
CmdRecords::new(command).get_all_records.each do |item|
|
298
|
+
record =item.keys.first
|
299
|
+
value=item[record]
|
300
|
+
t << [record, value[:status].to_s,
|
301
|
+
value[:end_date],
|
302
|
+
value[:exec_time],
|
303
|
+
value[:stdout].empty?,
|
304
|
+
value[:stdout].empty?]
|
305
|
+
end
|
306
|
+
end
|
307
|
+
if check_unicode_term then
|
308
|
+
puts table.render(:unicode)
|
309
|
+
else
|
310
|
+
puts table.render(:ascii)
|
311
|
+
end
|
312
|
+
|
313
|
+
else
|
314
|
+
CmdRecords::new(command).get_all_records.each do |item|
|
315
|
+
record =item.keys.first
|
316
|
+
value=item[record]
|
317
|
+
log.item record
|
318
|
+
log.arrow "Status : #{value[:status].to_s}"
|
319
|
+
log.arrow "End date : #{value[:end_date]}"
|
320
|
+
log.arrow "Execution time : #{value[:exec_time]}"
|
321
|
+
log.arrow "STDOUT empty ? : #{value[:stdout].empty?}"
|
322
|
+
log.arrow "STDERR empty ? : #{value[:stderr].empty?}"
|
323
|
+
end
|
324
|
+
end
|
325
|
+
splash_exit case: :quiet_exit
|
326
|
+
else
|
327
|
+
splash_exit case: :not_root, :more => "Command execution history"
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
268
331
|
# Thor method : getting information on the last execution of a command
|
269
332
|
desc "lastrun COMMAND", "Show last running result for specific configured command COMMAND"
|
270
333
|
long_desc <<-LONGDESC
|
@@ -273,6 +336,9 @@ module CLISplash
|
|
273
336
|
LONGDESC
|
274
337
|
option :hostname, :type => :string, :aliases => "-H"
|
275
338
|
def lastrun(command)
|
339
|
+
unless is_root? then
|
340
|
+
splash_exit case: :not_root, :more => "Command last execution report"
|
341
|
+
end
|
276
342
|
log = get_logger
|
277
343
|
backend = get_backend :execution_trace
|
278
344
|
redis = (backend.class == Splash::Backends::Redis)? true : false
|
@@ -294,7 +360,7 @@ module CLISplash
|
|
294
360
|
tp = Template::new(
|
295
361
|
list_token: get_config.execution_template_tokens,
|
296
362
|
template_file: get_config.execution_template_path)
|
297
|
-
tp.map YAML::load(res)
|
363
|
+
tp.map YAML::load(res).last.values.first
|
298
364
|
log.flat tp.output
|
299
365
|
else
|
300
366
|
log.ko "Command not already runned."
|
@@ -305,6 +371,58 @@ module CLISplash
|
|
305
371
|
end
|
306
372
|
end
|
307
373
|
|
374
|
+
|
375
|
+
# Thor method : getting information on one specific execution of a command
|
376
|
+
desc "onerun COMMAND", "Show running result for specific configured command COMMAND"
|
377
|
+
long_desc <<-LONGDESC
|
378
|
+
Show specific running result for specific configured command COMMAND\n
|
379
|
+
with --hostname <HOSTNAME>, an other Splash monitored server (only with Redis backend configured)
|
380
|
+
with --date <DATE>, a date format string (same as in history ouput)
|
381
|
+
|
382
|
+
LONGDESC
|
383
|
+
option :hostname, :type => :string, :aliases => "-H"
|
384
|
+
option :date, :type => :string, :aliases => "-D", :required => true
|
385
|
+
def onerun(command)
|
386
|
+
unless is_root? then
|
387
|
+
splash_exit case: :not_root, :more => "Command specific execution report"
|
388
|
+
end
|
389
|
+
log = get_logger
|
390
|
+
backend = get_backend :execution_trace
|
391
|
+
redis = (backend.class == Splash::Backends::Redis)? true : false
|
392
|
+
if not redis and options[:hostname] then
|
393
|
+
splash_exit case: :specific_config_required, :more => "Redis backend is requiered for Remote execution report request"
|
394
|
+
end
|
395
|
+
splash_exit case: :not_root if not is_root? and not redis
|
396
|
+
list = get_config.commands.keys
|
397
|
+
if options[:hostname] then
|
398
|
+
options[:hostname] = Socket.gethostname if options[:hostname] == 'hostname'
|
399
|
+
list = backend.list("*", options[:hostname]).map(&:to_sym)
|
400
|
+
end
|
401
|
+
if list.include? command.to_sym then
|
402
|
+
log.info "Splash command #{command} previous execution report:\n"
|
403
|
+
req = { :key => command}
|
404
|
+
req[:hostname] = options[:hostname] if options[:hostname]
|
405
|
+
if backend.exist? req then
|
406
|
+
res = backend.get req
|
407
|
+
tp = Template::new(
|
408
|
+
list_token: get_config.execution_template_tokens,
|
409
|
+
template_file: get_config.execution_template_path)
|
410
|
+
prov = YAML::load(res).select{|key,value| key.keys.first == options[:date]}
|
411
|
+
if prov.empty? then
|
412
|
+
log.ko "Command not runned one this date or date misformatted."
|
413
|
+
else
|
414
|
+
tp.map prov.first.values.first
|
415
|
+
log.flat tp.output
|
416
|
+
end
|
417
|
+
else
|
418
|
+
log.ko "Command not already runned."
|
419
|
+
end
|
420
|
+
splash_exit case: :quiet_exit
|
421
|
+
else
|
422
|
+
splash_exit case: :not_found, :more => "Command report never runned remotly" if options[:hostname]
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
308
426
|
# Thor method : getting the list of avaibles executions reports
|
309
427
|
desc "getreportlist", "list all executions report results "
|
310
428
|
long_desc <<-LONGDESC
|
@@ -320,6 +438,9 @@ module CLISplash
|
|
320
438
|
option :all, :type => :boolean, :negate => false, :aliases => "-A"
|
321
439
|
option :detail, :type => :boolean, :aliases => "-D"
|
322
440
|
def getreportlist
|
441
|
+
unless is_root? then
|
442
|
+
splash_exit case: :not_root, :more => "Command execution report list"
|
443
|
+
end
|
323
444
|
log = get_logger
|
324
445
|
options[:hostname] = Socket.gethostname if options[:hostname] == 'hostname'
|
325
446
|
if options[:hostname] and options[:all] then
|
@@ -355,10 +476,9 @@ module CLISplash
|
|
355
476
|
req = { :key => command }
|
356
477
|
req[:hostname] = host if options[:all]
|
357
478
|
res = YAML::load(backend.get(req))
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
log.arrow "Execution time : #{res[:exec_time]}"
|
479
|
+
res.each do |record|
|
480
|
+
log.arrow "#{record.keys.first} : #{record[record.keys.first][:status]}"
|
481
|
+
end
|
362
482
|
end
|
363
483
|
end
|
364
484
|
splash_exit case: :quiet_exit
|
data/lib/splash/cli/daemon.rb
CHANGED
@@ -74,7 +74,47 @@ module CLISplash
|
|
74
74
|
splash_exit case: :quiet_exit
|
75
75
|
end
|
76
76
|
rescue Interrupt
|
77
|
-
splash_exit status: :error, case: :interrupt, more: "
|
77
|
+
splash_exit status: :error, case: :interrupt, more: "ping Command"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# Thor method : sending get_jobs verb over transport in the input queue of Splashd
|
82
|
+
desc "getjobs", "send a get_jobs verb to HOSTNAME daemon over transport (need an active tranport), Typicallly RabbitMQ"
|
83
|
+
def getjobs(hostname=Socket.gethostname)
|
84
|
+
log = get_logger
|
85
|
+
log.info "ctrl+c for interrupt"
|
86
|
+
begin
|
87
|
+
transport = get_default_client
|
88
|
+
if transport.class == Hash and transport.include? :case then
|
89
|
+
splash_exit transport
|
90
|
+
else
|
91
|
+
log.receive transport.execute({ :verb => :get_jobs,
|
92
|
+
:return_to => "splash.#{Socket.gethostname}.returncli",
|
93
|
+
:queue => "splash.#{hostname}.input" })
|
94
|
+
splash_exit case: :quiet_exit
|
95
|
+
end
|
96
|
+
rescue Interrupt
|
97
|
+
splash_exit status: :error, case: :interrupt, more: "getjobs Command"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Thor method : sending reset verb over transport in the input queue of Splashd
|
102
|
+
desc "getjobs", "send a reset verb to HOSTNAME daemon over transport (need an active tranport), Typicallly RabbitMQ"
|
103
|
+
def reset(hostname=Socket.gethostname)
|
104
|
+
log = get_logger
|
105
|
+
log.info "ctrl+c for interrupt"
|
106
|
+
begin
|
107
|
+
transport = get_default_client
|
108
|
+
if transport.class == Hash and transport.include? :case then
|
109
|
+
splash_exit transport
|
110
|
+
else
|
111
|
+
log.receive transport.execute({ :verb => :reset,
|
112
|
+
:return_to => "splash.#{Socket.gethostname}.returncli",
|
113
|
+
:queue => "splash.#{hostname}.input" })
|
114
|
+
splash_exit case: :quiet_exit
|
115
|
+
end
|
116
|
+
rescue Interrupt
|
117
|
+
splash_exit status: :error, case: :interrupt, more: "reset Command"
|
78
118
|
end
|
79
119
|
end
|
80
120
|
|
data/lib/splash/cli/logs.rb
CHANGED
@@ -12,61 +12,76 @@ module CLISplash
|
|
12
12
|
# Thor method : running Splash configured logs monitors analyse
|
13
13
|
desc "analyse", "analyze logs defined in Splash config"
|
14
14
|
def analyse
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
15
|
+
if is_root? then
|
16
|
+
log = get_logger
|
17
|
+
results = LogScanner::new
|
18
|
+
res = results.analyse
|
19
|
+
log.info "SPlash Configured log monitors :"
|
20
|
+
full_status = true
|
21
|
+
results.output.each do |result|
|
22
|
+
if result[:status] == :clean then
|
23
|
+
log.ok "Log : #{result[:log]} with label : #{result[:label]} : no errors"
|
24
|
+
log.item "Detected pattern : #{result[:pattern]}"
|
25
|
+
log.item "Nb lines = #{result[:lines]}"
|
26
|
+
elsif result[:status] == :missing then
|
27
|
+
log.ko "Log : #{result[:log]} with label : #{result[:label]} : missing !"
|
28
|
+
log.item "Detected pattern : #{result[:pattern]}"
|
29
|
+
else
|
30
|
+
log.ko "Log : #{result[:log]} with label : #{result[:label]} : #{result[:count]} errors"
|
31
|
+
log.item "Detected pattern : #{result[:pattern]}"
|
32
|
+
log.item "Nb lines = #{result[:lines]}"
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
35
|
+
full_status = false unless result[:status] == :clean
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
if full_status then
|
39
|
+
log.ok "Global status : no error found"
|
40
|
+
else
|
41
|
+
log.error "Global status : some error found"
|
42
|
+
end
|
43
|
+
splash_exit case: :quiet_exit
|
39
44
|
else
|
40
|
-
|
45
|
+
splash_exit case: :not_root, :more => "Log analysis"
|
41
46
|
end
|
42
|
-
splash_exit case: :quiet_exit
|
43
47
|
end
|
44
48
|
|
45
49
|
|
46
50
|
# Thor method : running Splash configured logs monitors analyse and sending to Prometheus Pushgateway
|
47
51
|
desc "monitor", "monitor logs defined in Splash config"
|
48
52
|
def monitor
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
53
|
+
if is_root? then
|
54
|
+
log = get_logger
|
55
|
+
log.level = :fatal if options[:quiet]
|
56
|
+
result = LogScanner::new
|
57
|
+
result.analyse
|
58
|
+
splash_exit result.notify
|
59
|
+
else
|
60
|
+
splash_exit case: :not_root, :more => "Log analysis"
|
61
|
+
end
|
54
62
|
|
55
63
|
end
|
56
64
|
|
65
|
+
|
66
|
+
|
67
|
+
|
57
68
|
# Thor method : display a specific Splash configured log monitor
|
58
69
|
desc "show LOG", "show Splash configured log monitoring for LOG"
|
59
70
|
def show(logrecord)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
71
|
+
if is_root? then
|
72
|
+
log = get_logger
|
73
|
+
log_record_set = get_config.logs.select{|item| item[:log] == logrecord or item[:label] == logrecord.to_sym}
|
74
|
+
unless log_record_set.empty? then
|
75
|
+
record = log_record_set.first
|
76
|
+
log.info "Splash log monitor : #{record[:log]}"
|
77
|
+
log.item "pattern : /#{record[:pattern]}/"
|
78
|
+
log.item "label : #{record[:label]}"
|
79
|
+
splash_exit case: :quiet_exit
|
80
|
+
else
|
81
|
+
splash_exit case: :not_found, :more => "log not configured"
|
82
|
+
end
|
68
83
|
else
|
69
|
-
splash_exit case: :
|
84
|
+
splash_exit case: :not_root, :more => "Log analysis"
|
70
85
|
end
|
71
86
|
end
|
72
87
|
|
@@ -78,17 +93,66 @@ module CLISplash
|
|
78
93
|
LONGDESC
|
79
94
|
option :detail, :type => :boolean, :aliases => "-D"
|
80
95
|
def list
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
96
|
+
if is_root? then
|
97
|
+
log = get_logger
|
98
|
+
log.info "Splash configured log monitoring :"
|
99
|
+
log_record_set = get_config.logs
|
100
|
+
log.ko 'No configured commands found' if log_record_set.empty?
|
101
|
+
log_record_set.each do |record|
|
102
|
+
log.item "log monitor : #{record[:log]} label : #{record[:label]}"
|
103
|
+
if options[:detail] then
|
104
|
+
log.arrow "pattern : /#{record[:pattern]}/"
|
105
|
+
end
|
89
106
|
end
|
107
|
+
splash_exit case: :quiet_exit
|
108
|
+
else
|
109
|
+
splash_exit case: :not_root, :more => "Log analysis"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
# Thor method : show logs monitoring history
|
115
|
+
long_desc <<-LONGDESC
|
116
|
+
show logs monitoring history for LABEL\n
|
117
|
+
LONGDESC
|
118
|
+
option :table, :type => :boolean, :aliases => "-t"
|
119
|
+
desc "history LABEL", "show logs monitoring history"
|
120
|
+
def history(label)
|
121
|
+
if is_root? then
|
122
|
+
log = get_logger
|
123
|
+
log.info "Log : #{label}"
|
124
|
+
config = get_config
|
125
|
+
if options[:table] then
|
126
|
+
table = TTY::Table.new do |t|
|
127
|
+
t << ["Start Date", "File","Status", "Nb errors", "Nb lines"]
|
128
|
+
t << ['','','','','']
|
129
|
+
LogsRecords::new(label).get_all_records.each do |item|
|
130
|
+
record =item.keys.first
|
131
|
+
value=item[record]
|
132
|
+
|
133
|
+
t << [record, value[:file], value[:status].to_s, value[:errors], value[:lines]]
|
134
|
+
end
|
135
|
+
end
|
136
|
+
if check_unicode_term then
|
137
|
+
puts table.render(:unicode)
|
138
|
+
else
|
139
|
+
puts table.render(:ascii)
|
140
|
+
end
|
141
|
+
|
142
|
+
else
|
143
|
+
LogsRecords::new(label).get_all_records.each do |item|
|
144
|
+
record =item.keys.first
|
145
|
+
value=item[record]
|
146
|
+
log.item record
|
147
|
+
log.arrow "Status : #{value[:status].to_s}"
|
148
|
+
log.arrow "nb files : #{value[:errors]}"
|
149
|
+
log.arrow "nb lines : #{value[:lines]}"
|
150
|
+
end
|
151
|
+
end
|
152
|
+
splash_exit case: :quiet_exit
|
153
|
+
else
|
154
|
+
splash_exit case: :not_root, :more => "Log analysis"
|
90
155
|
end
|
91
|
-
splash_exit case: :quiet_exit
|
92
156
|
end
|
93
157
|
|
94
158
|
end
|