prometheus-splash 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,10 +2,10 @@
2
2
 
3
3
 
4
4
 
5
- WebAdminApp.get '/api/process/list.?:format?' do
5
+ WebAdminApp.get '/api/processes/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 "API : process, verb : GET, route : list, format : #{format}"
8
+ log.call "API : processes, 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
@@ -13,11 +13,11 @@ WebAdminApp.get '/api/process/list.?:format?' do
13
13
  format_response(obj, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
14
14
  end
15
15
 
16
- WebAdminApp.get '/api/process/show/:name.?:format?' do
16
+ WebAdminApp.get '/api/processes/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 "API : process, verb : GET, route : show, item : #{params[:name]} , format : #{format}"
20
- process_recordset = get_config.processes.select{|item| item[:process] == params[:name] }
19
+ log.call "API : processes, verb : GET, route : show, item : #{params[:name]} , format : #{format}"
20
+ process_recordset = get_config.processes.select{|item| item[:process] == params[:name].to_sym }
21
21
  unless process_recordset.empty? then
22
22
  record = process_recordset.first
23
23
  obj = splash_return case: :quiet_exit
@@ -29,10 +29,10 @@ WebAdminApp.get '/api/process/show/:name.?:format?' do
29
29
  format_response(obj, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
30
30
  end
31
31
 
32
- WebAdminApp.post '/api/process/analyse.?:format?' do
32
+ WebAdminApp.post '/api/processes/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 "API : process, verb : POST, route : analyse, format : #{format}"
35
+ log.call "API : processes, verb : POST, route : analyse, format : #{format}"
36
36
  results = Splash::Processes::ProcessScanner::new
37
37
  results.analyse
38
38
  res = results.output
@@ -43,10 +43,10 @@ WebAdminApp.post '/api/process/analyse.?:format?' do
43
43
  format_response(obj, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
44
44
  end
45
45
 
46
- WebAdminApp.post '/api/process/monitor.?:format?' do
46
+ WebAdminApp.post '/api/processes/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 "API : process, verb : POST, route : monitor, format : #{format}"
49
+ log.call "API : processes, verb : POST, route : monitor, format : #{format}"
50
50
  results = Splash::Processes::ProcessScanner::new
51
51
  results.analyse
52
52
  res = splash_return results.notify
@@ -58,3 +58,15 @@ WebAdminApp.post '/api/process/monitor.?:format?' do
58
58
  content_type format
59
59
  format_response(res, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
60
60
  end
61
+
62
+ WebAdminApp.get '/api/processes/history/:process.?:format?' do
63
+ log = get_logger
64
+ format = (params[:format])? format_by_extensions(params[:format]) : format_by_extensions('json')
65
+ log.call "API : processes, verb : GET, route : history, format : #{format}"
66
+ record = Splash::Processes::ProcessRecords::new(params[:process]).get_all_records
67
+ history = splash_return case: :quiet_exit, :more => "Proces monitoring history"
68
+ history[:data] = record
69
+ content_type format
70
+ status 201
71
+ format_response(history, (params[:format])? format_by_extensions(params[:format]): request.accept.first)
72
+ end
@@ -7,6 +7,8 @@ class WebAdminApp < Sinatra::Base
7
7
  include Splash::Exiter
8
8
  include Splash::Loggers
9
9
  include Splash::Daemon::Controller
10
+ include Splash::Logs
11
+ include Splash::Processes
10
12
 
11
13
  set :server, 'thin'
12
14
  set :port, get_config.webadmin_port
@@ -21,7 +21,7 @@ end
21
21
  WebAdminApp.get '/add_modify_log/?:label?' do
22
22
  get_menu 0
23
23
  log = get_logger
24
- log.call "WEB : logs, verb : POST, controller : /add_modify_log/?:label?"
24
+ log.call "WEB : logs, verb : GET, controller : /add_modify_log/?:label?"
25
25
  @data = {}
26
26
  if params[:label] then
27
27
  url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/logs/show/#{params[:label].to_s}.yml"
@@ -30,10 +30,23 @@ WebAdminApp.get '/add_modify_log/?:label?' do
30
30
  @data = res[:data] if res[:status] == :success
31
31
  @data[:old_label] = params[:label].to_s
32
32
  end
33
- slim :logs_form, :format => :html
33
+ slim :log_form, :format => :html
34
34
  end
35
35
 
36
36
 
37
+ WebAdminApp.get '/get_log_history/:label' do
38
+ get_menu 0
39
+ log = get_logger
40
+ log.call "WEB : logs, verb : GET, controller : /get_log_history/:label"
41
+ @data = {}
42
+ url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/logs/history/#{params[:label].to_s}.yml"
43
+ raw = RestClient::Request.execute(method: 'GET', url: url,timeout: 10)
44
+ res = YAML::load(raw)
45
+ @data = res[:data] if res[:status] == :success
46
+ @label = params[:label].to_s
47
+ slim :log_history, :format => :html
48
+ end
49
+
37
50
  WebAdminApp.post '/save_log' do
38
51
  get_menu 0
39
52
  log = get_logger
@@ -1,16 +1,72 @@
1
- WebAdminApp.get '/processes' do
1
+ WebAdminApp.get '/processes/?:status?/?:process?' do
2
2
  get_menu 1
3
3
  log = get_logger
4
- log.call "WEB : processes, verb : GET, controller : /processes"
5
- url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/process/list.yml"
4
+ log.call "WEB : processes, verb : GET, controller : /processes/?:status?/?:process?"
5
+ url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/processes/list.yml"
6
6
  raw = RestClient::Request.execute(method: 'GET', url: url,timeout: 10)
7
7
  @data = YAML::load(raw)[:data]
8
- url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/process/analyse.yml"
8
+ url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/processes/analyse.yml"
9
9
  raw = RestClient::Request.execute(method: 'POST', url: url,timeout: 10)
10
10
  prov = YAML::load(raw)[:data]
11
11
  @result = {}
12
+ @process_failed = params[:process] if params[:status] == 'failure'
13
+ @process_saved = params[:process] if params[:status] == 'success'
12
14
  prov.each {|item|
13
15
  @result[item[:process]] = item
14
16
  }
15
17
  slim :processes, :format => :html
16
18
  end
19
+
20
+ WebAdminApp.get '/add_modify_process/?:process?' do
21
+ get_menu 1
22
+ log = get_logger
23
+ log.call "WEB : processes, verb : GET, controller : /add_modify_process/?:process?"
24
+ @data = {}
25
+ if params[:process] then
26
+ url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/processes/show/#{params[:process].to_s}.yml"
27
+ raw = RestClient::Request.execute(method: 'GET', url: url,timeout: 10)
28
+ res = YAML::load(raw)
29
+ @data = res[:data] if res[:status] == :success
30
+ if @data[:patterns].class == Array then
31
+ prov = @data[:patterns].join('|')
32
+ @data[:patterns] = prov
33
+ end
34
+ @data[:old_process] = params[:process].to_s
35
+ end
36
+ slim :process_form, :format => :html
37
+ end
38
+
39
+
40
+ WebAdminApp.get '/get_process_history/:process' do
41
+ get_menu 1
42
+ log = get_logger
43
+ log.call "WEB : processes, verb : GET, controller : /get_process_history/:process"
44
+ @data = {}
45
+ url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/processes/history/#{params[:process].to_s}.yml"
46
+ raw = RestClient::Request.execute(method: 'GET', url: url,timeout: 10)
47
+ res = YAML::load(raw)
48
+ @data = res[:data] if res[:status] == :success
49
+ @process = params[:process].to_s
50
+ slim :process_history, :format => :html
51
+ end
52
+
53
+ WebAdminApp.post '/save_process' do
54
+ get_menu 1
55
+ log = get_logger
56
+ log.call "WEB : processes, verb : POST, controller : /save_process/?:process?"
57
+ data = {}
58
+ data[:patterns] = params[:patterns].split('|')
59
+ data[:process] = params[:process].to_sym
60
+ if params[:update] then
61
+ url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/config/deleteprocess/#{params[:old_process]}"
62
+ raw = RestClient::Request.execute(method: 'DELETE', url: url,timeout: 10)
63
+ end
64
+ url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/config/addprocess.yml"
65
+ raw = RestClient::Request.execute(method: 'POST', url: url,timeout: 10, payload: data.to_yaml)
66
+ res = YAML::load(raw)
67
+ if res[:status] == :success then
68
+ redirect "/processes/success/#{params[:process].to_s}"
69
+ else
70
+ redirect "/processes/failure/#{params[:process].to_s}"
71
+ end
72
+ end
@@ -0,0 +1,24 @@
1
+ h2.uk-text-success <i class="uk-icon-#{@menu_icons[@current_item]} uk-icon-medium "></i>&nbsp;&nbsp;History for log #{@label} monitoring
2
+
3
+
4
+ -
5
+ div.uk-width-medium-1-1
6
+ div.uk-panel.uk-panel-box
7
+ span.uk-text-large.uk-text-bold List of records
8
+ br
9
+ table#logrecords.uk-table.uk-table-hover.uk-table-striped
10
+ thead
11
+ tr
12
+ th Date
13
+ th File
14
+ th Status
15
+ th Nb Errors
16
+ th Full Nb of lines
17
+ tbody
18
+ - @data.each do |key|
19
+ tr
20
+ td #{key.keys.first}
21
+ td #{key[key.keys.first][:file]}
22
+ td #{key[key.keys.first][:status]}
23
+ td #{key[key.keys.first][:errors]}
24
+ td #{key[key.keys.first][:lines]}
@@ -36,6 +36,30 @@ javascript:
36
36
  });
37
37
  });
