prometheus-splash 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -0
- data/README.md +58 -60
- data/bin/splash +3 -0
- data/config/splash.yml +77 -7
- data/lib/splash/backends.rb +6 -0
- data/lib/splash/backends/file.rb +40 -0
- data/lib/splash/backends/redis.rb +47 -4
- data/lib/splash/cli.rb +18 -5
- data/lib/splash/cli/commands.rb +26 -18
- data/lib/splash/cli/config.rb +16 -2
- data/lib/splash/cli/daemon.rb +10 -3
- data/lib/splash/cli/documentation.rb +5 -2
- data/lib/splash/cli/logs.rb +25 -16
- data/lib/splash/cli/process.rb +103 -0
- data/lib/splash/cli/sequences.rb +114 -0
- data/lib/splash/cli/webadmin.rb +46 -0
- data/lib/splash/commands.rb +146 -122
- data/lib/splash/config.rb +166 -14
- data/lib/splash/config/flush.rb +30 -0
- data/lib/splash/config/sanitycheck.rb +7 -2
- data/lib/splash/config/service.rb +8 -1
- data/lib/splash/config/setup.rb +8 -3
- data/lib/splash/constants.rb +37 -8
- data/lib/splash/daemon.rb +6 -0
- data/lib/splash/{controller.rb → daemon/controller.rb} +34 -14
- data/lib/splash/daemon/metrics.rb +103 -0
- data/lib/splash/daemon/orchestrator.rb +182 -0
- data/lib/splash/daemon/orchestrator/grammar.rb +76 -0
- data/lib/splash/daemon/orchestrator/hooks.rb +28 -0
- data/lib/splash/dependencies.rb +16 -2
- data/lib/splash/exiter.rb +14 -0
- data/lib/splash/helpers.rb +84 -48
- data/lib/splash/loggers.rb +40 -13
- data/lib/splash/loggers/cli.rb +18 -3
- data/lib/splash/loggers/daemon.rb +14 -3
- data/lib/splash/loggers/dual.rb +35 -2
- data/lib/splash/loggers/web.rb +51 -0
- data/lib/splash/logs.rb +67 -54
- data/lib/splash/processes.rb +83 -0
- data/lib/splash/sequences.rb +105 -0
- data/lib/splash/templates.rb +10 -0
- data/lib/splash/transports.rb +9 -0
- data/lib/splash/transports/rabbitmq.rb +33 -4
- data/lib/splash/webadmin.rb +122 -0
- data/lib/splash/webadmin/api/routes/commands.rb +28 -0
- data/lib/splash/webadmin/api/routes/config.rb +10 -0
- data/lib/splash/webadmin/api/routes/init.rb +2 -0
- data/lib/splash/webadmin/api/routes/logs.rb +59 -0
- data/lib/splash/webadmin/api/routes/process.rb +60 -0
- data/lib/splash/webadmin/api/routes/sequences.rb +28 -0
- data/lib/splash/webadmin/main.rb +26 -0
- data/lib/splash/webadmin/portal/controllers/commands.rb +7 -0
- data/lib/splash/webadmin/portal/controllers/documentation.rb +6 -0
- data/lib/splash/webadmin/portal/controllers/home.rb +12 -0
- data/lib/splash/webadmin/portal/controllers/logs.rb +14 -0
- data/lib/splash/webadmin/portal/controllers/notfound.rb +5 -0
- data/lib/splash/webadmin/portal/controllers/processes.rb +14 -0
- data/lib/splash/webadmin/portal/controllers/proxy.rb +28 -0
- data/lib/splash/webadmin/portal/controllers/restclient.rb +19 -0
- data/lib/splash/webadmin/portal/controllers/sequences.rb +7 -0
- data/lib/splash/webadmin/portal/init.rb +11 -0
- data/lib/splash/webadmin/portal/public/css/ultragreen.css +8544 -0
- data/lib/splash/webadmin/portal/public/fonts/FontAwesome.otf +0 -0
- data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.ttf +0 -0
- data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff +0 -0
- data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff2 +0 -0
- data/lib/splash/webadmin/portal/public/images/logo_splash.png +0 -0
- data/lib/splash/webadmin/portal/public/images/logo_splash_reduce.png +0 -0
- data/lib/splash/webadmin/portal/public/images/logo_splash_tiny.png +0 -0
- data/lib/splash/webadmin/portal/views/commands.slim +49 -0
- data/lib/splash/webadmin/portal/views/documentation.slim +3 -0
- data/lib/splash/webadmin/portal/views/home.slim +78 -0
- data/lib/splash/webadmin/portal/views/layout.slim +43 -0
- data/lib/splash/webadmin/portal/views/logs.slim +32 -0
- data/lib/splash/webadmin/portal/views/nav.slim +17 -0
- data/lib/splash/webadmin/portal/views/not_found.slim +3 -0
- data/lib/splash/webadmin/portal/views/processes.slim +29 -0
- data/lib/splash/webadmin/portal/views/proxy.slim +13 -0
- data/lib/splash/webadmin/portal/views/restclient.slim +41 -0
- data/lib/splash/webadmin/portal/views/restclient_result.slim +29 -0
- data/lib/splash/webadmin/portal/views/sequences.slim +50 -0
- data/prometheus-splash.gemspec +7 -1
- data/spec/helpers_spec.rb +119 -0
- data/templates/ansible-splash/roles/splash/handlers/main.yml +4 -0
- data/templates/ansible-splash/roles/splash/tasks/main.yml +24 -1
- data/templates/ansible-splash/roles/splash/templates/logrotate.splash.j2 +11 -0
- data/templates/ansible-splash/roles/splash/templates/splash.yml.j2 +1 -1
- metadata +145 -10
- data/lib/splash/orchestrator.rb +0 -100
- data/lib/splash/orchestrator/grammar.rb +0 -54
- data/lib/splash/orchestrator/hooks.rb +0 -16
@@ -26,4 +26,27 @@
|
|
26
26
|
owner: root
|
27
27
|
group: root
|
28
28
|
mode: 0644
|
29
|
-
|
29
|
+
notify: restart Splashd
|
30
|
+
|
31
|
+
- name: SPLASH Check if Systemd service installed
|
32
|
+
stat:
|
33
|
+
path: /etc/systemd/system/splashd.service
|
34
|
+
register: stat_splash_result
|
35
|
+
|
36
|
+
- name: SPLASH Install systemd service
|
37
|
+
shell: splash conf service
|
38
|
+
when: not stat_splash_result.stat.exists
|
39
|
+
|
40
|
+
- name: SPLASH Splashd running
|
41
|
+
service:
|
42
|
+
name: splashd
|
43
|
+
state: started
|
44
|
+
enabled: yes
|
45
|
+
|
46
|
+
- name: SPLASH LogRotate template
|
47
|
+
template:
|
48
|
+
src: logrotate.splash.j2
|
49
|
+
dest: /etc/logrotate.d/splash
|
50
|
+
owner: root
|
51
|
+
group: root
|
52
|
+
mode: 0644
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prometheus-splash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Romain GEORGES
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -136,6 +136,90 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 0.8.1
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: sinatra
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 2.1.0
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 2.1.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: thin
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 1.7.2
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 1.7.2
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rest-client
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 2.1.0
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 2.1.0
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: slim
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 4.1.0
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 4.1.0
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: kramdown
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 1.16.2
|
202
|
+
type: :runtime
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: 1.16.2
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: rack-reverse-proxy
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - "~>"
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: 0.12.0
|
216
|
+
type: :runtime
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - "~>"
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: 0.12.0
|
139
223
|
- !ruby/object:Gem::Dependency
|
140
224
|
name: rake
|
141
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -265,13 +349,22 @@ files:
|
|
265
349
|
- lib/splash/cli/daemon.rb
|
266
350
|
- lib/splash/cli/documentation.rb
|
267
351
|
- lib/splash/cli/logs.rb
|
352
|
+
- lib/splash/cli/process.rb
|
353
|
+
- lib/splash/cli/sequences.rb
|
354
|
+
- lib/splash/cli/webadmin.rb
|
268
355
|
- lib/splash/commands.rb
|
269
356
|
- lib/splash/config.rb
|
357
|
+
- lib/splash/config/flush.rb
|
270
358
|
- lib/splash/config/sanitycheck.rb
|
271
359
|
- lib/splash/config/service.rb
|
272
360
|
- lib/splash/config/setup.rb
|
273
361
|
- lib/splash/constants.rb
|
274
|
-
- lib/splash/
|
362
|
+
- lib/splash/daemon.rb
|
363
|
+
- lib/splash/daemon/controller.rb
|
364
|
+
- lib/splash/daemon/metrics.rb
|
365
|
+
- lib/splash/daemon/orchestrator.rb
|
366
|
+
- lib/splash/daemon/orchestrator/grammar.rb
|
367
|
+
- lib/splash/daemon/orchestrator/hooks.rb
|
275
368
|
- lib/splash/dependencies.rb
|
276
369
|
- lib/splash/exiter.rb
|
277
370
|
- lib/splash/helpers.rb
|
@@ -279,14 +372,53 @@ files:
|
|
279
372
|
- lib/splash/loggers/cli.rb
|
280
373
|
- lib/splash/loggers/daemon.rb
|
281
374
|
- lib/splash/loggers/dual.rb
|
375
|
+
- lib/splash/loggers/web.rb
|
282
376
|
- lib/splash/logs.rb
|
283
|
-
- lib/splash/
|
284
|
-
- lib/splash/
|
285
|
-
- lib/splash/orchestrator/hooks.rb
|
377
|
+
- lib/splash/processes.rb
|
378
|
+
- lib/splash/sequences.rb
|
286
379
|
- lib/splash/templates.rb
|
287
380
|
- lib/splash/transports.rb
|
288
381
|
- lib/splash/transports/rabbitmq.rb
|
382
|
+
- lib/splash/webadmin.rb
|
383
|
+
- lib/splash/webadmin/api/routes/commands.rb
|
384
|
+
- lib/splash/webadmin/api/routes/config.rb
|
385
|
+
- lib/splash/webadmin/api/routes/init.rb
|
386
|
+
- lib/splash/webadmin/api/routes/logs.rb
|
387
|
+
- lib/splash/webadmin/api/routes/process.rb
|
388
|
+
- lib/splash/webadmin/api/routes/sequences.rb
|
389
|
+
- lib/splash/webadmin/main.rb
|
390
|
+
- lib/splash/webadmin/portal/controllers/commands.rb
|
391
|
+
- lib/splash/webadmin/portal/controllers/documentation.rb
|
392
|
+
- lib/splash/webadmin/portal/controllers/home.rb
|
393
|
+
- lib/splash/webadmin/portal/controllers/logs.rb
|
394
|
+
- lib/splash/webadmin/portal/controllers/notfound.rb
|
395
|
+
- lib/splash/webadmin/portal/controllers/processes.rb
|
396
|
+
- lib/splash/webadmin/portal/controllers/proxy.rb
|
397
|
+
- lib/splash/webadmin/portal/controllers/restclient.rb
|
398
|
+
- lib/splash/webadmin/portal/controllers/sequences.rb
|
399
|
+
- lib/splash/webadmin/portal/init.rb
|
400
|
+
- lib/splash/webadmin/portal/public/css/ultragreen.css
|
401
|
+
- lib/splash/webadmin/portal/public/fonts/FontAwesome.otf
|
402
|
+
- lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.ttf
|
403
|
+
- lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff
|
404
|
+
- lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff2
|
405
|
+
- lib/splash/webadmin/portal/public/images/logo_splash.png
|
406
|
+
- lib/splash/webadmin/portal/public/images/logo_splash_reduce.png
|
407
|
+
- lib/splash/webadmin/portal/public/images/logo_splash_tiny.png
|
408
|
+
- lib/splash/webadmin/portal/views/commands.slim
|
409
|
+
- lib/splash/webadmin/portal/views/documentation.slim
|
410
|
+
- lib/splash/webadmin/portal/views/home.slim
|
411
|
+
- lib/splash/webadmin/portal/views/layout.slim
|
412
|
+
- lib/splash/webadmin/portal/views/logs.slim
|
413
|
+
- lib/splash/webadmin/portal/views/nav.slim
|
414
|
+
- lib/splash/webadmin/portal/views/not_found.slim
|
415
|
+
- lib/splash/webadmin/portal/views/processes.slim
|
416
|
+
- lib/splash/webadmin/portal/views/proxy.slim
|
417
|
+
- lib/splash/webadmin/portal/views/restclient.slim
|
418
|
+
- lib/splash/webadmin/portal/views/restclient_result.slim
|
419
|
+
- lib/splash/webadmin/portal/views/sequences.slim
|
289
420
|
- prometheus-splash.gemspec
|
421
|
+
- spec/helpers_spec.rb
|
290
422
|
- spec/templates_spec.rb
|
291
423
|
- templates/ansible-splash/Vagrantfile
|
292
424
|
- templates/ansible-splash/deploy.yml
|
@@ -300,7 +432,9 @@ files:
|
|
300
432
|
- templates/ansible-splash/roles/mq/handlers/main.yml
|
301
433
|
- templates/ansible-splash/roles/mq/tasks/main.yml
|
302
434
|
- templates/ansible-splash/roles/mq/templates/rabbitmq-env.conf.j2
|
435
|
+
- templates/ansible-splash/roles/splash/handlers/main.yml
|
303
436
|
- templates/ansible-splash/roles/splash/tasks/main.yml
|
437
|
+
- templates/ansible-splash/roles/splash/templates/logrotate.splash.j2
|
304
438
|
- templates/ansible-splash/roles/splash/templates/splash.yml.j2
|
305
439
|
- templates/ansible-splash/roles/supervision_gateway/handlers/main.yml
|
306
440
|
- templates/ansible-splash/roles/supervision_gateway/tasks/main.yml
|
@@ -312,11 +446,11 @@ files:
|
|
312
446
|
- templates/splashd.service
|
313
447
|
- test.sh
|
314
448
|
- ultragreen_roodi_coding_convention.yml
|
315
|
-
homepage:
|
449
|
+
homepage: https://github.com/Ultragreen/prometheus-splash
|
316
450
|
licenses:
|
317
451
|
- BSD-2-Clause
|
318
452
|
metadata: {}
|
319
|
-
post_install_message:
|
453
|
+
post_install_message:
|
320
454
|
rdoc_options: []
|
321
455
|
require_paths:
|
322
456
|
- lib
|
@@ -332,9 +466,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
332
466
|
version: '0'
|
333
467
|
requirements: []
|
334
468
|
rubygems_version: 3.1.2
|
335
|
-
signing_key:
|
469
|
+
signing_key:
|
336
470
|
specification_version: 4
|
337
471
|
summary: Supervision with Prometheus of Logs and Asynchronous tasks orchestration
|
338
472
|
for Services or Hosts
|
339
473
|
test_files:
|
474
|
+
- spec/helpers_spec.rb
|
340
475
|
- spec/templates_spec.rb
|
data/lib/splash/orchestrator.rb
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
Dir[File.dirname(__FILE__) + '/orchestrator/*.rb'].each {|file| require file }
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
module Splash
|
7
|
-
module Orchestrator
|
8
|
-
|
9
|
-
class Scheduler
|
10
|
-
include Splash::Constants
|
11
|
-
include Splash::Helpers
|
12
|
-
include Splash::Config
|
13
|
-
include Splash::Transports
|
14
|
-
include Splash::Orchestrator::Grammar
|
15
|
-
include Splash::Loggers
|
16
|
-
|
17
|
-
def initialize(options = {})
|
18
|
-
@log = get_logger
|
19
|
-
$stdout.sync = true
|
20
|
-
$stderr.sync = true
|
21
|
-
@server = Rufus::Scheduler::new
|
22
|
-
@server.extend SchedulerHooks
|
23
|
-
@config = get_config
|
24
|
-
@result = LogScanner::new
|
25
|
-
@log.info "Splash Orchestrator starting :"
|
26
|
-
if options[:scheduling] then
|
27
|
-
@log.item "Initializing commands Scheduling."
|
28
|
-
init_commands_scheduling
|
29
|
-
end
|
30
|
-
sched,value = @config.daemon_logmon_scheduling.flatten
|
31
|
-
@log.item "Initializing logs monitorings & notifications."
|
32
|
-
@server.send sched,value do
|
33
|
-
begin
|
34
|
-
session = get_session
|
35
|
-
@log.trigger "Logs monitoring for Scheduling : #{sched.to_s} #{value.to_s}", session
|
36
|
-
@result.analyse
|
37
|
-
@result.notify :session => session
|
38
|
-
rescue Errno::ECONNREFUSED
|
39
|
-
@log.error "PushGateway seems to be done, please start it.", session
|
40
|
-
end
|
41
|
-
end
|
42
|
-
hostname = Socket.gethostname
|
43
|
-
transport = get_default_subscriber queue: "splash.#{hostname}.input"
|
44
|
-
if transport.class == Hash and transport.include? :case then
|
45
|
-
splash_exit transport
|
46
|
-
end
|
47
|
-
transport.subscribe(:block => true) do |delivery_info, properties, body|
|
48
|
-
content = YAML::load(body)
|
49
|
-
session = get_session
|
50
|
-
content[:session] = session
|
51
|
-
if VERBS.include? content[:verb]
|
52
|
-
@log.receive "Valid remote order, verb : #{content[:verb].to_s}", session
|
53
|
-
res = self.send content[:verb], content
|
54
|
-
get_default_client.publish queue: content[:return_to], message: res.to_yaml
|
55
|
-
@log.send "Result to #{content[:return_to]}.", session
|
56
|
-
else
|
57
|
-
@log.receive "INVALID remote order, verb : #{content[:verb].to_s}", session
|
58
|
-
get_default_client.publish queue: content[:return_to], message: "Unkown verb #{content[:verb]}".to_yaml
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def terminate
|
64
|
-
@log.info "Splash daemon shutdown"
|
65
|
-
@server.shutdown
|
66
|
-
change_logger logger: :cli
|
67
|
-
splash_exit case: :quiet_exit
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
def init_commands_scheduling
|
72
|
-
config = get_config.commands
|
73
|
-
commands = config.select{|key,value| value.include? :schedule}.keys
|
74
|
-
commands.each do |command|
|
75
|
-
sched,value = config[command][:schedule].flatten
|
76
|
-
@log.arrow "Scheduling command #{command.to_s}"
|
77
|
-
@server.send sched,value do
|
78
|
-
session = get_session
|
79
|
-
@log.trigger "Executing Scheduled command #{command.to_s} for Scheduling : #{sched.to_s} #{value.to_s}", session
|
80
|
-
execute command: command.to_s, session: session
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
def execute(options)
|
87
|
-
command = Splash::CommandWrapper::new(options[:command])
|
88
|
-
if options[:ack] then
|
89
|
-
command.ack
|
90
|
-
else
|
91
|
-
return command.call_and_notify trace: true, notify: true, callback: true, session: options[:session]
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
end
|
99
|
-
|
100
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
module Splash
|
3
|
-
module Orchestrator
|
4
|
-
module Grammar
|
5
|
-
|
6
|
-
include Splash::Config
|
7
|
-
include Splash::Loggers
|
8
|
-
|
9
|
-
|
10
|
-
VERBS=[:ping,:list_commands,:execute_command,:ack_command, :shutdown]
|
11
|
-
|
12
|
-
|
13
|
-
def shutdown
|
14
|
-
terminate
|
15
|
-
end
|
16
|
-
|
17
|
-
def ping(content)
|
18
|
-
return "Pong : #{content[:payload][:hostname]} !"
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
def list_commands(content)
|
23
|
-
return get_config.commands
|
24
|
-
end
|
25
|
-
|
26
|
-
def ack_command(content)
|
27
|
-
return execute command: content[:payload][:name], ack: true
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
def execute_command(content)
|
32
|
-
payload = content[:payload]
|
33
|
-
unless get_config.commands.include? payload[:name].to_sym
|
34
|
-
@log.item "Command not found", content[:session]
|
35
|
-
return { :case => :not_found }
|
36
|
-
end
|
37
|
-
if payload.include? :schedule then
|
38
|
-
sched,value = payload[:schedule].flatten
|
39
|
-
@log.schedule "remote call command #{payload[:name]}, scheduling : #{sched.to_s} #{value}", content[:session]
|
40
|
-
@server.send sched,value do
|
41
|
-
@log.trigger "Executing Scheduled command #{payload[:name]} for Scheduling : #{sched.to_s} #{value}", content[:session]
|
42
|
-
execute command: payload[:name], session: content[:session]
|
43
|
-
end
|
44
|
-
return { :case => :quiet_exit }
|
45
|
-
else
|
46
|
-
@log.info "Execute direct command", content[:session]
|
47
|
-
res = execute command: payload[:name], session: content[:session]
|
48
|
-
return res
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|