prometheus-splash 0.6.0 → 0.8.2

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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -1
  3. data/README.md +1 -1
  4. data/config/splash.yml +97 -11
  5. data/lib/splash/backends.rb +1 -0
  6. data/lib/splash/cli.rb +4 -1
  7. data/lib/splash/cli/commands.rb +127 -7
  8. data/lib/splash/cli/daemon.rb +41 -1
  9. data/lib/splash/cli/logs.rb +111 -47
  10. data/lib/splash/cli/process.rb +112 -52
  11. data/lib/splash/cli/sequences.rb +114 -0
  12. data/lib/splash/cli/transfers.rb +213 -0
  13. data/lib/splash/cli/webadmin.rb +3 -3
  14. data/lib/splash/commands.rb +89 -22
  15. data/lib/splash/config.rb +149 -62
  16. data/lib/splash/config/sanitycheck.rb +1 -1
  17. data/lib/splash/constants.rb +11 -11
  18. data/lib/splash/daemon/controller.rb +10 -10
  19. data/lib/splash/daemon/metrics.rb +8 -8
  20. data/lib/splash/daemon/orchestrator.rb +96 -35
  21. data/lib/splash/daemon/orchestrator/grammar.rb +16 -1
  22. data/lib/splash/dependencies.rb +8 -0
  23. data/lib/splash/exiter.rb +1 -1
  24. data/lib/splash/helpers.rb +22 -4
  25. data/lib/splash/loggers/cli.rb +2 -10
  26. data/lib/splash/logs.rb +91 -17
  27. data/lib/splash/processes.rb +88 -17
  28. data/lib/splash/sequences.rb +105 -0
  29. data/lib/splash/transfers.rb +229 -0
  30. data/lib/splash/transports/rabbitmq.rb +0 -1
  31. data/lib/splash/webadmin.rb +4 -4
  32. data/lib/splash/webadmin/api/routes/commands.rb +2 -2
  33. data/lib/splash/webadmin/api/routes/config.rb +53 -2
  34. data/lib/splash/webadmin/api/routes/logs.rb +32 -17
  35. data/lib/splash/webadmin/api/routes/process.rb +4 -4
  36. data/lib/splash/webadmin/api/routes/sequences.rb +28 -0
  37. data/lib/splash/webadmin/main.rb +3 -2
  38. data/lib/splash/webadmin/portal/controllers/commands.rb +2 -0
  39. data/lib/splash/webadmin/portal/controllers/documentation.rb +3 -1
  40. data/lib/splash/webadmin/portal/controllers/home.rb +24 -0
  41. data/lib/splash/webadmin/portal/controllers/logs.rb +44 -1
  42. data/lib/splash/webadmin/portal/controllers/processes.rb +2 -0
  43. data/lib/splash/webadmin/portal/controllers/proxy.rb +15 -8
  44. data/lib/splash/webadmin/portal/controllers/restclient.rb +7 -2
  45. data/lib/splash/webadmin/portal/controllers/sequences.rb +9 -0
  46. data/lib/splash/webadmin/portal/init.rb +2 -2
  47. data/lib/splash/webadmin/portal/public/css/ultragreen.css +6 -0
  48. data/lib/splash/webadmin/portal/public/favicon.ico +0 -0
  49. data/lib/splash/webadmin/portal/views/commands.slim +1 -1
  50. data/lib/splash/webadmin/portal/views/documentation.slim +1 -1
  51. data/lib/splash/webadmin/portal/views/home.slim +53 -9
  52. data/lib/splash/webadmin/portal/views/layout.slim +2 -2
  53. data/lib/splash/webadmin/portal/views/logs.slim +68 -21
  54. data/lib/splash/webadmin/portal/views/logs_form.slim +24 -0
  55. data/lib/splash/webadmin/portal/views/nav.slim +1 -1
  56. data/lib/splash/webadmin/portal/views/not_found.slim +1 -1
  57. data/lib/splash/webadmin/portal/views/processes.slim +1 -1
  58. data/lib/splash/webadmin/portal/views/proxy.slim +5 -2
  59. data/lib/splash/webadmin/portal/views/restclient.slim +7 -4
  60. data/lib/splash/webadmin/portal/views/restclient_result.slim +24 -20
  61. data/lib/splash/webadmin/portal/views/sequences.slim +50 -0
  62. data/prometheus-splash.gemspec +5 -2
  63. metadata +69 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54e538fd7e22b4dc38c1253db96c6e842bf81d1378db0434295c0a827e23bfb7
4
- data.tar.gz: c951aaf9aacd398d0944594185fc8d4986de4268162a62cedd69ff0c96d26f9d
3
+ metadata.gz: a1089bb88ba3cb916cae48b6253559c5542028ab7752d9c08d5a90cb95a45c9f
4
+ data.tar.gz: 90280e53cbf7124b191707fd089afcd48f29bbf68d332fc2acc7865efc2f70b4
5
5
  SHA512:
6
- metadata.gz: 110950f5ac22753830d8b6f1fd74eaf86d77c78eb18728613215fc671279aa8c6da577ba3d54250640c747c76f35c66cd35ffd2ccb38cfc47d65a7c47e408b2b
7
- data.tar.gz: 18aecf0d1f4f080ec1863ec79e17cc6d0582b5cd7f9efac442162c0095d92658372fa2bad1b3c502dd0e44a731a4fd9fe9710bae3e6a4d00be5759610ad08c1c
6
+ metadata.gz: c50f695e45c368955df4c919faa179c32ae333ce9d0e5676e9da0b1497893d08c526a2ba0a07fdaa7172972831fa43e7a16522404e112d1fdae156a1dfc2fbac
7
+ data.tar.gz: c8923535e3af5102bb02c3571cc29a220d83a02e2aa71885ab6022800ad3144361e583302de6021d690922c8f49c503a0e5eb3198cb1e7fa745377727462dae8
@@ -124,4 +124,41 @@
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)
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.6.0
12
+ * DOC yardoc : https://www.rubydoc.info/gems/prometheus-splash/0.8.2
13
13
 
