prometheus-splash 0.8.3 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -4
  3. data/README.md +400 -178
  4. data/config/splash.yml +15 -13
  5. data/lib/splash/backends/file.rb +1 -1
  6. data/lib/splash/backends.rb +7 -1
  7. data/lib/splash/cli/commands.rb +45 -80
  8. data/lib/splash/cli/config.rb +12 -1
  9. data/lib/splash/cli/daemon.rb +1 -1
  10. data/lib/splash/cli/logs.rb +34 -2
  11. data/lib/splash/cli/process.rb +33 -0
  12. data/lib/splash/cli/webadmin.rb +2 -1
  13. data/lib/splash/commands.rb +31 -22
  14. data/lib/splash/config/flush.rb +2 -2
  15. data/lib/splash/config.rb +15 -8
  16. data/lib/splash/constants.rb +1 -1
  17. data/lib/splash/daemon/orchestrator/grammar.rb +1 -1
  18. data/lib/splash/daemon/orchestrator.rb +6 -7
  19. data/lib/splash/dependencies.rb +1 -0
  20. data/lib/splash/logs.rb +5 -1
  21. data/lib/splash/monkeys.rb +5 -0
  22. data/lib/splash/processes.rb +4 -0
  23. data/lib/splash/sequences.rb +6 -1
  24. data/lib/splash/webadmin/api/routes/commands.rb +13 -1
  25. data/lib/splash/webadmin/api/routes/config.rb +95 -8
  26. data/lib/splash/webadmin/api/routes/process.rb +21 -9
  27. data/lib/splash/webadmin/main.rb +15 -1
  28. data/lib/splash/webadmin/portal/controllers/commands.rb +99 -1
  29. data/lib/splash/webadmin/portal/controllers/logs.rb +31 -4
  30. data/lib/splash/webadmin/portal/controllers/processes.rb +74 -4
  31. data/lib/splash/webadmin/portal/views/command_form.slim +45 -0
  32. data/lib/splash/webadmin/portal/views/command_history.slim +27 -0
  33. data/lib/splash/webadmin/portal/views/commands.slim +69 -19
  34. data/lib/splash/webadmin/portal/views/{logs_form.slim → log_form.slim} +3 -0
  35. data/lib/splash/webadmin/portal/views/log_history.slim +24 -0
  36. data/lib/splash/webadmin/portal/views/logs.slim +34 -7
  37. data/lib/splash/webadmin/portal/views/process_form.slim +24 -0
  38. data/lib/splash/webadmin/portal/views/process_history.slim +24 -0
  39. data/lib/splash/webadmin/portal/views/processes.slim +79 -6
  40. data/lib/splash/webadmin.rb +3 -1
  41. data/prometheus-splash.gemspec +1 -1
  42. data/templates/.env +0 -0
  43. data/templates/Dockerfile +5 -0
  44. data/templates/docker-compose.yml +14 -0
  45. metadata +18 -9
