prometheus-splash 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +25 -0
- data/CHANGELOG +26 -0
- data/README.md +37 -1
- data/assets/images/splash_design.png +0 -0
- data/bin/splash +9 -1
- data/config/splash.yml +13 -3
- data/lib/splash/backends/file.rb +16 -0
- data/lib/splash/cli/commands.rb +117 -41
- data/lib/splash/cli/config.rb +7 -5
- data/lib/splash/cli/daemon.rb +8 -4
- data/lib/splash/cli/logs.rb +32 -18
- data/lib/splash/commands.rb +17 -16
- data/lib/splash/config.rb +4 -0
- data/lib/splash/config/sanitycheck.rb +23 -19
- data/lib/splash/config/setup.rb +15 -11
- data/lib/splash/constants.rb +9 -5
- data/lib/splash/controller.rb +20 -10
- data/lib/splash/dependencies.rb +3 -0
- data/lib/splash/exiter.rb +4 -2
- data/lib/splash/helpers.rb +30 -4
- data/lib/splash/loggers.rb +89 -0
- data/lib/splash/loggers/cli.rb +83 -0
- data/lib/splash/loggers/daemon.rb +32 -0
- data/lib/splash/loggers/dual.rb +22 -0
- data/lib/splash/logs.rb +4 -3
- data/lib/splash/orchestrator.rb +17 -8
- data/lib/splash/orchestrator/grammar.rb +13 -6
- data/lib/splash/transports.rb +2 -2
- data/lib/splash/transports/rabbitmq.rb +16 -2
- data/prometheus-splash.gemspec +2 -1
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d75be43cdbdc1c7e5cd951946d8ff25bf0da4225c65d2f1150b986179a2be6a
|
4
|
+
data.tar.gz: 6f10a62124372883c15723a1e28d9e439d105cf70b7e30162e7dd16cfd09e0a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b55b81edb62e943d53393a9b2dbafecb94e82ff7aacd9feb35480b8184c82585d2267ae97e5d67f6797f2a9df8b67424f04912721d97dea3512a7edb597fad99
|
7
|
+
data.tar.gz: '059dc2af31e92868090913afe9ae8044b4d995e4df6ea6a0ca9492ba4a341aada92a684d79857c04a77ad7b675106fc9a21719933d7e4ef2b352c6505e7771a9'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
- name: Set up Ruby 2.6
|
17
|
+
uses: actions/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: 2.6.x
|
20
|
+
- name: Build and test with Rake
|
21
|
+
run: |
|
22
|
+
gem install bundler
|
23
|
+
bundle install --jobs 4 --retry 3
|
24
|
+
bundle exec rake spec
|
25
|
+
bundle exec rake build
|
data/CHANGELOG
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# SPLASH CHANGELOG
|
2
|
+
|
3
|
+
|
4
|
+
## V 0.3.0 2020/04/11
|
5
|
+
|
6
|
+
* Begining of Changelog tracking
|
7
|
+
|
8
|
+
## V 0.4.0 2020/04/14
|
9
|
+
|
10
|
+
### DOC :
|
11
|
+
|
12
|
+
* adding \n for LONGDESC Thor #14
|
13
|
+
* Doc for command name format in YAML #2
|
14
|
+
|
15
|
+
### CHANGE :
|
16
|
+
|
17
|
+
* RabbitMQ Credentials and vhosts support #16
|
18
|
+
* backend hardening #18
|
19
|
+
* remote show with --hostname #12
|
20
|
+
|
21
|
+
|
22
|
+
### FEATURE :
|
23
|
+
|
24
|
+
* CLI colors and logger CLI /dual #8
|
25
|
+
* Log for splash daemon #6
|
26
|
+
* Schedule command via daemon execute and --hostname #11
|
data/README.md
CHANGED
@@ -4,9 +4,22 @@
|
|
4
4
|
|
5
5
|
SPLASH is **Supervision with Prometheus of Logs and Asynchronous tasks orchestration for Services or Hosts**
|
6
6
|
|
7
|
+
* Author : Romain GEORGES
|
8
|
+
* COPYright : BSD-2-Clause (c) 2020 Ultragreen Software
|
9
|
+
* Web : http://www.ultragreen.net
|
10
|
+
* Github : https://github.com/Ultragreen/prometheus-splash
|
11
|
+
* Rubygems : https://rubygems.org/gems/prometheus-splash
|
12
|
+
* DOC yardoc : https://www.rubydoc.info/gems/prometheus-splash/0.3.0
|
7
13
|
|
8
14
|
Prometheus Logs and Batchs supervision over PushGateway
|
9
15
|
|
16
|
+
[![GitHub version](https://badge.fury.io/gh/Ultragreen%2Fprometheus-splash.svg)](https://badge.fury.io/gh/Ultragreen%2Fprometheus-splash)
|
17
|
+
![Ruby](https://github.com/Ultragreen/prometheus-splash/workflows/Ruby/badge.svg)
|
18
|
+
[![Gem Version](https://badge.fury.io/rb/prometheus-splash.svg)](https://badge.fury.io/rb/prometheus-splash)
|
19
|
+
|
20
|
+
## Design
|
21
|
+
|
22
|
+
![Splash Design](assets/images/splash_design.png)
|
10
23
|
|
11
24
|
## Preconfiguration
|
12
25
|
|
@@ -289,6 +302,13 @@ To see all the commands in the 'commands' submenu :
|
|
289
302
|
|
290
303
|
Commands or Commands Sequences must be defined in the main configuration file '/etc/splash.yml'
|
291
304
|
|
305
|
+
Command name must be Ruby Symbols, so in the YAML file, it must look like :
|
306
|
+
|
307
|
+
:xxxxxx:
|
308
|
+
|
309
|
+
_with x in the following list [A-Za-z_0-9]_
|
310
|
+
|
311
|
+
|
292
312
|
*Exemple* in default configuration :
|
293
313
|
|
294
314
|
### configuration of commands and scheduling
|
@@ -350,10 +370,21 @@ may include :
|
|
350
370
|
* :user: the userneme to use to run the command
|
351
371
|
* :on_failure: the name of an other defined command, to, execute if exit_code > 0
|
352
372
|
* :on_success: the name of an other defined command, to, execute if exit_code = 0
|
353
|
-
* :schedule: (
|
373
|
+
* :schedule: (Hash) a scheduling for daemon, after in this documentation, it support :
|
354
374
|
* :every: "<timing>" ex: "1s", "3m", "2h"
|
355
375
|
* :at: "<date/time>" ex: "2030/12/12 23:30:00"
|
356
376
|
* :cron: * * * * * a cron format
|
377
|
+
* delegate_to: (Hash) a Slash delagation
|
378
|
+
* :host: the hostname of an other Confiugured Splash Node.
|
379
|
+
* :remote_command: a command defined in the remote Splash node Configuration
|
380
|
+
|
381
|
+
_Remarque_ : Command name, as precise earlier in this documentation is Ruby Symbols ':xxxxx'.
|
382
|
+
In YAML as a Hash key : ':xxxxxx: ', but as a value _':xxxxx'_, so the synthaxe for callbacks :
|
383
|
+
|
384
|
+
:on_success: :xxxxxx
|
385
|
+
:on_failure: :xxxxxx
|
386
|
+
|
387
|
+
It's the same for :remote_command
|
357
388
|
|
358
389
|
[Rufus Scheduler Doc](https://github.com/jmettraux/rufus-scheduler)
|
359
390
|
|
@@ -704,3 +735,8 @@ EXIT_MAP= {
|
|
704
735
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
705
736
|
4. Push to the branch (`git push origin my-new-feature`)
|
706
737
|
5. Create new Pull Request
|
738
|
+
|
739
|
+
|
740
|
+
## Context
|
741
|
+
|
742
|
+
*Massively made during COVID-19 containment : #StayAtHomeSoftware*
|
Binary file
|
data/bin/splash
CHANGED
@@ -10,7 +10,15 @@ $-w = nil
|
|
10
10
|
include Splash::Dependencies
|
11
11
|
include Splash::Helpers
|
12
12
|
include Splash::Exiter
|
13
|
+
include Splash::Loggers
|
14
|
+
include Splash::Config
|
13
15
|
|
16
|
+
unless verify_file(name: CONFIG_FILE, mode: "644", owner: user_root, group: group_root).empty? then
|
17
|
+
puts 'ERROR: Splash need reconfiguration : execution abort, '
|
18
|
+
puts ' => Restart after rebuild (recheck for homemade templates) :'
|
14
19
|
|
20
|
+
acase = run_as_root :setupsplash
|
21
|
+
splash_exit acase
|
22
|
+
end
|
15
23
|
|
16
|
-
|
24
|
+
CLI.start(ARGV)
|
data/config/splash.yml
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
:splash:
|
3
3
|
|
4
4
|
### Main Configuration
|
5
|
+
:loggers:
|
6
|
+
:level: :info
|
7
|
+
:daemon:
|
8
|
+
:file: /var/log/splash.log
|
9
|
+
:cli:
|
10
|
+
:emoji: true
|
11
|
+
:color: true
|
5
12
|
:templates:
|
6
13
|
:execution:
|
7
14
|
:path: /etc/splash_execution_report.tpl
|
@@ -9,7 +16,7 @@
|
|
9
16
|
:stores:
|
10
17
|
:execution_trace:
|
11
18
|
:type: :file
|
12
|
-
:path: /
|
19
|
+
:path: /var/run/splash
|
13
20
|
# :execution_trace:
|
14
21
|
# :type: :redis
|
15
22
|
# :host: localhost
|
@@ -19,15 +26,17 @@
|
|
19
26
|
:transports:
|
20
27
|
:active: :rabbitmq
|
21
28
|
:rabbitmq:
|
22
|
-
:
|
29
|
+
:vhost: /
|
23
30
|
:port: 5672
|
24
31
|
:host: "localhost"
|
32
|
+
# :passwd: testpasswd
|
33
|
+
# :user: test
|
25
34
|
:daemon:
|
26
35
|
:logmon_scheduling:
|
27
36
|
:every: 20s
|
28
37
|
:process_name: "Splash : daemon."
|
29
38
|
:paths:
|
30
|
-
:pid_path: /
|
39
|
+
:pid_path: /var/run
|
31
40
|
:trace_path: /tmp/splash
|
32
41
|
:files:
|
33
42
|
:stdout_trace: stdout.txt
|
@@ -88,6 +97,7 @@
|
|
88
97
|
:delegate_to:
|
89
98
|
:host: omicron
|
90
99
|
:remote_command: :echo2
|
100
|
+
:on_success: :echo3
|
91
101
|
|
92
102
|
|
93
103
|
### configuration of monitored logs
|
data/lib/splash/backends/file.rb
CHANGED
@@ -3,9 +3,14 @@ module Splash
|
|
3
3
|
module Backends
|
4
4
|
class File
|
5
5
|
include Splash::Config
|
6
|
+
include Splash::Exiter
|
7
|
+
include Splash::Helpers
|
8
|
+
include Splash::Loggers
|
9
|
+
|
6
10
|
def initialize(store)
|
7
11
|
@config = get_config[:backends][:stores][store]
|
8
12
|
@path = @config[:path]
|
13
|
+
ensure_backend
|
9
14
|
end
|
10
15
|
|
11
16
|
def list(pattern='*')
|
@@ -36,6 +41,17 @@ module Splash
|
|
36
41
|
return "#{astring}.trace"
|
37
42
|
end
|
38
43
|
|
44
|
+
def ensure_backend
|
45
|
+
unless verify_folder(name: @config[:path], mode: "644", owner: get_config.user_root, group: get_config.group_root).empty? then
|
46
|
+
get_logger.warn "File Backend folder : #{@config[:path]} is missing"
|
47
|
+
if make_folder path: @config[:path], mode: "644", owner: get_config.user_root, group: get_config.group_root then
|
48
|
+
get_logger.ok "File Backend folder : #{@config[:path]} created"
|
49
|
+
else
|
50
|
+
splash_exit case: :configuration_error, more: "File backend creation error"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
39
55
|
end
|
40
56
|
end
|
41
57
|
|
data/lib/splash/cli/commands.rb
CHANGED
@@ -8,6 +8,7 @@ module CLISplash
|
|
8
8
|
include Splash::Exiter
|
9
9
|
include Splash::Transports
|
10
10
|
include Splash::Templates
|
11
|
+
include Splash::Loggers
|
11
12
|
|
12
13
|
desc "execute NAME", "run for command/sequence or ack result"
|
13
14
|
long_desc <<-LONGDESC
|
@@ -16,7 +17,7 @@ module CLISplash
|
|
16
17
|
with --ack, notify errorcode=0 to Prometheus PushGateway\n
|
17
18
|
with --no-notify, bypass Prometheus notification\n
|
18
19
|
with --no-callback, never execute callback (:on_failure, :on_success)\n
|
19
|
-
never follow sequences
|
20
|
+
never follow sequences\n
|
20
21
|
with --hostname, execute on an other Splash daemon node
|
21
22
|
LONGDESC
|
22
23
|
option :trace, :type => :boolean, :default => true
|
@@ -25,11 +26,12 @@ module CLISplash
|
|
25
26
|
option :callback, :type => :boolean, :default => true
|
26
27
|
option :hostname, :type => :string
|
27
28
|
def execute(name)
|
29
|
+
log = get_logger
|
28
30
|
if is_root? then
|
29
31
|
if options[:hostname] then
|
30
32
|
splash_exit({ :case => :options_incompatibility, :more => '--hostname forbidden with delagate commands'}) if get_config.commands[name.to_sym][:delegate_to]
|
31
|
-
|
32
|
-
|
33
|
+
log.info "Remote Splash configured commands on #{options[:hostname]}:"
|
34
|
+
log.info "ctrl+c for interrupt"
|
33
35
|
begin
|
34
36
|
transport = get_default_client
|
35
37
|
if transport.class == Hash and transport.include? :case then
|
@@ -68,18 +70,61 @@ module CLISplash
|
|
68
70
|
end
|
69
71
|
|
70
72
|
|
73
|
+
desc "schedule NAME", "Schedule excution of command on Splash daemon"
|
74
|
+
long_desc <<-LONGDESC
|
75
|
+
Schedule excution of command on Splash daemon\n
|
76
|
+
with --hostname, Schedule on an other Splash daemon via transport\n
|
77
|
+
with --at TIME/DATE, Schedule at specified date/time, like 2030/12/12 23:30:00 or 12:00 \n
|
78
|
+
with --in TIMING, Schedule in specified timing, like 12s, 1m, 2h, 3m10s, 10d\n
|
79
|
+
--in and --at are imcompatibles.\n
|
80
|
+
WARNING : scheduling by CLI are not percisted, so use it only for specifics cases.\n
|
81
|
+
NOTES : Scheduling, force trace, notifying and callback.
|
82
|
+
LONGDESC
|
83
|
+
option :hostname, :type => :string
|
84
|
+
option :at, :type => :string
|
85
|
+
option :in, :type => :string
|
86
|
+
def schedule(name)
|
87
|
+
log = get_logger
|
88
|
+
hostname = (options[:hostname])? options[:hostname] : Socket.gethostname
|
89
|
+
splash_exit({ :case => :options_incompatibility, :more => '--at or --in is required'}) unless options[:at] or options[:in]
|
90
|
+
splash_exit({ :case => :options_incompatibility, :more => '--at an --in'}) if options[:at] and options[:in]
|
91
|
+
log.info "Remote Splash scheduling command on #{hostname}:"
|
92
|
+
log.info "ctrl+c for interrupt"
|
93
|
+
begin
|
94
|
+
transport = get_default_client
|
95
|
+
if transport.class == Hash and transport.include? :case then
|
96
|
+
splash_exit transport
|
97
|
+
else
|
98
|
+
schedule = { :in => options[:in]} if options[:in]
|
99
|
+
schedule = { :at => options[:at]} if options[:at]
|
100
|
+
res = transport.execute({ :verb => :execute_command,
|
101
|
+
payload: {:name => name, :schedule => schedule},
|
102
|
+
:return_to => "splash.#{Socket.gethostname}.returncli",
|
103
|
+
:queue => "splash.#{hostname}.input" })
|
104
|
+
log.receive "Execute command sheduled confirmed"
|
105
|
+
res[:more] = "Remote command : :execute_command with schedule"
|
106
|
+
splash_exit res
|
107
|
+
end
|
108
|
+
rescue Interrupt
|
109
|
+
splash_exit case: :interrupt, more: "Remote command exection"
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
|
71
115
|
desc "treeview", "Show commands sequence tree"
|
72
116
|
def treeview(command, depht = 0)
|
73
|
-
|
117
|
+
log = get_logger
|
118
|
+
log.info "Command : #{command.to_s}" if depht == 0
|
74
119
|
cmd = get_config.commands[command.to_sym]
|
75
120
|
if cmd[:on_failure] then
|
76
|
-
|
77
|
-
|
121
|
+
spacer= " " * depht + " "
|
122
|
+
log.flat "#{spacer}* on failure => #{cmd[:on_failure]}"
|
78
123
|
treeview(cmd[:on_failure], depht+2)
|
79
124
|
end
|
80
125
|
if cmd[:on_success] then
|
81
|
-
|
82
|
-
|
126
|
+
spacer = " " * depht + " "
|
127
|
+
log.flat "#{spacer}* on success => #{cmd[:on_success]}"
|
83
128
|
treeview(cmd[:on_success],depht+2)
|
84
129
|
end
|
85
130
|
splash_exit case: :quiet_exit
|
@@ -88,17 +133,18 @@ module CLISplash
|
|
88
133
|
|
89
134
|
desc "list", "Show configured commands"
|
90
135
|
long_desc <<-LONGDESC
|
91
|
-
Show configured commands
|
92
|
-
with --detail, show command details
|
93
|
-
with --hostname, ask other
|
136
|
+
Show configured commands\n
|
137
|
+
with --detail, show command details\n
|
138
|
+
with --hostname, ask other Splash daemon via transport\n
|
94
139
|
LONGDESC
|
95
140
|
option :detail, :type => :boolean
|
96
141
|
option :hostname, :type => :string
|
97
142
|
def list
|
143
|
+
log = get_logger
|
98
144
|
list = {}
|
99
145
|
if options[:hostname] then
|
100
|
-
|
101
|
-
|
146
|
+
log.info "Remote Splash configured commands on #{options[:hostname]}:"
|
147
|
+
log.info "ctrl+c for interrupt"
|
102
148
|
begin
|
103
149
|
transport = get_default_client
|
104
150
|
if transport.class == Hash and transport.include? :case then
|
@@ -112,20 +158,20 @@ module CLISplash
|
|
112
158
|
splash_exit case: :interrupt, more: "remote list Command"
|
113
159
|
end
|
114
160
|
else
|
115
|
-
|
161
|
+
log.info "Splash configured commands :"
|
116
162
|
list = get_config.commands
|
117
163
|
end
|
118
|
-
|
164
|
+
log.ko 'No configured commands found' if list.keys.empty?
|
119
165
|
list.keys.each do |command|
|
120
|
-
|
166
|
+
log.item "#{command.to_s}"
|
121
167
|
if options[:detail] then
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
168
|
+
log.arrow "command line : '#{list[command][:command]}'"
|
169
|
+
log.arrow "command description : '#{list[command][:desc]}'"
|
170
|
+
log.arrow "command failure callback : '#{list[command.to_sym][:on_failure]}'" if list[command.to_sym][:on_failure]
|
171
|
+
log.arrow "command success callback : '#{list[command.to_sym][:on_success]}'" if list[command.to_sym][:on_success]
|
126
172
|
if list[command.to_sym][:schedule]
|
127
173
|
sched,val = list[command.to_sym][:schedule].flatten
|
128
|
-
|
174
|
+
log.arrow "command scheduled : #{sched} #{val}."
|
129
175
|
end
|
130
176
|
end
|
131
177
|
end
|
@@ -134,14 +180,42 @@ module CLISplash
|
|
134
180
|
|
135
181
|
|
136
182
|
desc "show COMMAND", "Show specific configured command COMMAND"
|
183
|
+
long_desc <<-LONGDESC
|
184
|
+
Show specific configured command COMMAND\n
|
185
|
+
with --hostname <HOSTNAME>, an other Splash monitored server (only with Redis backend configured)
|
186
|
+
LONGDESC
|
187
|
+
option :hostname, :type => :string
|
137
188
|
def show(command)
|
138
|
-
|
189
|
+
log = get_logger
|
190
|
+
list = {}
|
191
|
+
if options[:hostname] then
|
192
|
+
log.info "Remote Splash configured commands on #{options[:hostname]}:"
|
193
|
+
log.info "ctrl+c for interrupt"
|
194
|
+
begin
|
195
|
+
transport = get_default_client
|
196
|
+
if transport.class == Hash and transport.include? :case then
|
197
|
+
splash_exit transport
|
198
|
+
else
|
199
|
+
list = transport.execute({ :verb => :list_commands,
|
200
|
+
:return_to => "splash.#{Socket.gethostname}.returncli",
|
201
|
+
:queue => "splash.#{options[:hostname]}.input" })
|
202
|
+
end
|
203
|
+
rescue Interrupt
|
204
|
+
splash_exit case: :interrupt, more: "remote list Command"
|
205
|
+
end
|
206
|
+
else
|
207
|
+
list = get_config.commands
|
208
|
+
end
|
139
209
|
if list.keys.include? command.to_sym then
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
210
|
+
log.info "Splash command : #{command}"
|
211
|
+
log.item "command line : '#{list[command.to_sym][:command]}'"
|
212
|
+
log.item "command description : '#{list[command.to_sym][:desc]}'"
|
213
|
+
log.item "command failure callback : '#{list[command.to_sym][:on_failure]}'" if list[command.to_sym][:on_failure]
|
214
|
+
log.item "command success callback : '#{list[command.to_sym][:on_success]}'" if list[command.to_sym][:on_success]
|
215
|
+
if list[command.to_sym][:schedule]
|
216
|
+
sched,val = list[command.to_sym][:schedule].flatten
|
217
|
+
log.item "command scheduled : #{sched} #{val}."
|
218
|
+
end
|
145
219
|
splash_exit case: :quiet_exit
|
146
220
|
else
|
147
221
|
splash_exit case: :not_found, :more => 'Command not configured'
|
@@ -151,11 +225,12 @@ module CLISplash
|
|
151
225
|
|
152
226
|
desc "lastrun COMMAND", "Show last running result for specific configured command COMMAND"
|
153
227
|
long_desc <<-LONGDESC
|
154
|
-
Show last running result for specific configured command COMMAND
|
228
|
+
Show last running result for specific configured command COMMAND\n
|
155
229
|
with --hostname <HOSTNAME>, an other Splash monitored server (only with Redis backend configured)
|
156
230
|
LONGDESC
|
157
231
|
option :hostname, :type => :string
|
158
232
|
def lastrun(command)
|
233
|
+
log = get_logger
|
159
234
|
backend = get_backend :execution_trace
|
160
235
|
redis = (backend.class == Splash::Backends::Redis)? true : false
|
161
236
|
if not redis and options[:hostname] then
|
@@ -166,7 +241,7 @@ module CLISplash
|
|
166
241
|
list = backend.list("*", options[:hostname]).map(&:to_sym)
|
167
242
|
end
|
168
243
|
if list.include? command.to_sym then
|
169
|
-
|
244
|
+
log.info "Splash command #{command} previous execution report:\n"
|
170
245
|
req = { :key => command}
|
171
246
|
req[:hostname] = options[:hostname] if options[:hostname]
|
172
247
|
if backend.exist? req then
|
@@ -175,9 +250,9 @@ module CLISplash
|
|
175
250
|
list_token: get_config.execution_template_tokens,
|
176
251
|
template_file: get_config.execution_template_path)
|
177
252
|
tp.map YAML::load(res)
|
178
|
-
|
253
|
+
log.flat tp.output
|
179
254
|
else
|
180
|
-
|
255
|
+
log.ko "Command not already runned."
|
181
256
|
end
|
182
257
|
splash_exit case: :quiet_exit
|
183
258
|
else
|
@@ -187,11 +262,11 @@ module CLISplash
|
|
187
262
|
|
188
263
|
desc "getreportlist", "list all executions report results "
|
189
264
|
long_desc <<-LONGDESC
|
190
|
-
list all executions report results
|
265
|
+
list all executions report results\n
|
191
266
|
with --pattern <SEARCH>, search type string, wilcard * (group) ? (char)\n
|
192
267
|
with --hostname <HOSTNAME>, an other Splash monitored server (only with Redis backend configured)\n
|
193
268
|
with --all, get all execution report for all servers (only with Redis backend configured)\n
|
194
|
-
with --detail, get major informations of each reports
|
269
|
+
with --detail, get major informations of each reports\n
|
195
270
|
--all and --hostname are exclusives
|
196
271
|
LONGDESC
|
197
272
|
option :pattern, :type => :string
|
@@ -199,6 +274,7 @@ module CLISplash
|
|
199
274
|
option :all, :type => :boolean, :negate => false
|
200
275
|
option :detail, :type => :boolean
|
201
276
|
def getreportlist
|
277
|
+
log = get_logger
|
202
278
|
if options[:hostname] and options[:all] then
|
203
279
|
splash_exit case: :options_incompatibility, more: "--all, --hostname"
|
204
280
|
end
|
@@ -215,26 +291,26 @@ module CLISplash
|
|
215
291
|
else
|
216
292
|
res = backend.list pattern
|
217
293
|
end
|
218
|
-
|
219
|
-
|
294
|
+
log.info "List of Executions reports :\n"
|
295
|
+
log.ko "Not reports found" if res.empty?
|
220
296
|
res.each do |item|
|
221
297
|
host = ""
|
222
298
|
command = ""
|
223
299
|
if options[:all]
|
224
300
|
host,command = item.split('#')
|
225
|
-
|
301
|
+
log.item "Command : #{command} @ host : #{host}"
|
226
302
|
else
|
227
303
|
command = item
|
228
|
-
|
304
|
+
log.item "Command : #{command}"
|
229
305
|
end
|
230
306
|
if options[:detail] then
|
231
307
|
req = { :key => command }
|
232
308
|
req[:hostname] = host if options[:all]
|
233
309
|
res = YAML::load(backend.get(req))
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
310
|
+
log.arrow "Status : #{res[:status]}"
|
311
|
+
log.arrow "Start date : #{res[:start_date]}"
|
312
|
+
log.arrow "End date : #{res[:end_date]}"
|
313
|
+
log.arrow "Execution time : #{res[:exec_time]}"
|
238
314
|
end
|
239
315
|
end
|
240
316
|
splash_exit case: :quiet_exit
|