14
14
  Prometheus Logs and Batchs supervision over PushGateway
15
15
 
@@ -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,19 +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:
51
- :host: "localhost"
52
- :port: 9091
53
- :path: ''
54
- :url: "http://localhost:9090/"
60
+ :pushgateway: 'http://localhost:9091'
61
+ :url: 'http://localhost:9090'
62
+ :alertmanager: 'http://localhost:9093'
55
63
  :webadmin:
56
64
  :port: 9234
57
65
  :ip: 127.0.0.1
@@ -63,7 +71,7 @@
63
71
  :pid_file: splash_webadmin.pid
64
72
 
65
73
 
66
- ### configuration of commands and scheduling
74
+ ### Sample configuration of commands and scheduling
67
75
  :commands:
68
76
  :id_root:
69
77
  :desc: run id command on root
@@ -115,18 +123,96 @@
115
123
  :on_success: :echo3
116
124
 
117
125
 
118
- ### configuration of monitored logs
126
+ ### Sample configuration of monitored logs
119
127
  :logs:
120
128
  - :label: :log_app_1
121
129
  :log: /tmp/test
122
130
  :pattern: ERROR
131
+ :retention:
132
+ :hours: 5
123
133
  - :label: :log_app_2
124
134
  :log: /tmp/test2
125
135
  :pattern: ERROR
126
-
136
+ :retention:
137
+ :hours: 5
127
138
 
128
139
  ### configuration of monitored processes
129
140
  :processes:
130
141
  - :process: cron
131
142
  :patterns:
132
143
  - cron
144
+ :retention:
145
+ :hours: 5
146
+
147
+
148
+ ###
149
+ ## Sample configuration of executions sequences
150
+ :sequences:
151
+ :sample_remote_sequence:
152
+ :definition:
153
+ - :step: execute echo2 on omicron
154
+ :command: :echo2
155
+ :on_host: omicron
156
+ - :step: run locally echo3
157
+ :command: :echo3
158
+ :trace: false
159
+ :sample_local_sequence:
160
+ :definition:
161
+ - :step: run locally pwd without callback
162
+ :command: :pwd
163
+ :callback: false
164
+ - :step: run locally echo3 without Prometheus notifications
165
+ :command: :echo3
166
+ :notify: false
167
+ :sample_local_failed_sequence:
168
+ :options:
169
+ :continue: false
170
+ :definition:
171
+ - :step: run false_test locally without callback
172
+ :command: :false_test
173
+ :callback: false
174
+ - :step: considere this as inefective
175
+ :command: :echo3
176
+ :sample_local_full_sequence:
177
+ :options:
178
+ :continue: true
179
+ :definition:
180
+ - :step: run false_test locally without callback
181
+ :command: :false_test
182
+ :callback: false
183
+ :trace: false
184
+ - :step: considere this as inefective
185
+ :command: :pwd
186
+ :sample_scheduled_sequence:
187
+ :schedule:
188
+ :every: 1m
189
+ :options:
190
+ :continue: true
191
+ :definition:
192
+ - :step: exec echo3
193
+ :command: :echo3
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
+
218
+ ###
@@ -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
@@ -29,6 +29,8 @@ class CLI < Thor
29
29
  include CLISplash
30
30
  desc "commands SUBCOMMAND ...ARGS", "Managing commands/batchs supervision & orchestration"
31
31
  subcommand "commands", Commands
32
+ desc "sequences SUBCOMMAND ...ARGS", "Managing Sequences of commands"
33
+ subcommand "sequences", Sequences
32
34
  desc "logs SUBCOMMAND ...ARGS", "Managing Files/Logs supervision"
33
35
  subcommand "logs", Logs
34
36
  desc "processes SUBCOMMAND ...ARGS", "Managing processes supervision"
@@ -41,6 +43,7 @@ class CLI < Thor
41
43
  subcommand "documentation", Documentation
42
44
  desc "webadmin SUBCOMMAND ...ARGS", "Splash Webadmin daemon controller"
43
45
  subcommand "webadmin", WebAdmin
44
-
46
+ desc "transfers SUBCOMMAND ...ARGS", "Managing transfers"
47
+ subcommand "transfers", Transfers
45
48
 
46
49
  end
@@ -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,11 +132,14 @@ 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
135
141
  options[:hostname] = Socket.gethostname if options[:hostname] == 'hostname'
136
- log.info "Remote Splash scheduling command on #{options[:hostname]}:"
142
+ log.info "Remote Splash treeview command on #{options[:hostname]}:"
137
143
  log.info "ctrl+c for interrupt"
138
144
  begin
139
145
  transport = get_default_client
@@ -169,7 +175,7 @@ module CLISplash
169
175
  end
170
176
 
171
177
 
172
- # Thor method : getting the list of avaible commands in splash config
178
+ # Thor method : getting the list of available commands in splash config
173
179
  desc "list", "Show configured commands"
174
180
  long_desc <<-LONGDESC
175
181
  Show configured commands\n
@@ -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
- log.arrow "Status : #{res[:status]}"
359
- log.arrow "Start date : #{res[:start_date]}"
360
- log.arrow "End date : #{res[:end_date]}"
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