@@ -1,16 +1,86 @@
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[:retention].class == Hash then
31
+ prov = @data[:retention].flatten.reverse.join(' ')
32
+ @data[:retention] = prov
33
+ end
34
+ if @data[:patterns].class == Array then
35
+ prov = @data[:patterns].join('|')
36
+ @data[:patterns] = prov
37
+ end
38
+ @data[:old_process] = params[:process].to_s
39
+ end
40
+ slim :process_form, :format => :html
41
+ end
42
+
43
+
44
+ WebAdminApp.get '/get_process_history/:process' do
45
+ get_menu 1
46
+ log = get_logger
47
+ log.call "WEB : processes, verb : GET, controller : /get_process_history/:process"
48
+ @data = {}
49
+ url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/processes/history/#{params[:process].to_s}.yml"
50
+ raw = RestClient::Request.execute(method: 'GET', url: url,timeout: 10)
51
+ res = YAML::load(raw)
52
+ @data = res[:data] if res[:status] == :success
53
+ @process = params[:process].to_s
54
+ slim :process_history, :format => :html
55
+ end
56
+
57
+ WebAdminApp.post '/save_process' do
58
+ get_menu 1
59
+ log = get_logger
60
+ log.call "WEB : processes, verb : POST, controller : /save_process"
61
+ data = {}
62
+ data[:patterns] = params[:patterns].split('|')
63
+ data[:process] = params[:process].split(' ').first.to_sym
64
+ unless params[:retention].blank?
65
+ value, key = params[:retention].split(' ')
66
+ key = (key.nil?)? :days : key.to_sym
67
+ value = value.to_i
68
+ key = :days if key == :day
69
+ key = :hours if key == :hour
70
+ if [:hours,:days].include? key then
71
+ data[:retention] = {key => value}
72
+ end
73
+ end
74
+ if params[:update] then
75
+ url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/config/deleteprocess/#{params[:old_process]}"
76
+ raw = RestClient::Request.execute(method: 'DELETE', url: url,timeout: 10)
77
+ end
78
+ url = "http://#{get_config.webadmin_ip}:#{get_config.webadmin_port}/api/config/addprocess.yml"
79
+ raw = RestClient::Request.execute(method: 'POST', url: url,timeout: 10, payload: data.to_yaml)
80
+ res = YAML::load(raw)
81
+ if res[:status] == :success then
82
+ redirect "/processes/success/#{params[:process].to_s}"
83
+ else
84
+ redirect "/processes/failure/#{params[:process].to_s}"
85
+ end
86
+ end
@@ -0,0 +1,45 @@
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 command definition : #{@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 command definition
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_command" method="POST"
9
+ div.uk-text-bold Definition
10
+ label.uk-form-label for="name" Name
11
+ <input class="uk-form-width-large" id="name" type="text" placeholder="name" name="name" value="#{@data[:name].to_s}" required>
12
+ div &nbsp;
13
+ label.uk-form-label for="command" Command
14
+ <input class="uk-form-width-large" id="command" type="text" placeholder="command" name="command" value="#{@data[:command].to_s}">
15
+ div &nbsp;
16
+ label.uk-form-label for="desc" Description
17
+ <input class="uk-form-width-large" id="desc" type="text" placeholder="description" name="desc" value="#{@data[:desc]}" required>
18
+ div &nbsp;
19
+ label.uk-form-label for="desc" Become User
20
+ <input class="uk-form-width-large" id="user" type="text" placeholder="user" name="user" value="#{@data[:user]}">
21
+ div &nbsp;
22
+ label.uk-form-label for="retention" Retention (Like "2 hours, 2 days")
23
+ <input class="uk-form-width-large" id="retention" type="text" placeholder="retention" name="retention" value="#{@data[:retention]}">
24
+ div &nbsp;
25
+ label.uk-form-label for="schedule" Scheduling (Like "'every 10m', 'in 1h', 'at 12:00'")
26
+ <input class="uk-form-width-large" id="schedule" type="text" placeholder="scheduling" name="schedule" value="#{@data[:schedule]}">
27
+ div &nbsp;
28
+ label.uk-form-label for="delegate_to" Delegation (Like "task_name@hostname")
29
+ <input class="uk-form-width-large" id="delegate_to" type="text" placeholder="delegation" name="delegate_to" value="#{@data[:delegate_to]}">
30
+ div &nbsp;
31
+ div &nbsp;
32
+ div.uk-text-bold Callbacks
33
+ label.uk-form-label for="on_success" On success
34
+ <input class="uk-form-width-large" id="on_success" type="text" placeholder="on success" name="on_success" value="#{@data[:on_success]}">
35
+ div &nbsp;
36
+ label.uk-form-label for="on_success" On failure
37
+ <input class="uk-form-width-large" id="on_failure" type="text" placeholder="on failure" name="on_failure" value="#{@data[:on_failure]}">
38
+ div &nbsp;
39
+ - unless @data.empty?
40
+ input type="hidden" name="update" value="true"
41
+ input type="hidden" name="old_command" value="#{@data[:old_command].to_s}"
42
+ div.uk-align-right
43
+ input.uk-button.uk-button-small-primary type="submit" value="Submit"
44
+ javascript:
45
+ $("#query").validate();
@@ -0,0 +1,27 @@
1
+ h2.uk-text-success <i class="uk-icon-#{@menu_icons[@current_item]} uk-icon-medium "></i>&nbsp;&nbsp;History for command #{@command} executions and 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 Start Date
13
+ th End Date
14
+ th Execution time (sec)
15
+ th Status
16
+ th STDOUT empty ?
17
+ th STDERR empty ?
18
+
19
+ tbody
20
+ - @data.reverse.each do |key|
21
+ tr class="#{(key[key.keys.first][:status].to_s.split.last == "0")? 'uk-text-success' : 'uk-text-danger'}"
22
+ td #{key.keys.first}
23
+ td #{key[key.keys.first][:end_date]}
24
+ td #{key[key.keys.first][:exec_time]}
25
+ td #{key[key.keys.first][:status].to_s}
26
+ td #{key[key.keys.first][:stdout].empty?}
27
+ td #{key[key.keys.first][:stderr].empty?}
@@ -1,14 +1,49 @@
1
1
  h2.uk-text-success <i class="uk-icon-#{@menu_icons[@current_item]} uk-icon-medium "></i>&nbsp;&nbsp;Commands configured in Splash