38
38
 
39
+ $(document).on( 'click','input.monitor-log',function(){
40
+ var url = "/api/logs/monitor.json";
41
+ UIkit.modal.confirm('Are you sure?', function(){
42
+ console.debug(url)
43
+ $.ajax({
44
+ url: url,
45
+ type: 'POST',
46
+ success: function( data ) {
47
+ console.debug(data)
48
+ if (data['status'] == 'success') {
49
+ UIkit.notify("Forced monitoring done", {status:'success'});
50
+ }
51
+ else
52
+ {
53
+ UIkit.notify("Forced monitoring failed !", {status:'danger'});
54
+ }
55
+ },
56
+ error: function(e) {
57
+ UIkit.notify("Forced monitoring failed !", {status:'danger'});
58
+ }
59
+ });
60
+ });
61
+ });
62
+
39
63
  div.uk-width-medium-1-1
40
64
  div.uk-panel.uk-panel-box
41
65
  span.uk-text-large.uk-text-bold List of logs monitored
@@ -72,8 +96,9 @@ div.uk-width-medium-1-1
72
96
  br
73
97
  input.modify-log.uk-button.uk-button-mini.uk-button-primary id="#{log[:label].to_s}" value="Modify" onclick="location.href='/add_modify_log/#{log[:label].to_s}';"
