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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -1
- data/README.md +1 -1
- data/config/splash.yml +97 -11
- data/lib/splash/backends.rb +1 -0
- data/lib/splash/cli.rb +4 -1
- data/lib/splash/cli/commands.rb +127 -7
- 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 +114 -0
- data/lib/splash/cli/transfers.rb +213 -0
- data/lib/splash/cli/webadmin.rb +3 -3
- data/lib/splash/commands.rb +89 -22
- data/lib/splash/config.rb +149 -62
- data/lib/splash/config/sanitycheck.rb +1 -1
- data/lib/splash/constants.rb +11 -11
- data/lib/splash/daemon/controller.rb +10 -10
- data/lib/splash/daemon/metrics.rb +8 -8
- data/lib/splash/daemon/orchestrator.rb +96 -35
- data/lib/splash/daemon/orchestrator/grammar.rb +16 -1
- data/lib/splash/dependencies.rb +8 -0
- data/lib/splash/exiter.rb +1 -1
- data/lib/splash/helpers.rb +22 -4
- data/lib/splash/loggers/cli.rb +2 -10
- data/lib/splash/logs.rb +91 -17
- data/lib/splash/processes.rb +88 -17
- data/lib/splash/sequences.rb +105 -0
- data/lib/splash/transfers.rb +229 -0
- data/lib/splash/transports/rabbitmq.rb +0 -1
- data/lib/splash/webadmin.rb +4 -4
- 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 +3 -2
- 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 +15 -8
- 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 +5 -2
- metadata +69 -4
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
|
data/lib/splash/cli/process.rb
CHANGED
@@ -12,65 +12,77 @@ module CLISplash
|
|
12
12
|
# Thor method : unning Splash configured processes monitors analyse
|
13
13
|
desc "analyse", "analyze processes defined in Splash config"
|
14
14
|
def analyse
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
if is_root? then
|
16
|
+
log = get_logger
|
17
|
+
results = ProcessScanner::new
|
18
|
+
res = results.analyse
|
19
|
+
log.info "Splash Configured process records :"
|
20
|
+
full_status = true
|
21
|
+
results.output.each do |result|
|
22
|
+
if result[:status] == :running then
|
23
|
+
log.ok "Process : #{result[:process]} : running"
|
24
|
+
log.item "Detected patterns : "
|
25
|
+
result[:patterns].each do |pattern|
|
26
|
+
log.arrow "/#{pattern}/"
|
27
|
+
end
|
28
|
+
log.item "CPU usage in % : #{result[:cpu]} "
|
29
|
+
log.item "Memory usage in % : #{result[:mem]} "
|
30
|
+
else
|
31
|
+
log.ko "Process : #{result[:process]} : inexistant"
|
32
|
+
log.item "Detected patterns : "
|
33
|
+
result[:patterns].each do |pattern|
|
34
|
+
log.arrow "/#{pattern}/"
|
35
|
+
end
|
26
36
|
end
|
27
|
-
log.item "CPU usage in % : #{result[:cpu]} "
|
28
|
-
log.item "Memory usage in % : #{result[:mem]} "
|
29
|
-
else
|
30
|
-
log.ko "Process : #{result[:process]} : inexistant"
|
31
|
-
log.item "Detected patterns : "
|
32
|
-
result[:patterns].each do |pattern|
|
33
|
-
log.arrow "/#{pattern}/"
|
34
|
-
end
|
35
|
-
end
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
full_status = false unless result[:status] == :running
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
41
|
+
if full_status then
|
42
|
+
log.ok "Global status : no error found"
|
43
|
+
else
|
44
|
+
log.error "Global status : some error found"
|
45
|
+
end
|
46
|
+
splash_exit case: :quiet_exit
|
42
47
|
else
|
43
|
-
|
48
|
+
splash_exit case: :not_root, :more => "Process analysis"
|
44
49
|
end
|
45
|
-
splash_exit case: :quiet_exit
|
46
50
|
end
|
47
51
|
|
48
52
|
|
49
53
|
# Thor method : running Splash configured processes monitors analyse and sending to Prometheus Pushgateway
|
50
54
|
desc "monitor", "monitor processes defined in Splash config"
|
51
55
|
def monitor
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
56
|
+
if is_root? then
|
57
|
+
log = get_logger
|
58
|
+
log.level = :fatal if options[:quiet]
|
59
|
+
result = ProcessScanner::new
|
60
|
+
result.analyse
|
61
|
+
splash_exit result.notify
|
62
|
+
else
|
63
|
+
splash_exit case: :not_root, :more => "Process analysis"
|
64
|
+
end
|
57
65
|
end
|
58
66
|
|
59
67
|
# Thor method : display a specific Splash configured process monitor
|
60
68
|
desc "show PROCESS", "show Splash configured process record for PROCESS"
|
61
69
|
def show(record)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
+
if is_root? then
|
71
|
+
log = get_logger
|
72
|
+
process_recordset = get_config.processes.select{|item| item[:process] == record }
|
73
|
+
unless process_recordset.empty? then
|
74
|
+
record = process_recordset.first
|
75
|
+
log.item "Process monitor : #{record[:process]}"
|
76
|
+
log.arrow "patterns :"
|
77
|
+
record[:patterns].each do |pattern|
|
78
|
+
log.flat " - /#{pattern}/"
|
79
|
+
end
|
80
|
+
splash_exit case: :quiet_exit
|
81
|
+
else
|
82
|
+
splash_exit case: :not_found, :more => "Process not configured"
|
70
83
|
end
|
71
|
-
splash_exit case: :quiet_exit
|
72
84
|
else
|
73
|
-
splash_exit case: :
|
85
|
+
splash_exit case: :not_root, :more => "Process analysis"
|
74
86
|
end
|
75
87
|
end
|
76
88
|
|
@@ -82,20 +94,68 @@ module CLISplash
|
|
82
94
|
LONGDESC
|
83
95
|
option :detail, :type => :boolean, :aliases => "-D"
|
84
96
|
def list
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
97
|
+
if is_root? then
|
98
|
+
log = get_logger
|
99
|
+
log.info "Splash configured process records :"
|
100
|
+
process_recordset = get_config.processes
|
101
|
+
log.ko 'No configured process found' if process_recordset.empty?
|
102
|
+
process_recordset.each do |record|
|
103
|
+
log.item "Process monitor : #{record[:process]}"
|
104
|
+
if options[:detail] then
|
105
|
+
log.arrow "patterns :"
|
106
|
+
record[:patterns].each do |pattern|
|
107
|
+
log.flat " - /#{pattern}/"
|
108
|
+
end
|
95
109
|
end
|
96
110
|
end
|
111
|
+
splash_exit case: :quiet_exit
|
112
|
+
else
|
113
|
+
splash_exit case: :not_root, :more => "Process analysis"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
# Thor method : show logs monitoring history
|
119
|
+
long_desc <<-LONGDESC
|
120
|
+
show Process monitoring history for LABEL\n
|
121
|
+
LONGDESC
|
122
|
+
option :table, :type => :boolean, :aliases => "-t"
|
123
|
+
desc "history PROCESS", "show process monitoring history"
|
124
|
+
def history(process)
|
125
|
+
if is_root? then
|
126
|
+
log = get_logger
|
127
|
+
log.info "Process : #{process}"
|
128
|
+
config = get_config
|
129
|
+
if options[:table] then
|
130
|
+
table = TTY::Table.new do |t|
|
131
|
+
t << ["Start Date", "Status", "CPU Percent", "MEM Percent"]
|
132
|
+
t << ['','','','']
|
133
|
+
ProcessRecords::new(process).get_all_records.each do |item|
|
134
|
+
record =item.keys.first
|
135
|
+
value=item[record]
|
136
|
+
t << [record, value[:status].to_s, value[:cpu_percent], value[:mem_percent]]
|
137
|
+
end
|
138
|
+
end
|
139
|
+
if check_unicode_term then
|
140
|
+
puts table.render(:unicode)
|
141
|
+
else
|
142
|
+
puts table.render(:ascii)
|
143
|
+
end
|
144
|
+
|
145
|
+
else
|
146
|
+
ProcessRecords::new(process).get_all_records.each do |item|
|
147
|
+
record =item.keys.first
|
148
|
+
value=item[record]
|
149
|
+
log.item record
|
150
|
+
log.arrow "Status : #{value[:status].to_s}"
|
151
|
+
log.arrow "CPU Percent : #{value[:cpu_percent]}"
|
152
|
+
log.arrow "MEM Percent : #{value[:mem_percent]}"
|
153
|
+
end
|
154
|
+
end
|
155
|
+
splash_exit case: :quiet_exit
|
156
|
+
else
|
157
|
+
splash_exit case: :not_root, :more => "Process analysis"
|
97
158
|
end
|
98
|
-
splash_exit case: :quiet_exit
|
99
159
|
end
|
100
160
|
|
101
161
|
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
# module for all Thor subcommands
|
4
|
+
module CLISplash
|
5
|
+
|
6
|
+
# Thor inherited class for sequences management
|
7
|
+
class Sequences < Thor
|
8
|
+
include Splash::Sequences
|
9
|
+
include Splash::Transports
|
10
|
+
include Splash::Exiter
|
11
|
+
include Splash::Loggers
|
12
|
+
|
13
|
+
|
14
|
+
# Thor method : execute sequence
|
15
|
+
option :continue, :type => :boolean, default: true
|
16
|
+
long_desc <<-LONGDESC
|
17
|
+
Execute a commands Sequence\n
|
18
|
+
With --no-continue, stop execution on failure
|
19
|
+
LONGDESC
|
20
|
+
desc "execute", "Execute a sequence"
|
21
|
+
def execute(sequence)
|
22
|
+
options[:name] = sequence
|
23
|
+
acase = run_as_root :run_seq, options
|
24
|
+
splash_exit acase
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
# Thor method : show sequence
|
29
|
+
long_desc <<-LONGDESC
|
30
|
+
Show a commands Sequence\n
|
31
|
+
LONGDESC
|
32
|
+
desc "show", "Show a sequence"
|
33
|
+
def show(sequence)
|
34
|
+
options = {}
|
35
|
+
log = get_logger
|
36
|
+
options[:name] = sequence
|
37
|
+
acase = run_as_root :show_seq, options
|
38
|
+
unless acase[:data].nil? then
|
39
|
+
dseq = acase[:data]
|
40
|
+
log.item sequence
|
41
|
+
unless dseq[:options].nil? then
|
42
|
+
log.arrow "Options : "
|
43
|
+
log.flat " * continue on failure : #{dseq[:options][:continue]}" unless dseq[:options][:continue].nil?
|
44
|
+
end
|
45
|
+
log.arrow "Definition :"
|
46
|
+
dseq[:definition].each do |step|
|
47
|
+
log.flat " * Step name : #{step[:step]}"
|
48
|
+
log.flat " => Splash Command to execute : #{step[:command]}"
|
49
|
+
log.flat " => Execute remote on host : #{step[:on_host]}" unless step[:on_host].nil?
|
50
|
+
log.flat " => Follow Callback : #{step[:callback]}" unless step[:callback].nil?
|
51
|
+
log.flat " => Prometheus notification : #{step[:notification]}" unless step[:notification].nil?
|
52
|
+
end
|
53
|
+
end
|
54
|
+
splash_exit acase
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
# Thor method : getting the list of available sequences in splash config
|
59
|
+
desc "list", "Show configured sequences"
|
60
|
+
long_desc <<-LONGDESC
|
61
|
+
Show configured sequences\n
|
62
|
+
with --detail, show command details\n
|
63
|
+
LONGDESC
|
64
|
+
option :detail, :type => :boolean, :aliases => "-D"
|
65
|
+
def list
|
66
|
+
acase = run_as_root :list_seq, options
|
67
|
+
log = get_logger
|
68
|
+
unless acase[:data].nil?
|
69
|
+
log.info "Splash configured sequences"
|
70
|
+
acase[:data].keys.each do |seq|
|
71
|
+
log.item seq
|
72
|
+
if options[:detail] then
|
73
|
+
dseq = acase[:data][seq]
|
74
|
+
unless dseq[:options].nil? then
|
75
|
+
log.arrow "Options : "
|
76
|
+
log.flat " * continue on failure : #{dseq[:options][:continue]}" unless dseq[:options][:continue].nil?
|
77
|
+
end
|
78
|
+
log.arrow "Definition :"
|
79
|
+
dseq[:definition].each do |step|
|
80
|
+
log.flat " * Step name : #{step[:step]}"
|
81
|
+
log.flat " => Splash Command to execute : #{step[:command]}"
|
82
|
+
log.flat " => Execute remote on host : #{step[:on_host]}" unless step[:on_host].nil?
|
83
|
+
log.flat " => Follow Callback : #{step[:callback]}" unless step[:callback].nil?
|
84
|
+
log.flat " => Prometheus notification : #{step[:notification]}" unless step[:notification].nil?
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
splash_exit acase
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
# Thor method : scheduling execution of a commands sequences in splash daemon
|
94
|
+
desc "schedule", "Schedule a configured sequences execution"
|
95
|
+
long_desc <<-LONGDESC
|
96
|
+
Schedule excution of command sequence on Splash daemon\n
|
97
|
+
with --at TIME/DATE, Schedule at specified date/time, like 2030/12/12 23:30:00 or 12:00 \n
|
98
|
+
with --in TIMING, Schedule in specified timing, like 12s, 1m, 2h, 3m10s, 10d\n
|
99
|
+
--in and --at are imcompatibles.\n
|
100
|
+
WARNING : scheduling by CLI are not percisted, so use it only for specifics cases.\n
|
101
|
+
LONGDESC
|
102
|
+
option :at, :type => :string
|
103
|
+
option :in, :type => :string
|
104
|
+
def schedule(sequence)
|
105
|
+
options[:sequence] = sequence
|
106
|
+
acase = run_as_root :schedule_seq, options
|
107
|
+
log = get_logger
|
108
|
+
log.info "Feature in development"
|
109
|
+
splash_exit acase
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|