2
2
 
3
+ - unless @log_saved.nil?
4
+ javascript:
5
+ UIkit.notify("Command definition #{@command_saved} saved", {status:'success'});
6
+ - unless @log_failed.nil?
7
+ javascript:
8
+ UIkit.notify("Command definition #{@command_saved} not saved", {status:'danger'});
9
+
10
+ javascript:
11
+ $(document).on( 'click','input.delete-command',function(){
12
+ var id = this.id;
13
+ var url = "/api/config/deletecommand/" + id + ".json";
14
+ UIkit.modal.confirm('Are you sure?', function(){
15
+ console.debug(url)
16
+ $.ajax({
17
+ url: url,
18
+ type: 'DELETE',
19
+ success: function( data ) {
20
+ console.debug(data)
21
+ if (data['status'] == 'success') {
22
+ $('div#commandrecords h3#' + id).remove();
23
+ $('div#commandrecords div#' + id).remove();
24
+ UIkit.notify("Deleting log for " + id + " done", {status:'success'});
25
+ }
26
+ else
27
+ {
28
+ UIkit.notify("Deleting log for " + id + " failed !", {status:'danger'});
29
+ }
30
+ },
31
+ error: function(e) {
32
+ UIkit.notify("Deleting log for " + id + " failed !", {status:'danger'});
33
+ }
34
+ });
35
+ });
36
+ });
37
+
3
38
  div.uk-width-medium-1-1
4
39
  div.uk-panel.uk-panel-box
5
40
  span.uk-text-large.uk-text-bold List of commands availables
6
41
  br
7
42
 
8
- div.uk-accordion(data-uk-accordion)
9
- - @data.each do |command,content|
10
- h3.uk-accordion-title <b>Name</b> : #{command}
11
- div.uk-accordion-content
43
+ div#commandrecords.uk-accordion(data-uk-accordion)
44
+ - @data.reverse.each do |command|
45
+ h3.uk-accordion-title id="#{command[:name].to_s}" <i class="uk-icon-play-circle-o"></i>&nbsp;<b>Name</b> : #{command[:name]}
46
+ div.uk-accordion-content id="#{command[:name].to_s} "
12
47
  table.uk-table.uk-table-hover.uk-table-striped
13
48
  thead
14
49
  tr
@@ -19,31 +54,46 @@ div.uk-width-medium-1-1
19
54
  td
20
55
  dl.uk-description-list-horizontal
21
56
  dt <i class="uk-icon-th-list"></i>&nbsp;Description