74
98
  br
75
- input.history-log.uk-button.uk-button-mini.uk-button-primary id="#{log[:label].to_s}" value="History" onclick="location.href='/history/#{log[:label].to_s}';"
99
+ input.history-log.uk-button.uk-button-mini.uk-button-primary id="#{log[:label].to_s}" value="History" onclick="location.href='/get_log_history/#{log[:label].to_s}';"
76
100
  div.uk-align-right
77
101
  form.uk-form.uk-form-horizontal#query action="/add_modify_log" method="GET"
78
102
  div &nbsp;
103
+ input.monitor-log.uk-button value="Force monitoring"&nbsp;
79
104
  input.add-log.uk-button type="submit" value="Add new log"
@@ -0,0 +1,21 @@
1
+ - unless @data.empty?
2
+ h2.uk-text-success <i class="uk-icon-#{@menu_icons[@current_item]} uk-icon-medium "></i>&nbsp;&nbsp;Modify Splash process monitoring : #{@data[:process]}
3
+ - else
4
+ h2.uk-text-success <i class="uk-icon-#{@menu_icons[@current_item]} uk-icon-medium "></i>&nbsp;&nbsp;Add new Splash process monitoring
5
+
6
+ script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.2/jquery.validate.min.js"
7
+
8
+ form.uk-form.uk-form-horizontal#query action="/save_process" method="POST"
9
+ label.uk-form-label for="process" Process
10
+ <input class="uk-form-width-large" id="process" type="text" placeholder="process" name="process" value="#{@data[:process].to_s}" required>
11
+ div &nbsp;
12
+ label.uk-form-label for="patterns" Patterns
13
+ <input class="uk-form-width-large" id="patterns" type="text" placeholder="patterns" name="patterns" value="#{@data[:patterns]}" required>
14
+ div &nbsp;
15
+ - unless @data.empty?
16
+ input type="hidden" name="update" value="true"
17
+ input type="hidden" name="old_process" value="#{@data[:old_process].to_s}"
18
+ div.uk-align-right
19
+ input.uk-button.uk-button-small-primary type="submit" value="Submit"
20
+ javascript:
21
+ $("#query").validate();
@@ -0,0 +1,24 @@
1
+ h2.uk-text-success <i class="uk-icon-#{@menu_icons[@current_item]} uk-icon-medium "></i>&nbsp;&nbsp;History for process #{@process} monitoring
2
+
3
+
4
+ -
5
+ div.uk-width-medium-1-1
6
+ div.uk-panel.uk-panel-box
7
+ span.uk-text-large.uk-text-bold List of records
8
+ br
9
+ table#logrecords.uk-table.uk-table-hover.uk-table-striped
10
+ thead
11
+ tr
12
+ th Date
13
+ th Process
14
+ th Status
15
+ th % CPU
16
+ th % MEM
17
+ tbody
18
+ - @data.each do |key|
19
+ tr
20
+ td #{key.keys.first}
21
+ td #{key[key.keys.first][:process]}
22
+ td #{key[key.keys.first][:status]}
23
+ td #{key[key.keys.first][:cpu]}
24
+ td #{key[key.keys.first][:mem]}
@@ -1,10 +1,69 @@
1
1
  h2.uk-text-success <i class="uk-icon-#{@menu_icons[@current_item]} uk-icon-medium "></i>&nbsp;&nbsp;Processes configured in Splash
