prometheus-splash 0.6.0 → 0.8.2
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 -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
@@ -0,0 +1,229 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
# base Splash Module
|
4
|
+
module Splash
|
5
|
+
|
6
|
+
# Transfers module
|
7
|
+
module Transfers
|
8
|
+
|
9
|
+
include Splash::Config
|
10
|
+
include Splash::Loggers
|
11
|
+
include Splash::Helpers
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
class TxNotifier
|
16
|
+
@@registry = Prometheus::Client::Registry::new
|
17
|
+
@@metric_nbfiles = Prometheus::Client::Gauge.new(:txnbfiles, docstring: 'SPLASH metric transfer number of files')
|
18
|
+
@@metric_nbfiles_failed = Prometheus::Client::Gauge.new(:txnbfilesfailed, docstring: 'SPLASH metric transfer number of failed files')
|
19
|
+
@@metric_time = Prometheus::Client::Gauge.new(:txtime, docstring: 'SPLASH metric transfer execution time')
|
20
|
+
@@registry.register(@@metric_nbfiles)
|
21
|
+
@@registry.register(@@metric_nbfiles_failed)
|
22
|
+
@@registry.register(@@metric_time)
|
23
|
+
|
24
|
+
def initialize(options={})
|
25
|
+
@config = get_config
|
26
|
+
@url = @config.prometheus_pushgateway_url
|
27
|
+
@name = "tx_#{options[:name].to_s}"
|
28
|
+
@nbfiles = options[:nbfiles]
|
29
|
+
@nbfiles_failed = options[:nbfiles_failed]
|
30
|
+
@time = options[:time]
|
31
|
+
end
|
32
|
+
|
33
|
+
# send metrics to Prometheus PushGateway
|
34
|
+
# @return [Bool]
|
35
|
+
def notify
|
36
|
+
unless verify_service url: @url then
|
37
|
+
return { :case => :service_dependence_missing, :more => "Prometheus Notification not send."}
|
38
|
+
end
|
39
|
+
@@metric_nbfiles.set(@nbfiles)
|
40
|
+
@@metric_nbfiles_failed.set(@nbfiles_failed)
|
41
|
+
@@metric_time.set(@time)
|
42
|
+
hostname = Socket.gethostname
|
43
|
+
return Prometheus::Client::Push.new(@name, hostname, @url).add(@@registry)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
class TxRecords
|
51
|
+
include Splash::Backends
|
52
|
+
include Splash::Constants
|
53
|
+
|
54
|
+
def initialize(name)
|
55
|
+
@name = name
|
56
|
+
@backend = get_backend :transfers_trace
|
57
|
+
end
|
58
|
+
|
59
|
+
def purge(retention)
|
60
|
+
retention = {} if retention.nil?
|
61
|
+
if retention.include? :hours then
|
62
|
+
adjusted_datetime = DateTime.now - retention[:hours].to_f / 24
|
63
|
+
elsif retention.include? :hours then
|
64
|
+
adjusted_datetime = DateTime.now - retention[:days].to_i
|
65
|
+
else
|
66
|
+
adjusted_datetime = DateTime.now - DEFAULT_RETENTION
|
67
|
+
end
|
68
|
+
|
69
|
+
data = get_all_records
|
70
|
+
|
71
|
+
data.delete_if { |item|
|
72
|
+
DateTime.parse(item.keys.first) <= (adjusted_datetime)}
|
73
|
+
@backend.put key: @name, value: data.to_yaml
|
74
|
+
end
|
75
|
+
|
76
|
+
def add_record(record)
|
77
|
+
data = get_all_records
|
78
|
+
data.push({ DateTime.now.to_s => record })
|
79
|
+
@backend.put key: @name, value: data.to_yaml
|
80
|
+
end
|
81
|
+
|
82
|
+
def get_all_records(options={})
|
83
|
+
return (@backend.exist?({key: @name}))? YAML::load(@backend.get({key: @name})) : []
|
84
|
+
end
|
85
|
+
|
86
|
+
def check_prepared
|
87
|
+
return :never_run_prepare unless @backend.exist?({key: @name})
|
88
|
+
return :never_prepare unless YAML::load(@backend.get({key: @name})).select {|item|
|
89
|
+
record =item.keys.first
|
90
|
+
value=item[record]
|
91
|
+
value[:status] == :prepared
|
92
|
+
}.count > 0
|
93
|
+
return :prepared
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
def run_txs(options = {})
|
99
|
+
log = get_logger
|
100
|
+
log.info 'Running Transfers'
|
101
|
+
count=0
|
102
|
+
get_config.transfers.each do |record|
|
103
|
+
txrec = TxRecords::new record[:name]
|
104
|
+
txrec.purge(record[:retention])
|
105
|
+
log.item "Execute : #{record[:name]}, #{record[:desc]}"
|
106
|
+
case txrec.check_prepared
|
107
|
+
when :prepared
|
108
|
+
if record[:type] == :push then
|
109
|
+
unless push record
|
110
|
+
count += 1
|
111
|
+
end
|
112
|
+
elsif record[:type] == :pull then
|
113
|
+
unless pull record
|
114
|
+
count += 1
|
115
|
+
end
|
116
|
+
else
|
117
|
+
log.ko "Transfer type unkown"
|
118
|
+
count += 1
|
119
|
+
end
|
120
|
+
when :never_prepare
|
121
|
+
log.ko "#{record[:name]} : Never prepared, ignored"
|
122
|
+
txrec.add_record :status => :never_prepared
|
123
|
+
count += 1
|
124
|
+
when :never_run_prepare
|
125
|
+
log.ko "#{record[:name]} : Never Executed and never prepared, ignored"
|
126
|
+
txrec.add_record :status => :never_prepared
|
127
|
+
count += 1
|
128
|
+
end
|
129
|
+
end
|
130
|
+
return {:case => :error_exit, :more => "#{count} Transfer(s) failed"} if count > 0
|
131
|
+
return {:case => :quiet_exit }
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
def prepare_tx(name)
|
137
|
+
log = get_logger
|
138
|
+
record = get_config.transfers.select { |item| item[:name] == name.to_sym }.first
|
139
|
+
home = Etc.getpwnam(record[:local][:user]).dir
|
140
|
+
identity = ::File::readlines("#{home}/.ssh/id_rsa.pub").first.chomp
|
141
|
+
folder = {:mode => "755",
|
142
|
+
:owner => record[:local][:user] ,
|
143
|
+
:group => Etc.getgrgid(Etc.getpwnam(record[:local][:user]).gid).name,
|
144
|
+
:name => record[:local][:path],
|
145
|
+
:path => record[:local][:path]}
|
146
|
+
log.info "Ensure local folder : #{record[:local][:path]}"
|
147
|
+
make_folder(folder) unless verify_folder(folder).empty?
|
148
|
+
begin
|
149
|
+
log.info "Ensure RSA Key sharing for local user : #{record[:local][:user]} to remote user : #{record[:remote][:user]}@#{record[:remote][:host]}"
|
150
|
+
ssh = Net::SSH.start(record[:remote][:host],record[:remote][:user])
|
151
|
+
output = ssh.exec!(%[
|
152
|
+
/bin/bash -cl '
|
153
|
+
umask 077;
|
154
|
+
mkdir #{record[:remote][:path]};
|
155
|
+
test -d ~/.ssh || mkdir ~/.ssh;
|
156
|
+
if [ ! -f ~/.ssh/authorized_keys -o `grep "#{identity}" ~/.ssh/authorized_keys 2> /dev/null | wc -l` -eq 0 ]; then echo "#{identity}" >> ~/.ssh/authorized_keys
|
157
|
+
fi'])
|
158
|
+
log.info "Prepare remote folder : #{record[:remote][:path]}"
|
159
|
+
log.info "Prepare data file for transfer : #{record[:name]}"
|
160
|
+
txrec = TxRecords::new record[:name]
|
161
|
+
txrec.add_record :status => :prepared
|
162
|
+
log.ok "Transfer : #{record[:name]} prepared successfully"
|
163
|
+
return {:case => :quiet_exit }
|
164
|
+
rescue Interrupt
|
165
|
+
splash_exit case: :interrupt, more: "Remote command exection"
|
166
|
+
rescue TTY::Reader::InputInterrupt
|
167
|
+
splash_exit case: :interrupt, more: "Remote command exection"
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
def save_data
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
def push(record)
|
180
|
+
config = get_config
|
181
|
+
log = get_logger
|
182
|
+
txrec = TxRecords::new record[:name]
|
183
|
+
start = Time.now
|
184
|
+
res = true
|
185
|
+
count = 0
|
186
|
+
done =[]
|
187
|
+
start_date = DateTime.now.to_s
|
188
|
+
list = Dir.glob("#{record[:local][:path]}/#{record[:pattern]}")
|
189
|
+
count = list.count
|
190
|
+
log.arrow "Transfering #{count} file(s)"
|
191
|
+
|
192
|
+
begin
|
193
|
+
scp = Net::SCP.start(record[:remote][:host],record[:remote][:user])
|
194
|
+
list.each do|f|
|
195
|
+
log.arrow "Copy file : #{f} to #{record[:remote][:user]}@#{record[:remote][:host]}:#{record[:remote][:path]}"
|
196
|
+
scp.upload! f, record[:remote][:path]
|
197
|
+
done.push f
|
198
|
+
if record[:backup] then
|
199
|
+
log.arrow "File #{f} backuped"
|
200
|
+
FileUtils::mv(f, "#{f}.#{Time.now.getutc.to_i}")
|
201
|
+
else
|
202
|
+
FileUtils::unlink(f)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
rescue
|
207
|
+
res = false
|
208
|
+
end
|
209
|
+
|
210
|
+
end_date = DateTime.now.to_s
|
211
|
+
time = Time.now - start
|
212
|
+
status = (res)? :success : :failure
|
213
|
+
txrec.add_record :status => status,
|
214
|
+
:end_date => end_date,
|
215
|
+
:time => time,
|
216
|
+
:count => count,
|
217
|
+
:wanted => list,
|
218
|
+
:done => done
|
219
|
+
count_failed = list.count - done.count
|
220
|
+
txmonitor = TxNotifier::new({name: record[:name], nbfiles: count,nbfiles_failed: count_failed, time: time})
|
221
|
+
if txmonitor.notify then
|
222
|
+
log.ok "Sending metrics to Prometheus Pushgateway"
|
223
|
+
else
|
224
|
+
log.ko "Failed to send metrics to Prometheus Pushgateway"
|
225
|
+
end
|
226
|
+
return res
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
@@ -100,7 +100,6 @@ module Splash
|
|
100
100
|
condition = ConditionVariable.new
|
101
101
|
get_default_subscriber(queue: queue).subscribe do |delivery_info, properties, payload|
|
102
102
|
res = YAML::load(payload)
|
103
|
-
|
104
103
|
lock.synchronize { condition.signal }
|
105
104
|
end
|
106
105
|
get_logger.send "Verb : #{order[:verb].to_s} to queue : #{order[:queue]}."
|
data/lib/splash/webadmin.rb
CHANGED
@@ -21,7 +21,7 @@ module Splash
|
|
21
21
|
# @param [Hash] options
|
22
22
|
# @option options [Symbol] :quiet activate quiet mode for log (limit to :fatal)
|
23
23
|
# @return [Hash] Exiter Case (:quiet_exit, :already_exist, :unknown_error or other)
|
24
|
-
def
|
24
|
+
def startweb(options = {})
|
25
25
|
require 'splash/webadmin/main'
|
26
26
|
config = get_config
|
27
27
|
log = get_logger
|
@@ -29,7 +29,7 @@ module Splash
|
|
29
29
|
realpid = get_processes pattern: get_config.webadmin_process_name
|
30
30
|
|
31
31
|
|
32
|
-
unless File::exist? config.
|
32
|
+
unless File::exist? config.webadmin_full_pid_path then
|
33
33
|
unless realpid.empty? then
|
34
34
|
return {:case => :already_exist, :more => "Splash WebAdmin Process already launched "}
|
35
35
|
end
|
@@ -64,7 +64,7 @@ module Splash
|
|
64
64
|
# @param [Hash] options
|
65
65
|
# @option options [Symbol] :quiet activate quiet mode for log (limit to :fatal)
|
66
66
|
# @return [Hash] Exiter Case (:quiet_exit, :not_found, other)
|
67
|
-
def
|
67
|
+
def stopweb(options = {})
|
68
68
|
config = get_config
|
69
69
|
log = get_logger
|
70
70
|
log.level = :fatal if options[:quiet]
|
@@ -86,7 +86,7 @@ module Splash
|
|
86
86
|
# Status of the Splash WebAdmin, display status
|
87
87
|
# @param [Hash] options ignored
|
88
88
|
# @return [Hash] Exiter Case (:status_ko, :status_ok)
|
89
|
-
def
|
89
|
+
def statusweb(options = {})
|
90
90
|
log = get_logger
|
91
91
|
config = get_config
|
92
92
|
pid = realpid = ''
|
@@ -5,7 +5,7 @@
|
|
5
5
|
WebAdminApp.get '/api/commands/list.?:format?' do
|
6
6
|
log = get_logger
|
7
7
|
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
|
8
|
-
log.call "
|
8
|
+
log.call "API : commands, verb : GET, route : list, format : #{format}"
|
9
9
|
obj = splash_return case: :quiet_exit, :more => "Commands list"
|
10
10
|
obj[:data] = get_config.commands
|
11
11
|
content_type format
|
@@ -15,7 +15,7 @@ WebAdminApp.get '/api/commands/list.?:format?' do
|
|
15
15
|
WebAdminApp.get '/api/commands/show/:name.?:format?' do
|
16
16
|
log = get_logger
|
17
17
|
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
|
18
|
-
log.call "
|
18
|
+
log.call "API : commands, verb : GET, route : show, item : #{params[:name]} , format : #{format}"
|
19
19
|
commands_recordset = get_config.commands[params[:name].to_sym]
|
20
20
|
unless commands_recordset.nil? then
|
21
21
|
obj = splash_return case: :quiet_exit
|
@@ -1,10 +1,61 @@
|
|
1
1
|
WebAdminApp.get '/api/config/full.?:format?' do
|
2
2
|
log = get_logger
|
3
3
|
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
|
4
|
-
log.call "
|
4
|
+
log.call "API : config, verb : GET, route : full, format : #{format}"
|
5
5
|
config = get_config.full
|
6
|
-
obj = splash_return case: :quiet_exit, :more => "
|
6
|
+
obj = splash_return case: :quiet_exit, :more => "Show internal Splash Config"
|
7
7
|
obj[:data] = config
|
8
8
|
content_type format
|
9
9
|
format_response(obj, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
|
10
10
|
end
|
11
|
+
|
12
|
+
WebAdminApp.get '/api/config/fromfile.?:format?' do
|
13
|
+
log = get_logger
|
14
|
+
fromfile = {}
|
15
|
+
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
|
16
|
+
log.call "API : config, verb : GET, route : fromfile, format : #{format}"
|
17
|
+
config = get_config.config_from_file
|
18
|
+
fromfile = splash_return case: :quiet_exit, :more => "Show config from file"
|
19
|
+
fromfile[:data] = config
|
20
|
+
content_type format
|
21
|
+
format_response(fromfile, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
WebAdminApp.post '/api/config/addlog.?:format?' do
|
26
|
+
log = get_logger
|
27
|
+
addlog = {}
|
28
|
+
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
|
29
|
+
log.call "API : config, verb : POST, route : addlog, format : #{format}"
|
30
|
+
res = get_config.add_log :record => YAML::load(request.body.read), :type => :logs, :clean => true
|
31
|
+
case res[:status]
|
32
|
+
when :success
|
33
|
+
addlog = splash_return case: :quiet_exit, :more => "add logs"
|
34
|
+
when :already_exist
|
35
|
+
addlog = splash_return case: :already_exist, :more => "add logs"
|
36
|
+
when :failure
|
37
|
+
addlog = splash_return case: :configuration_error, :more => "add logs"
|
38
|
+
addlog[:data] = res
|
39
|
+
end
|
40
|
+
content_type format
|
41
|
+
format_response(addlog, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
WebAdminApp.delete '/api/config/deletelog/:label.?:format?' do
|
46
|
+
log = get_logger
|
47
|
+
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
|
48
|
+
log.call "API : config, verb : DELETE, route : deletelog, format : #{format}"
|
49
|
+
res = get_config.delete_log label: params[:label].to_sym
|
50
|
+
deletelog = {}
|
51
|
+
case res[:status]
|
52
|
+
when :success
|
53
|
+
deletelog = splash_return case: :quiet_exit, :more => "delete logs"
|
54
|
+
when :not_found
|
55
|
+
deletelog = splash_return case: :not_found, :more => "delete logs"
|
56
|
+
else
|
57
|
+
deletelog = splash_return case: :configuration_error, :more => "delete logs"
|
58
|
+
end
|
59
|
+
content_type format
|
60
|
+
format_response(deletelog, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
|
61
|
+
end
|
@@ -4,56 +4,71 @@
|
|
4
4
|
|
5
5
|
WebAdminApp.get '/api/logs/list.?:format?' do
|
6
6
|
log = get_logger
|
7
|
+
list = {}
|
7
8
|
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
|
8
|
-
log.call "
|
9
|
+
log.call "API : logs, verb : GET, route : list, format : #{format}"
|
9
10
|
logs_recordset = get_config.logs
|
10
|
-
|
11
|
-
|
11
|
+
list = splash_return case: :quiet_exit, :more => "logs list"
|
12
|
+
list[:data] = logs_recordset
|
12
13
|
content_type format
|
13
|
-
format_response(
|
14
|
+
format_response(list, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
|
14
15
|
end
|
15
16
|
|
16
17
|
WebAdminApp.get '/api/logs/show/:name.?:format?' do
|
17
18
|
log = get_logger
|
18
19
|
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
|
19
|
-
log.call "
|
20
|
+
log.call "API : logs, verb : GET, route : show, item : #{params[:name]} , format : #{format}"
|
20
21
|
logs_recordset = get_config.logs.select{|item| item[:label] == params[:name].to_sym }
|
22
|
+
show = {}
|
21
23
|
unless logs_recordset.empty? then
|
22
24
|
record = logs_recordset.first
|
23
|
-
|
24
|
-
|
25
|
+
show = splash_return case: :quiet_exit
|
26
|
+
show[:data] = record
|
27
|
+
status 201
|
25
28
|
else
|
26
|
-
|
29
|
+
show = splash_return case: :not_found, :more => "logs not configured"
|
27
30
|
end
|
28
|
-
format_response(
|
31
|
+
format_response(show, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
|
29
32
|
end
|
30
33
|
|
31
34
|
WebAdminApp.post '/api/logs/analyse.?:format?' do
|
32
35
|
log = get_logger
|
33
36
|
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
|
34
|
-
log.call "
|
37
|
+
log.call "API : logs, verb : POST, route : analyse, format : #{format}"
|
35
38
|
results = Splash::Logs::LogScanner::new
|
36
39
|
results.analyse
|
37
40
|
res = results.output
|
38
|
-
|
39
|
-
|
41
|
+
analyse = splash_return case: :quiet_exit, :more => "logs analyse report"
|
42
|
+
analyse[:data] = res
|
40
43
|
status 201
|
41
44
|
content_type format
|
42
|
-
format_response(
|
45
|
+
format_response(analyse, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
|
43
46
|
end
|
44
47
|
|
45
48
|
WebAdminApp.post '/api/logs/monitor.?:format?' do
|
46
49
|
log = get_logger
|
47
50
|
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
|
48
|
-
log.call "
|
51
|
+
log.call "API : logs, verb : POST, route : monitor, format : #{format}"
|
49
52
|
results = Splash::Logs::LogScanner::new
|
50
53
|
results.analyse
|
51
|
-
|
52
|
-
if
|
54
|
+
monitor = splash_return results.notify
|
55
|
+
if monitor[:status] == :failure then
|
53
56
|
status 503
|
54
57
|
else
|
55
58
|
status 201
|
56
59
|
end
|
57
60
|
content_type format
|
58
|
-
format_response(
|
61
|
+
format_response(monitor, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
|
62
|
+
end
|
63
|
+
|
64
|
+
WebAdminApp.get '/api/logs/history/:label.?:format?' do
|
65
|
+
log = get_logger
|
66
|
+
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
|
67
|
+
log.call "API : logs, verb : GET, route : history, format : #{format}"
|
68
|
+
record = Splash::Logs::LogsRecords::new(params[:label]).get_all_records
|
69
|
+
history = splash_return case: :quiet_exit, :more => "log monitoring history"
|
70
|
+
history[:data] = record
|
71
|
+
content_type format
|
72
|
+
status 201
|
73
|
+
format_response(history, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
|
59
74
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
WebAdminApp.get '/api/process/list.?:format?' do
|
6
6
|
log = get_logger
|
7
7
|
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
|
8
|
-
log.call "
|
8
|
+
log.call "API : process, verb : GET, route : list, format : #{format}"
|
9
9
|
process_recordset = get_config.processes
|
10
10
|
obj = splash_return case: :quiet_exit, :more => "Processes list"
|
11
11
|
obj[:data] = process_recordset
|
@@ -16,7 +16,7 @@ WebAdminApp.get '/api/process/list.?:format?' do
|
|
16
16
|
WebAdminApp.get '/api/process/show/:name.?:format?' do
|
17
17
|
log = get_logger
|
18
18
|
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
|
19
|
-
log.call "
|
19
|
+
log.call "API : process, verb : GET, route : show, item : #{params[:name]} , format : #{format}"
|
20
20
|
process_recordset = get_config.processes.select{|item| item[:process] == params[:name] }
|
21
21
|
unless process_recordset.empty? then
|
22
22
|
record = process_recordset.first
|
@@ -32,7 +32,7 @@ end
|
|
32
32
|
WebAdminApp.post '/api/process/analyse.?:format?' do
|
33
33
|
log = get_logger
|
34
34
|
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
|
35
|
-
log.call "
|
35
|
+
log.call "API : process, verb : POST, route : analyse, format : #{format}"
|
36
36
|
results = Splash::Processes::ProcessScanner::new
|
37
37
|
results.analyse
|
38
38
|
res = results.output
|
@@ -46,7 +46,7 @@ end
|
|
46
46
|
WebAdminApp.post '/api/process/monitor.?:format?' do
|
47
47
|
log = get_logger
|
48
48
|
format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
|
49
|
-
log.call "
|
49
|
+
log.call "API : process, verb : POST, route : monitor, format : #{format}"
|
50
50
|
results = Splash::Processes::ProcessScanner::new
|
51
51
|
results.analyse
|
52
52
|
res = splash_return results.notify
|