22
- dd #{content[:desc]}
23
- - if content[:command]
57
+ dd #{command[:desc]}
58
+ - if command[:command]
24
59
  dt <i class="uk-icon-cog"></i>&nbsp;Command Line
25
- dd #{content[:command]}
26
- - if content[:schedule]
60
+ - if command[:delegate_to]
61
+ dd.uk-text-danger #{command[:command]} <i>(ignored because delegate_to is set)</i>
62
+ - else
63
+ dd #{command[:command]}
64
+ - if command[:schedule]
27
65
  dt <i class="uk-icon-calendar"></i>&nbsp;Schedule
28
66
  dd
29
67
  <ul>
30
- <li> <b><i>Type</b></i> : #{content[:schedule].keys.first}</li>
31
- <li> <b><i>Value</b></i> : #{content[:schedule].values.first}</li>
68
+ <li> <b><i>Type</b></i> : #{command[:schedule].keys.first}</li>
69
+ <li> <b><i>Value</b></i> : #{command[:schedule].values.first}</li>
32
70
  </ul>
33
- - if content[:on_success]
71
+ - if command[:on_success]
34
72
  dt <i class="uk-icon-check"></i>&nbsp;Execute on success
35
- dd #{content[:on_success]}
36
- - if content[:on_failure]
73
+ dd #{command[:on_success]}
74
+ - if command[:on_failure]
37
75
  dt <i class="uk-icon-bolt"></i>&nbsp;Execute on failure
38
- dd #{content[:on_failure]}
39
- - if content[:user]
76
+ dd #{command[:on_failure]}
77
+ - if command[:user]
40
78
  dt <i class="uk-icon-user"></i>&nbsp;become user
41
- dd #{content[:user]}
42
- - if content[:delegate_to]
79
+ dd #{command[:user]}
80
+ - if command[:delegate_to]
43
81
  dt <i class="uk-icon-chevron-circle-right"></i>&nbsp;Remote delegation
44
82
  dd
45
83
  <ul>
46
- <li> <i><b>Host</b></i> : #{content[:delegate_to][:host]}</li>
47
- <li> <b><i>Remote Command</b></i> : #{content[:delegate_to][:remote_command]}</li>
84
+ <li> <i><b>Host</b></i> : #{command[:delegate_to][:host]}</li>
85
+ <li> <b><i>Remote Command</b></i> : #{command[:delegate_to][:remote_command]}</li>
48
86
  </ul>
87
+ - if command[:retention].class == Hash
88
+ dt <i class="uk-icon-calendar-minus-o"></i>&nbsp;History retention
89
+ dd #{command[:retention].flatten.reverse.join(' ')}
49
90
  td
91
+ input.delete-command.uk-button.uk-button-mini.uk-button-danger id="#{command[:name].to_s}" value="Delete"
92
+ br
93
+ input.modify-process.uk-button.uk-button-mini.uk-button-primary id="#{command[:name].to_s}" value="Modify" onclick="location.href='/add_modify_command/#{command[:name].to_s}';"
94
+ br
95
+ input.history-command.uk-button.uk-button-mini.uk-button-primary id="#{command[:name].to_s}" value="History" onclick="location.href='/get_command_history/#{command[:name].to_s}';"
96
+ div.uk-align-right
97
+ form.uk-form.uk-form-horizontal#query action="/add_modify_command" method="GET"
98
+ div &nbsp;
99
+ input.add-process.uk-button type="submit" value="Add new process"
@@ -15,6 +15,9 @@ form.uk-form.uk-form-horizontal#query action="/save_log" method="POST"
15
15
  label.uk-form-label for="log" Log file
16
16
  <input class="uk-form-width-large" id="log" type="text" placeholder="log" name="log" value="#{@data[:log]}" required>
17
17
  div &nbsp;
18
+ label.uk-form-label for="retention" Retention (Like "2 hours, 2 days")
19
+ <input class="uk-form-width-large" id="retention" type="text" placeholder="retention" name="retention" value="#{@data[:retention]}">
20
+ div &nbsp;
18
21
  - unless @data.empty?