2
2
 
3
+ - unless @process_saved.nil?
4
+ javascript:
5
+ UIkit.notify("Process record #{@process_saved} saved", {status:'success'});
6
+ - unless @process_failed.nil?
7
+ javascript:
8
+ UIkit.notify("Process record #{@process_saved} not saved", {status:'danger'});
9
+
10
+
11
+ javascript:
12
+ $(document).on( 'click','input.delete-process',function(){
13
+ var id = this.id;
14
+ var url = "/api/config/deleteprocess/" + id + ".json";
15
+ UIkit.modal.confirm('Are you sure?', function(){
16
+ console.debug(url)
17
+ $.ajax({
18
+ url: url,
19
+ type: 'DELETE',
20
+ success: function( data ) {
21
+ console.debug(data)
22
+ if (data['status'] == 'success') {
23
+ $('table#processrecords tr#' + id).remove();
24
+ UIkit.notify("Deleting process for " + id + " done", {status:'success'});
25
+ }
26
+ else
27
+ {
28
+ UIkit.notify("Deleting process for " + id + " failed !", {status:'danger'});
29
+ }
30
+ },
31
+ error: function(e) {
32
+ UIkit.notify("Deleting process for " + id + " failed !", {status:'danger'});
33
+ }
34
+ });
35
+ });
36
+ });
37
+
38
+ $(document).on( 'click','input.monitor-process',function(){
39
+ var url = "/api/processes/monitor.json";
40
+ UIkit.modal.confirm('Are you sure?', function(){
41
+ console.debug(url)
42
+ $.ajax({
43
+ url: url,
44
+ type: 'POST',
45
+ success: function( data ) {
46
+ console.debug(data)
47
+ if (data['status'] == 'success') {
48
+ UIkit.notify("Forced monitoring done", {status:'success'});
49
+ }
50
+ else
51
+ {
52
+ UIkit.notify("Forced monitoring failed !", {status:'danger'});
53
+ }
54
+ },
55
+ error: function(e) {
56
+ UIkit.notify("Forced monitoring failed !", {status:'danger'});
57
+ }
58
+ });
59
+ });
60
+ });
61
+
3
62
  div.uk-width-medium-1-1
4
63
  div.uk-panel.uk-panel-box
5
64
  span.uk-text-large.uk-text-bold List of processes monitored
6
65
  br
7
- table.uk-table.uk-table-hover.uk-table-striped
66
+ table#processrecords.uk-table.uk-table-hover.uk-table-striped
8
67
  thead
9
68
  tr
