prometheus-splash 0.4.5 → 0.6.1

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 (99) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +64 -2
  3. data/README.md +58 -60
  4. data/bin/splash +13 -5
  5. data/config/splash.yml +77 -7
  6. data/lib/splash/backends.rb +6 -0
  7. data/lib/splash/backends/file.rb +40 -0
  8. data/lib/splash/backends/redis.rb +47 -4
  9. data/lib/splash/cli.rb +31 -3
  10. data/lib/splash/cli/commands.rb +82 -33
  11. data/lib/splash/cli/config.rb +25 -4
  12. data/lib/splash/cli/daemon.rb +11 -14
  13. data/lib/splash/cli/documentation.rb +5 -2
  14. data/lib/splash/cli/logs.rb +27 -17
  15. data/lib/splash/cli/process.rb +103 -0
  16. data/lib/splash/cli/sequences.rb +112 -0
  17. data/lib/splash/cli/webadmin.rb +46 -0
  18. data/lib/splash/commands.rb +146 -120
  19. data/lib/splash/config.rb +170 -15
  20. data/lib/splash/config/flush.rb +30 -0
  21. data/lib/splash/config/sanitycheck.rb +7 -2
  22. data/lib/splash/config/service.rb +33 -0
  23. data/lib/splash/config/setup.rb +8 -3
  24. data/lib/splash/constants.rb +37 -8
  25. data/lib/splash/daemon.rb +6 -0
  26. data/lib/splash/daemon/controller.rb +136 -0
  27. data/lib/splash/daemon/metrics.rb +103 -0
  28. data/lib/splash/daemon/orchestrator.rb +182 -0
  29. data/lib/splash/daemon/orchestrator/grammar.rb +76 -0
  30. data/lib/splash/daemon/orchestrator/hooks.rb +28 -0
  31. data/lib/splash/dependencies.rb +17 -2
  32. data/lib/splash/exiter.rb +15 -0
  33. data/lib/splash/helpers.rb +91 -50
  34. data/lib/splash/loggers.rb +48 -17
  35. data/lib/splash/loggers/cli.rb +18 -3
  36. data/lib/splash/loggers/daemon.rb +23 -4
  37. data/lib/splash/loggers/dual.rb +35 -2
  38. data/lib/splash/loggers/web.rb +51 -0
  39. data/lib/splash/logs.rb +67 -53
  40. data/lib/splash/processes.rb +83 -0
  41. data/lib/splash/sequences.rb +105 -0
  42. data/lib/splash/templates.rb +10 -0
  43. data/lib/splash/transports.rb +9 -0
  44. data/lib/splash/transports/rabbitmq.rb +33 -4
  45. data/lib/splash/webadmin.rb +122 -0
  46. data/lib/splash/webadmin/api/routes/commands.rb +28 -0
  47. data/lib/splash/webadmin/api/routes/config.rb +10 -0
  48. data/lib/splash/webadmin/api/routes/init.rb +2 -0
  49. data/lib/splash/webadmin/api/routes/logs.rb +59 -0
  50. data/lib/splash/webadmin/api/routes/process.rb +60 -0
  51. data/lib/splash/webadmin/main.rb +26 -0
  52. data/lib/splash/webadmin/portal/controllers/commands.rb +7 -0
  53. data/lib/splash/webadmin/portal/controllers/documentation.rb +6 -0
  54. data/lib/splash/webadmin/portal/controllers/home.rb +12 -0
  55. data/lib/splash/webadmin/portal/controllers/logs.rb +14 -0
  56. data/lib/splash/webadmin/portal/controllers/notfound.rb +5 -0
  57. data/lib/splash/webadmin/portal/controllers/processes.rb +14 -0
  58. data/lib/splash/webadmin/portal/controllers/proxy.rb +28 -0
  59. data/lib/splash/webadmin/portal/controllers/restclient.rb +19 -0
  60. data/lib/splash/webadmin/portal/init.rb +11 -0
  61. data/lib/splash/webadmin/portal/public/css/ultragreen.css +8544 -0
  62. data/lib/splash/webadmin/portal/public/fonts/FontAwesome.otf +0 -0
  63. data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.ttf +0 -0
  64. data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff +0 -0
  65. data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff2 +0 -0
  66. data/lib/splash/webadmin/portal/public/images/logo_splash.png +0 -0
  67. data/lib/splash/webadmin/portal/public/images/logo_splash_reduce.png +0 -0
  68. data/lib/splash/webadmin/portal/public/images/logo_splash_tiny.png +0 -0
  69. data/lib/splash/webadmin/portal/views/commands.slim +49 -0
  70. data/lib/splash/webadmin/portal/views/documentation.slim +3 -0
  71. data/lib/splash/webadmin/portal/views/home.slim +78 -0
  72. data/lib/splash/webadmin/portal/views/layout.slim +43 -0
  73. data/lib/splash/webadmin/portal/views/logs.slim +32 -0
  74. data/lib/splash/webadmin/portal/views/nav.slim +17 -0
  75. data/lib/splash/webadmin/portal/views/not_found.slim +3 -0
  76. data/lib/splash/webadmin/portal/views/processes.slim +29 -0
  77. data/lib/splash/webadmin/portal/views/proxy.slim +13 -0
  78. data/lib/splash/webadmin/portal/views/restclient.slim +41 -0
  79. data/lib/splash/webadmin/portal/views/restclient_result.slim +29 -0
  80. data/prometheus-splash.gemspec +8 -1
  81. data/spec/helpers_spec.rb +119 -0
  82. data/templates/ansible-splash/Vagrantfile +1 -1
  83. data/templates/ansible-splash/deploy.yml +28 -1
  84. data/templates/ansible-splash/group_vars/DEV.yml +2 -0
  85. data/templates/ansible-splash/roles/mq/handlers/main.yml +1 -1
  86. data/templates/ansible-splash/roles/mq/tasks/main.yml +17 -1
  87. data/templates/ansible-splash/roles/mq/templates/rabbitmq-env.conf.j2 +13 -0
  88. data/templates/ansible-splash/roles/splash/handlers/main.yml +4 -0
  89. data/templates/ansible-splash/roles/splash/tasks/main.yml +25 -1
  90. data/templates/ansible-splash/roles/splash/templates/logrotate.splash.j2 +11 -0
  91. data/templates/ansible-splash/roles/splash/templates/splash.yml.j2 +1 -1
  92. data/templates/splashd.service +1 -1
  93. data/test.sh +42 -0
  94. metadata +159 -11
  95. data/lib/splash/controller.rb +0 -90
  96. data/lib/splash/orchestrator.rb +0 -100
  97. data/lib/splash/orchestrator/grammar.rb +0 -53
  98. data/lib/splash/orchestrator/hooks.rb +0 -16
  99. data/templates/ansible-splash/inventory.prod +0 -26