19
22
  input type="hidden" name="update" value="true"
20
23
  input type="hidden" name="old_label" value="#{@data[:old_label].to_s}"
@@ -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.reverse.each do |key|
19
+ tr class="#{(key[key.keys.first][:status] == :clean)? 'uk-text-success' : 'uk-text-danger'}"
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
@@ -50,30 +74,33 @@ div.uk-width-medium-1-1
50
74
  tbody
51
75
  - @data.each do |log|
52
76
  tr id="#{log[:label].to_s}"
53
- td <b>Label</b> : #{log[:label]}
77
+ td <i class="uk-icon-tag"></i>&nbsp;<b>Label</b> : #{log[:label]}
54
78
  td
55
79
  ul
56
- li <b>File</b> : #{log[:log]}
57
- li <b>Pattern</b> : #{log[:pattern]}
80
+ li <i class="uk-icon-file"></i>&nbsp;<b>File</b> : #{log[:log]}
81
+ li <i class="uk-icon-binoculars"></i>&nbsp;<b>Pattern</b> : #{log[:pattern]}
82
+ - if log[:retention].class == Hash
83
+ li <i class="uk-icon-calendar-minus-o"></i>&nbsp;<b>History retention</b> : #{log[:retention].flatten.reverse.join(' ')}
58
84
  td
59
85
  - if @result[log[:label]][:status] == :missing
60
86
  div.uk-badge.uk-badge-warning missing
61
87
  - if @result[log[:label]][:status] == :clean
62
88
  div.uk-badge.uk-badge-success success
63
89
  ul
64
- li <b>Lines count</b> : #{@result[log[:label]][:lines]}
90
+ li <i class="uk-icon-asterisk"></i>&nbsp;<b>Lines count</b> : #{@result[log[:label]][:lines]}
65
91
  - if @result[log[:label]][:status] == :matched
66
92
  div.uk-badge.uk-badge-danger matched
67
93
  ul
68
- li <b>Lines count</b> : #{@result[log[:label]][:lines]}
69
- li <b class="uk-text-danger">Matchs count : #{@result[log[:label]][:count]} </b>
94
+ li <i class="uk-icon-asterisk"></i>&nbsp;<b>Lines count</b> : #{@result[log[:label]][:lines]}
95
+ li <i class="uk-icon-bolt"></i>&nbsp;<b class="uk-text-danger">Matchs count : #{@result[log[:label]][:count]} </b>
70
96
  td
71
97
  input.delete-log.uk-button.uk-button-mini.uk-button-danger id="#{log[:label].to_s}" value="Delete"
72
98
  br
73
99
  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
100
  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}';"
101
+ 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
102
  div.uk-align-right
77
103
  form.uk-form.uk-form-horizontal#query action="/add_modify_log" method="GET"
78
104
  div &nbsp;
105
+ input.monitor-log.uk-button value="Force monitoring"&nbsp;
79
106
  input.add-log.uk-button type="submit" value="Add new log"
@@ -0,0 +1,24 @@
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 (separator is "|")
13
+ <input class="uk-form-width-large" id="patterns" type="text" placeholder="patterns" name="patterns" value="#{@data[:patterns]}" required>
14
+ div &nbsp;
15
+ label.uk-form-label for="retention" Retention (Like "2 hours, 2 days")
16
+ <input class="uk-form-width-large" id="retention" type="text" placeholder="retention" name="retention" value="#{@data[:retention]}">
17
+ div &nbsp;
18
+ - unless @data.empty?
19
+ input type="hidden" name="update" value="true"
20
+ input type="hidden" name="old_process" value="#{@data[:old_process].to_s}"
21
+ div.uk-align-right
22
+ input.uk-button.uk-button-small-primary type="submit" value="Submit"
23
+ javascript:
24
+ $("#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.reverse.each do |key|
19
+ tr class="#{(key[key.keys.first][:status] == :running)? 'uk-text-success' : 'uk-text-danger'}"
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_percent]}
24
+ td #{key[key.keys.first][:mem_percent]}
@@ -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,18 +71,32 @@ div.uk-width-medium-1-1
12
71
  th Status