10
69
  th Process record
@@ -12,7 +71,7 @@ div.uk-width-medium-1-1
12
71
  th Status
13
72
  tbody
14
73
  - @data.each do |process|
15
- tr
74
+ tr id="#{process[:process].to_s}"
16
75
  td <b>Process</b> : #{process[:process]}
17
76
  td
18
77
  span.uk-text-bold Patterns
@@ -27,3 +86,14 @@ div.uk-width-medium-1-1
27
86
  ul
28
87
  li <b>CPU usage</b> : #{@result[process[:process]][:cpu]}
29
88
  li <b>MEM usage</b> : #{@result[process[:process]][:mem]}
89
+ td
90
+ input.delete-process.uk-button.uk-button-mini.uk-button-danger id="#{process[:process].to_s}" value="Delete"
91
+ br
92
+ input.modify-process.uk-button.uk-button-mini.uk-button-primary id="#{process[:process].to_s}" value="Modify" onclick="location.href='/add_modify_process/#{process[:process].to_s}';"
93
+ br
94
+ input.history-process.uk-button.uk-button-mini.uk-button-primary id="#{process[:process].to_s}" value="History" onclick="location.href='/get_process_history/#{process[:process].to_s}';"
95
+ div.uk-align-right
96
+ form.uk-form.uk-form-horizontal#query action="/add_modify_process" method="GET"
97
+ div &nbsp;
98
+ input.monitor-process.uk-button value="Force monitoring"&nbsp;
99
+ input.add-process.uk-button type="submit" value="Add new process"
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_runtime_dependency 'ps-ruby','~> 0.0.4'
28
28
  spec.add_runtime_dependency 'tty-markdown','~> 0.7.0'
29
29
  spec.add_runtime_dependency 'tty-pager','~> 0.14.0'
30
- spec.add_runtime_dependency 'tty-table','~> 0.11.0'
30
+ spec.add_runtime_dependency 'tty-table','~> 0.12.0'
31
31
  spec.add_runtime_dependency 'net-ssh','~> 6.1.0'
32
32
  spec.add_runtime_dependency 'net-scp','~> 3.0.0'
33
33
  spec.add_runtime_dependency 'colorize','~> 0.8.1'
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.8.3
4
+ version: 0.8.4
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-10-28 00:00:00.000000000 Z
11
+ date: 2020-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.11.0
131
+ version: 0.12.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 0.11.0
138
+ version: 0.12.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: net-ssh
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -468,10 +468,13 @@ files:
468
468
  - lib/splash/webadmin/portal/views/documentation.slim
469
469
  - lib/splash/webadmin/portal/views/home.slim
470
470
  - lib/splash/webadmin/portal/views/layout.slim
471
+ - lib/splash/webadmin/portal/views/log_form.slim
472
+ - lib/splash/webadmin/portal/views/log_history.slim
471
473
  - lib/splash/webadmin/portal/views/logs.slim
472
- - lib/splash/webadmin/portal/views/logs_form.slim
473
474
  - lib/splash/webadmin/portal/views/nav.slim
474
475
  - lib/splash/webadmin/portal/views/not_found.slim
476
+ - lib/splash/webadmin/portal/views/process_form.slim
477
+ - lib/splash/webadmin/portal/views/process_history.slim
475
478
  - lib/splash/webadmin/portal/views/processes.slim
476
479
  - lib/splash/webadmin/portal/views/proxy.slim
477
480
  - lib/splash/webadmin/portal/views/restclient.slim
@@ -510,7 +513,7 @@ homepage: https://github.com/Ultragreen/prometheus-splash
510
513
  licenses:
511
514
  - BSD-2-Clause
512
515
  metadata: {}
513
- post_install_message:
516
+ post_install_message:
514
517
  rdoc_options: []
515
518
  require_paths:
516
519
  - lib
@@ -525,8 +528,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
525
528
  - !ruby/object:Gem::Version
526
529
  version: '0'
527
530
  requirements: []
528
- rubygems_version: 3.0.6
529
- signing_key:
531
+ rubygems_version: 3.1.2
532
+ signing_key:
530
533
  specification_version: 4
531
534
  summary: Supervision with Prometheus of Logs and Asynchronous tasks orchestration
532
535
  for Services or Hosts