@@ -1,90 +0,0 @@
1
- # coding: utf-8
2
- module Splash
3
- module LogsMonitor
4
- module DaemonController
5
- include Splash::Constants
6
- include Splash::Helpers
7
- include Splash::Config
8
- include Splash::Orchestrator
9
- include Splash::Exiter
10
- include Splash::Loggers
11
-
12
- def startdaemon(options = {})
13
- config = get_config
14
- log = get_logger
15
- unless verify_service host: config.prometheus_pushgateway_host ,port: config.prometheus_pushgateway_port then
16
- return {:case => :service_dependence_missing, :more => 'Prometheus Gateway'}
17
- end
18
- unless File::exist? config.full_pid_path then
19
- daemon_config = {:description => config.daemon_process_name,
20
- :pid_file => config.full_pid_path,
21
- :stdout_trace => config.full_stdout_trace_path,
22
- :stderr_trace => config.full_stderr_trace_path,
23
- :foreground => options[:foreground]
24
- }
25
-
26
- ["int","term","hup"].each do |type| daemon_config["sig#{type}_handler".to_sym] = Proc::new { ObjectSpace.each_object(Splash::Orchestrator::Scheduler).first.shutdown } end
27
- res = daemonize daemon_config do
28
- Scheduler::new options
29
- end
30
- sleep 1
31
- if res == 0 then
32
- pid = `cat #{config.full_pid_path}`.to_i
33
- log.ok "Splash Daemon Started, with PID : #{pid}"
34
- return {:case => :quiet_exit, :more => "Splash Daemon successfully loaded."}
35
- else
36
- return {:case => :unknown_error, :more => "Splash Daemon loading error, see logs for more details."}
37
- end
38
-
39
- else
40
- return {:case => :already_exist, :more => "Pid File, please verify if Splash daemon is running."}
41
- end
42
- end
43
-
44
- def stopdaemon(options = {})
45
- config = get_config
46
- if File.exist?(config.full_pid_path) then
47
- begin
48
- pid = `cat #{config.full_pid_path}`.to_i
49
- Process.kill("TERM", pid)
50
- acase = {:case => :quiet_exit, :more => 'Splash stopped succesfully'}
51
- rescue Errno::ESRCH
52
- acase = {:case => :not_found, :more => "Process of PID : #{pid} not found"}
53
- end
54
- FileUtils::rm config.full_pid_path if File::exist? config.full_pid_path
55
- else
56
- acase = {:case => :not_found, :more => "Splash is not running"}
57
- end
58
- return acase
59
- end
60
-
61
- def statusdaemon(options = {})
62
- log = get_logger
63
- config = get_config
64
- pid = realpid = ''
65
- pid = `cat #{config.full_pid_path}`.to_s if File.exist?(config.full_pid_path)
66
- realpid = get_process pattern: get_config.daemon_process_name
67
- pid.chomp!
68
- realpid.chomp!
69
- unless realpid.empty? then
70
- log.item "Splash Process is running with PID #{realpid} "
71
- else
72
- log.item 'Splash Process not found '
73
- end
74
- unless pid.empty? then
75
- log.item "and PID file exist with PID #{pid}"
76
- else
77
- log.item "and PID file don't exist"
78
- end
79
- if pid == realpid then
80
- return {:case => :status_ok }
81
- elsif pid.empty? then
82
- return {:case => :status_ko, :more => "PID File error, you have to kill process manualy, with : '(sudo )kill -TERM #{realpid}'"}
83
- elsif realpid.empty? then
84
- return {:case => :status_ko, :more => "Process Splash Dameon missing, run 'splash daemon stop' to reload properly"}
85
- end
86
- end
87
-
88
- end
89
- end
90
- end
@@ -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
- @log.trigger "Logs monitoring for Scheduling : #{sched.to_s} #{value.to_s}"
35
- @result.analyse
36
- @result.notify
37
- rescue Errno::ECONNREFUSED
38
- @log.error "PushGateway seems to be done, please start it."
39
- end
40
- end
41
- hostname = Socket.gethostname
42
- transport = get_default_subscriber queue: "splash.#{hostname}.input"
43
- if transport.class == Hash and transport.include? :case then
44
- splash_exit transport
45
- end
46
- transport.subscribe(:block => true) do |delivery_info, properties, body|
47
- content = YAML::load(body)
48
- if VERBS.include? content[:verb]
49
- @log.receive "Valid remote order, verb : #{content[:verb].to_s}"
50
- if content[:payload] then
51
- res = self.send content[:verb], content[:payload]
52
- else
53
- res = self.send content[:verb]
54
- end
55
- get_default_client.publish queue: content[:return_to], message: res.to_yaml
56
- @log.send "Result to #{content[:return_to]}."
57
- else
58
- @log.receive "INVALID remote order, verb : #{content[:verb].to_s}"
59
- get_default_client.publish queue: content[:return_to], message: "Unkown verb #{content[:verb]}".to_yaml
60
- end
61
- end
62
- end
63
-
64
- def terminate
65
- @log.info "Splash daemon shutdown"
66
- @server.shutdown
67
- change_logger logger: :cli
68
- splash_exit case: :quiet_exit
69
- end
70
-
71
- private
72
- def init_commands_scheduling
73
- config = get_config.commands
74
- commands = config.select{|key,value| value.include? :schedule}.keys
75
- commands.each do |command|
76
- sched,value = config[command][:schedule].flatten
77
- @log.arrow "Scheduling command #{command.to_s}"
78
- @server.send sched,value do
79
- @log.trigger "Executing Scheduled command #{command.to_s} for Scheduling : #{sched.to_s} #{value.to_s}"
80
- execute command: command.to_s
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
92
- end
93
- end
94
-
95
- end
96
-
97
-
98
- end
99
-
100
- end
@@ -1,53 +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(payload)
18
- return "Pong : #{payload[:hostname]} !"
19
- end
20
-
21
-
22
- def list_commands
23
- return get_config.commands
24
- end
25
-
26
- def ack_command(payload)
27
- return execute command: payload[:name], ack: true
28
- end
29
-
30
-
31
- def execute_command(payload)
32
- unless get_config.commands.include? payload[:name].to_sym
33
- @log.item "Command not found"
34
- return { :case => :not_found }
35
- end
36
- if payload.include? :schedule then
37
- sched,value = payload[:schedule].flatten
38
- @log.schedule "remote call command #{payload[:name]}, scheduling : #{sched.to_s} #{value}"
39
- @server.send sched,value do
40
- @log.trigger "Executing Scheduled command #{payload[:name]} for Scheduling : #{sched.to_s} #{value}"
41
- execute command: payload[:name]
42
- end
43
- return { :case => :quiet_exit }
44
- else
45
- @log.info "Execute direct command"
46
- res = execute command: payload[:name]
47
- return res
48
- end
49
- end
50
-
51
- end
52
- end
53
- end
@@ -1,16 +0,0 @@
1
- # coding: utf-8
2
- module Splash
3
- module Orchestrator
4
-
5
- module SchedulerHooks
6
- def on_pre_trigger(job, trigger_time)
7
-
8
- end
9
-
10
- def on_post_trigger(job, trigger_time)
11
-
12
- end
13
-
14
- end
15
- end
16
- end
@@ -1,26 +0,0 @@
1
- # TEMPLATE
2
- [PROD:children]
3
- backend
4
- mq
5
- splash_nodes
6
- supervision_master
7
- supervision_gateway
8
-
9
-
10
- [backend]
11
- backend ansible_host=X.X.X.X
12
-
13
- [mq]
14
- mq ansible_host=X.X.X.X
15
-
16
-
17
- [splash_nodes]
18
- node1 ansible_host=X.X.X.X
19
- node2 ansible_host=X.X.X.X
20
-
21
-
22
- [supervision_gateway]
23
- pushgateway ansible_host=X.X.X.X
24
-
25
- [supervision_master]
26
- prometheus ansible_host=X.X.X.X