13
72
  tbody
14
73
  - @data.each do |process|
15
- tr
16
- td <b>Process</b> : #{process[:process]}
74
+ tr id="#{process[:process].to_s}"
75
+ td <i class="uk-icon-cog"></i>&nbsp;<b>Process</b> : #{process[:process]}
17
76
  td
18
- span.uk-text-bold Patterns
77
+ - if process[:retention].class == Hash
78
+ div <i class="uk-icon-calendar-minus-o"></i>&nbsp;<b>History retention</b> : #{process[:retention].flatten.reverse.join(' ')}
79
+ span.uk-text-bold <i class="uk-icon-binoculars"></i>&nbsp; Patterns
19
80
  ul
20
81
  - process[:patterns].each do |pattern|
21
82
  li= pattern
83
+
22
84
  td
23
85
  - if @result[process[:process]][:status] == :inexistant
24
86
  div.uk-badge.uk-badge-danger not running
25
87
  - if @result[process[:process]][:status] == :running
26
88
  div.uk-badge.uk-badge-success running
27
89
  ul
28
- li <b>CPU usage</b> : #{@result[process[:process]][:cpu]}
29
- li <b>MEM usage</b> : #{@result[process[:process]][:mem]}
90
+ li <i class="uk-icon-percent"></i>&nbsp;<b>CPU usage</b> : #{@result[process[:process]][:cpu]}
91
+ li <i class="uk-icon-percent"></i>&nbsp;<b>MEM usage</b> : #{@result[process[:process]][:mem]}
92
+ td
93
+ input.delete-process.uk-button.uk-button-mini.uk-button-danger id="#{process[:process].to_s}" value="Delete"
94
+ br
95
+ 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}';"
96
+ br
97
+ 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}';"
98
+ div.uk-align-right
99
+ form.uk-form.uk-form-horizontal#query action="/add_modify_process" method="GET"
100
+ div &nbsp;
101
+ input.monitor-process.uk-button value="Force monitoring"&nbsp;
102
+ input.add-process.uk-button type="submit" value="Add new process"
@@ -20,6 +20,7 @@ module Splash
20
20
  # Start the Splash Daemon
21
21
  # @param [Hash] options
22
22
  # @option options [Symbol] :quiet activate quiet mode for log (limit to :fatal)
23
+ # @option options [Symbol] :foreground run webadmin in foreground
23
24
  # @return [Hash] Exiter Case (:quiet_exit, :already_exist, :unknown_error or other)
24
25
  def startweb(options = {})
25
26
  require 'splash/webadmin/main'
@@ -37,7 +38,8 @@ module Splash
37
38
  daemon_config = {:description => config.webadmin_process_name,
38
39
  :pid_file => config.webadmin_full_pid_path,
39
40
  :stdout_trace => config.webadmin_full_stdout_trace_path,
40
- :stderr_trace => config.webadmin_full_stderr_trace_path
41
+ :stderr_trace => config.webadmin_full_stderr_trace_path,
42
+ :foreground => options[:foreground]
41
43
  }
42
44
 
43
45
  ["int","term","hup"].each do |type| daemon_config["sig#{type}_handler".to_sym] = Proc::new { WebAdminApp.quit! } end
@@ -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'
data/templates/.env ADDED
File without changes
@@ -0,0 +1,5 @@
1
+ FROM ruby:latest
2
+ RUN gem install prometheus-splash
3
+ RUN splash conf set
4
+ EXPOSE 9234
5
+ CMD ["splash","web", "start" ,"-F"]
@@ -0,0 +1,14 @@
1
+ version: "3"
2
+
3
+ services:
4
+ redis:
5
+ image: redis:latest
6
+
7
+ splash:
8
+ build: .
9
+ env_file: .env
10
+ ports:
11
+ - 9234:9234
12
+ depends_on:
13
+ - redis
14
+