prometheus-splash 0.5.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -0
  3. data/README.md +58 -60
  4. data/bin/splash +3 -0
  5. data/config/splash.yml +106 -10
  6. data/lib/splash/backends.rb +7 -0
  7. data/lib/splash/backends/file.rb +36 -0
  8. data/lib/splash/backends/redis.rb +44 -1
  9. data/lib/splash/cli.rb +16 -4
  10. data/lib/splash/cli/commands.rb +12 -5
  11. data/lib/splash/cli/config.rb +9 -1
  12. data/lib/splash/cli/daemon.rb +49 -2
  13. data/lib/splash/cli/documentation.rb +5 -2
  14. data/lib/splash/cli/logs.rb +21 -13
  15. data/lib/splash/cli/process.rb +103 -0
  16. data/lib/splash/cli/sequences.rb +114 -0
  17. data/lib/splash/cli/transfers.rb +206 -0
  18. data/lib/splash/cli/webadmin.rb +46 -0
  19. data/lib/splash/commands.rb +26 -4
  20. data/lib/splash/config.rb +184 -23
  21. data/lib/splash/config/flush.rb +9 -1
  22. data/lib/splash/config/sanitycheck.rb +7 -2
  23. data/lib/splash/config/service.rb +8 -1
  24. data/lib/splash/config/setup.rb +8 -3
  25. data/lib/splash/constants.rb +41 -10
  26. data/lib/splash/daemon.rb +5 -1
  27. data/lib/splash/daemon/controller.rb +31 -11
  28. data/lib/splash/daemon/metrics.rb +47 -22
  29. data/lib/splash/daemon/orchestrator.rb +141 -36
  30. data/lib/splash/daemon/orchestrator/grammar.rb +40 -5
  31. data/lib/splash/daemon/orchestrator/hooks.rb +10 -0
  32. data/lib/splash/dependencies.rb +19 -0
  33. data/lib/splash/exiter.rb +14 -0
  34. data/lib/splash/helpers.rb +93 -46
  35. data/lib/splash/loggers.rb +30 -4
  36. data/lib/splash/loggers/cli.rb +18 -11
  37. data/lib/splash/loggers/daemon.rb +14 -3
  38. data/lib/splash/loggers/dual.rb +14 -1
  39. data/lib/splash/loggers/web.rb +51 -0
  40. data/lib/splash/logs.rb +16 -5
  41. data/lib/splash/processes.rb +83 -0
  42. data/lib/splash/sequences.rb +105 -0
  43. data/lib/splash/templates.rb +10 -0
  44. data/lib/splash/transfers.rb +224 -0
  45. data/lib/splash/transports.rb +9 -0
  46. data/lib/splash/transports/rabbitmq.rb +33 -4
  47. data/lib/splash/webadmin.rb +122 -0
  48. data/lib/splash/webadmin/api/routes/commands.rb +28 -0
  49. data/lib/splash/webadmin/api/routes/config.rb +10 -0
  50. data/lib/splash/webadmin/api/routes/init.rb +2 -0
  51. data/lib/splash/webadmin/api/routes/logs.rb +59 -0
  52. data/lib/splash/webadmin/api/routes/process.rb +60 -0
  53. data/lib/splash/webadmin/api/routes/sequences.rb +28 -0
  54. data/lib/splash/webadmin/main.rb +27 -0
  55. data/lib/splash/webadmin/portal/controllers/commands.rb +7 -0
  56. data/lib/splash/webadmin/portal/controllers/documentation.rb +6 -0
  57. data/lib/splash/webadmin/portal/controllers/home.rb +31 -0
  58. data/lib/splash/webadmin/portal/controllers/logs.rb +14 -0
  59. data/lib/splash/webadmin/portal/controllers/notfound.rb +5 -0
  60. data/lib/splash/webadmin/portal/controllers/processes.rb +14 -0
  61. data/lib/splash/webadmin/portal/controllers/proxy.rb +36 -0
  62. data/lib/splash/webadmin/portal/controllers/restclient.rb +19 -0
  63. data/lib/splash/webadmin/portal/controllers/sequences.rb +7 -0
  64. data/lib/splash/webadmin/portal/init.rb +11 -0
  65. data/lib/splash/webadmin/portal/public/css/ultragreen.css +8544 -0
  66. data/lib/splash/webadmin/portal/public/fonts/FontAwesome.otf +0 -0
  67. data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.ttf +0 -0
  68. data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff +0 -0
  69. data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff2 +0 -0
  70. data/lib/splash/webadmin/portal/public/images/logo_splash.png +0 -0
  71. data/lib/splash/webadmin/portal/public/images/logo_splash_reduce.png +0 -0
  72. data/lib/splash/webadmin/portal/public/images/logo_splash_tiny.png +0 -0
  73. data/lib/splash/webadmin/portal/views/commands.slim +49 -0
  74. data/lib/splash/webadmin/portal/views/documentation.slim +3 -0
  75. data/lib/splash/webadmin/portal/views/home.slim +123 -0
  76. data/lib/splash/webadmin/portal/views/layout.slim +43 -0
  77. data/lib/splash/webadmin/portal/views/logs.slim +32 -0
  78. data/lib/splash/webadmin/portal/views/nav.slim +17 -0
  79. data/lib/splash/webadmin/portal/views/not_found.slim +3 -0
  80. data/lib/splash/webadmin/portal/views/processes.slim +29 -0
  81. data/lib/splash/webadmin/portal/views/proxy.slim +16 -0
  82. data/lib/splash/webadmin/portal/views/restclient.slim +41 -0
  83. data/lib/splash/webadmin/portal/views/restclient_result.slim +29 -0
  84. data/lib/splash/webadmin/portal/views/sequences.slim +50 -0
  85. data/prometheus-splash.gemspec +12 -3
  86. data/spec/helpers_spec.rb +119 -0
  87. metadata +196 -8
@@ -1,12 +1,19 @@
1
1
  # coding: utf-8
2
+
3
+ # base Splash Module
2
4
  module Splash
5
+
6
+ # Templates namespace
3
7
  module Templates
4
8
 
5
9
  # KISS template Engine
6
10
  class Template
7
11
 
12
+ # getter of the list of token
8
13
  attr_reader :list_token
14
+ # getter of the template file
9
15
  attr_reader :template_file
16
+ # getter of the flat content of the template
10
17
  attr_reader :content
11
18
 
12
19
  # constructor : generate the pseudo accessor for template Class from token list
@@ -72,8 +79,11 @@ module Splash
72
79
 
73
80
  end
74
81
 
82
+ # Exception for an invalid Token list
75
83
  class InvalidTokenList < Exception; end
84
+ # Exception for an malformed token
76
85
  class NotAToken < Exception; end
86
+ # Exception for an invalid template file
77
87
  class NoTemplateFile < Exception; end
78
88
 
79
89
  end
@@ -0,0 +1,224 @@
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
+ def initialize(name)
53
+ @name = name
54
+ @backend = get_backend :transferts_trace
55
+ end
56
+
57
+ def purge(retention)
58
+ if retention.include? :hours then
59
+ adjusted_datetime = DateTime.now - retention[:hours].to_f / 24
60
+ elsif retention.include? :hours then
61
+ adjusted_datetime = DateTime.now - retention[:days].to_i
62
+ else
63
+ retention = TRANSFER_DEFAULT_RETENTION
64
+ end
65
+
66
+ data = get_all_records
67
+
68
+ data.delete_if { |item,value|
69
+ DateTime.parse(item) <= (adjusted_datetime) and value[:status] != :prepared}
70
+ @backend.put key: @name, value: data.to_yaml
71
+ end
72
+
73
+ def add_record(record)
74
+ data = get_all_records
75
+ data[DateTime.now.to_s] = record
76
+ @backend.put key: @name, value: data.to_yaml
77
+ end
78
+
79
+ def get_all_records
80
+ return (@backend.exist?({key: @name}))? YAML::load(@backend.get({key: @name})) : {}
81
+ end
82
+
83
+ def check_prepared
84
+ return :never_run_prepare unless @backend.exist?({key: @name})
85
+ return :never_prepare unless YAML::load(@backend.get({key: @name})).select {|item,value|
86
+ value[:status] == :prepared
87
+ }.count > 0
88
+ return :prepared
89
+ end
90
+
91
+ end
92
+
93
+ def run_txs(options = {})
94
+ log = get_logger
95
+ log.info 'Running Transfers'
96
+ count=0
97
+ get_config.transfers.each do |record|
98
+ txrec = TxRecords::new record[:name]
99
+ txrec.purge(record[:retention])
100
+ log.item "Execute : #{record[:name]}, #{record[:desc]}"
101
+ case txrec.check_prepared
102
+ when :prepared
103
+ if record[:type] == :push then
104
+ unless push record
105
+ count += 1
106
+ end
107
+ elsif record[:type] == :pull then
108
+ unless pull record
109
+ count += 1
110
+ end
111
+ else
112
+ log.ko "Transfer type unkown"
113
+ count += 1
114
+ end
115
+ when :never_prepare
116
+ log.ko "#{record[:name]} : Never prepared, ignored"
117
+ txrec.add_record :status => :never_prepared
118
+ count += 1
119
+ when :never_run_prepare
120
+ log.ko "#{record[:name]} : Never Executed and never prepared, ignored"
121
+ txrec.add_record :status => :never_prepared
122
+ count += 1
123
+ end
124
+ end
125
+ return {:case => :error_exit, :more => "#{count} Transfer(s) failed"} if count > 0
126
+ return {:case => :quiet_exit }
127
+ end
128
+
129
+
130
+
131
+ def prepare_tx(name)
132
+ log = get_logger
133
+ record = get_config.transfers.select { |item| item[:name] == name.to_sym }.first
134
+ home = Etc.getpwnam(record[:local][:user]).dir
135
+ identity = ::File::readlines("#{home}/.ssh/id_rsa.pub").first.chomp
136
+ folder = {:mode => "755",
137
+ :owner => record[:local][:user] ,
138
+ :group => Etc.getgrgid(Etc.getpwnam(record[:local][:user]).gid).name,
139
+ :name => record[:local][:path],
140
+ :path => record[:local][:path]}
141
+ log.info "Ensure local folder : #{record[:local][:path]}"
142
+ make_folder(folder) unless verify_folder(folder).empty?
143
+ begin
144
+ log.info "Ensure RSA Key sharing for local user : #{record[:local][:user]} to remote user : #{record[:remote][:user]}@#{record[:remote][:host]}"
145
+ ssh = Net::SSH.start(record[:remote][:host],record[:remote][:user])
146
+ output = ssh.exec!(%[
147
+ /bin/bash -cl '
148
+ umask 077;
149
+ mkdir #{record[:remote][:path]};
150
+ test -d ~/.ssh || mkdir ~/.ssh;
151
+ if [ ! -f ~/.ssh/authorized_keys -o `grep "#{identity}" ~/.ssh/authorized_keys 2> /dev/null | wc -l` -eq 0 ]; then echo "#{identity}" >> ~/.ssh/authorized_keys
152
+ fi'])
153
+ log.info "Prepare remote folder : #{record[:remote][:path]}"
154
+ log.info "Prepare data file for transfer : #{record[:name]}"
155
+ txrec = TxRecords::new record[:name]
156
+ txrec.add_record :status => :prepared
157
+ log.ok "Transfer : #{record[:name]} prepared successfully"
158
+ return {:case => :quiet_exit }
159
+ rescue Interrupt
160
+ splash_exit case: :interrupt, more: "Remote command exection"
161
+ rescue TTY::Reader::InputInterrupt
162
+ splash_exit case: :interrupt, more: "Remote command exection"
163
+ end
164
+ end
165
+
166
+
167
+
168
+ def save_data
169
+
170
+ end
171
+
172
+
173
+
174
+ def push(record)
175
+ config = get_config
176
+ log = get_logger
177
+ txrec = TxRecords::new record[:name]
178
+ start = Time.now
179
+ res = true
180
+ count = 0
181
+ done =[]
182
+ start_date = DateTime.now.to_s
183
+ list = Dir.glob("#{record[:local][:path]}/#{record[:pattern]}")
184
+ count = list.count
185
+ log.arrow "Transfering #{count} file(s)"
186
+
187
+ begin
188
+ scp = Net::SCP.start(record[:remote][:host],record[:remote][:user])
189
+ list.each do|f|
190
+ log.arrow "Copy file : #{f} to #{record[:remote][:user]}@#{record[:remote][:host]}:#{record[:remote][:path]}"
191
+ scp.upload! f, record[:remote][:path]
192
+ done.push f
193
+ if record[:backup] then
194
+ log.arrow "File #{f} backuped"
195
+ FileUtils::mv(f, "#{f}.#{Time.now.getutc.to_i}")
196
+ else
197
+ FileUtils::unlink(f)
198
+ end
199
+ end
200
+
201
+ rescue
202
+ res = false
203
+ end
204
+
205
+ end_date = DateTime.now.to_s
206
+ time = Time.now - start
207
+ status = (res)? :success : :failure
208
+ txrec.add_record :status => status,
209
+ :end_date => end_date,
210
+ :time => time,
211
+ :count => count,
212
+ :wanted => list,
213
+ :done => done
214
+ count_failed = list.count - done.count
215
+ txmonitor = TxNotifier::new({name: record[:name], nbfiles: count,nbfiles_failed: count_failed, time: time})
216
+ if txmonitor.notify then
217
+ log.ok "Sending metrics to Prometheus Pushgateway"
218
+ else
219
+ log.ko "Failed to send metrics to Prometheus Pushgateway"
220
+ end
221
+ return res
222
+ end
223
+ end
224
+ end
@@ -1,9 +1,16 @@
1
1
  # coding: utf-8
2
2
 
3
+ # base Splash module
3
4
  module Splash
5
+
6
+ # Splash Transports namespace
4
7
  module Transports
5
8
  include Splash::Config
6
9
 
10
+
11
+ # factory for Splash::Transports::Rabbitmq::Subscriber
12
+ # @param [Hash] options
13
+ # @return [Splash::Transports::Rabbitmq::Subscriber|Hash] Subscriber or Exiter case :configuration_error
7
14
  def get_default_subscriber(options)
8
15
  config = get_config.transports
9
16
  transport = config[:active]
@@ -20,6 +27,8 @@ module Splash
20
27
  end
21
28
  end
22
29
 
30
+ # factory for Splash::Transports::Rabbitmq::Client
31
+ # @return [Splash::Transports::Rabbitmq::Client|Hash] Client or Exiter case :configuration_error
23
32
  def get_default_client
24
33
  config = get_config.transports
25
34
  transport = config[:active]
@@ -1,14 +1,24 @@
1
1
  # coding: utf-8
2
+
3
+ # base Splash module
2
4
  module Splash
5
+
6
+ # Splash Transports namespace
3
7
  module Transports
8
+
9
+ # RabbitMQ Transport
4
10
  module Rabbitmq
5
11
 
12
+ # Subscriber Mode RabbitMQ Client
6
13
  class Subscriber
7
14
  include Splash::Config
8
15
  extend Forwardable
9
16
 
10
17
  def_delegators :@queue, :subscribe
11
18
 
19
+ # Constructor Forward subscribe method and initialize a Bunny Client atribute @queue
20
+ # @param [Hash] options
21
+ # @option options [String] :queue the name of the subscribed queue
12
22
  def initialize(options = {})
13
23
  @config = get_config.transports
14
24
 
@@ -32,12 +42,13 @@ module Splash
32
42
 
33
43
  end
34
44
 
35
-
45
+ # publish / get Mode RabbitMQ Client
36
46
  class Client
37
47
  include Splash::Config
38
48
  include Splash::Transports
39
49
  include Splash::Loggers
40
50
 
51
+ # Constructor initialize a Bunny Client
41
52
  def initialize
42
53
  @config = get_config.transports
43
54
  host = @config[:rabbitmq][:host]
@@ -48,7 +59,7 @@ module Splash
48
59
  conf = { :host => host, :vhost => vhost, :user => user, :password => passwd, :port => port.to_i}
49
60
 
50
61
  begin
51
- @connection = Bunny.new conf
62
+ @connection = Bunny.new conf
52
63
  @connection.start
53
64
  @channel = @connection.create_channel
54
65
  rescue Bunny::Exception
@@ -56,19 +67,32 @@ module Splash
56
67
  end
57
68
  end
58
69
 
59
-
70
+ # purge a queue
71
+ # @param [Hash] options
72
+ # @option options [String] :queue the name of the queue to purge
60
73
  def purge(options)
61
74
  @channel.queue(options[:queue]).purge
62
75
  end
63
76
 
77
+ # publish to a queue
78
+ # @param [Hash] options
79
+ # @option options [String] :queue the name of the queue to purge
80
+ # @option options [String] :message the message to send
64
81
  def publish(options ={})
65
82
  return @channel.default_exchange.publish(options[:message], :routing_key => options[:queue])
66
83
  end
67
84
 
85
+ # ack a specific message for manual ack with a delivery tag to a queue
86
+ # @param [String] ack
87
+ # @return [Boolean]
68
88
  def ack(ack)
69
89
  return @channel.acknowledge(ack, false)
70
90
  end
71
91
 
92
+
93
+ # send an execution order message (verb+payload) via RabbitMQ to an slash input queue
94
+ # @param [Hash] order
95
+ # @return [Void] unserialized Void object from YAML
72
96
  def execute(order)
73
97
  queue = order[:return_to]
74
98
  lock = Mutex.new
@@ -76,7 +100,6 @@ module Splash
76
100
  condition = ConditionVariable.new
77
101
  get_default_subscriber(queue: queue).subscribe do |delivery_info, properties, payload|
78
102
  res = YAML::load(payload)
79
-
80
103
  lock.synchronize { condition.signal }
81
104
  end
82
105
  get_logger.send "Verb : #{order[:verb].to_s} to queue : #{order[:queue]}."
@@ -85,6 +108,11 @@ module Splash
85
108
  return res
86
109
  end
87
110
 
111
+ # Get a message from a RabbitMQ queue
112
+ # @param [Hash] options
113
+ # @option options [String] :queue the name of the queue to query
114
+ # @option options [String] :manual_ack flag to inhibit ack
115
+ # @return [Hash] Payload + ack tag if :manual_ack
88
116
  def get(options ={})
89
117
  queue = @channel.queue(options[:queue])
90
118
  opt = {}; opt[:manual_ack] = (options[:manual_ack])? true : false
@@ -94,6 +122,7 @@ module Splash
94
122
  return res
95
123
  end
96
124
 
125
+ # close the RabbitMQ connection
97
126
  def close
98
127
  @connection.close
99
128
  end
@@ -0,0 +1,122 @@
1
+ # coding: utf-8
2
+
3
+
4
+
5
+ # base Splash module
6
+ module Splash
7
+
8
+ # global daemon module
9
+ module WebAdmin
10
+
11
+ # Daemon Controller Module
12
+ module Controller
13
+ include Splash::Constants
14
+ include Splash::Helpers
15
+ include Splash::Config
16
+ include Splash::Exiter
17
+ include Splash::Loggers
18
+
19
+
20
+ # Start the Splash Daemon
21
+ # @param [Hash] options
22
+ # @option options [Symbol] :quiet activate quiet mode for log (limit to :fatal)
23
+ # @return [Hash] Exiter Case (:quiet_exit, :already_exist, :unknown_error or other)
24
+ def startweb(options = {})
25
+ require 'splash/webadmin/main'
26
+ config = get_config
27
+ log = get_logger
28
+ log.level = :fatal if options[:quiet]
29
+ realpid = get_processes pattern: get_config.webadmin_process_name
30
+
31
+
32
+ unless File::exist? config.webadmin_full_pid_path then
33
+ unless realpid.empty? then
34
+ return {:case => :already_exist, :more => "Splash WebAdmin Process already launched "}
35
+ end
36
+
37
+ daemon_config = {:description => config.webadmin_process_name,
38
+ :pid_file => config.webadmin_full_pid_path,
39
+ :stdout_trace => config.webadmin_full_stdout_trace_path,
40
+ :stderr_trace => config.webadmin_full_stderr_trace_path
41
+ }
42
+
43
+ ["int","term","hup"].each do |type| daemon_config["sig#{type}_handler".to_sym] = Proc::new { WebAdminApp.quit! } end
44
+ res = daemonize daemon_config do
45
+ log = get_logger logger: :web, force: true
46
+ log.info "Starting Splash WebAdmin"
47
+ WebAdminApp.run!
48
+ end
49
+ sleep 1
50
+ if res == 0 then
51
+ pid = `cat #{config.webadmin_full_pid_path}`.to_i
52
+ log.ok "Splash WebAdmin Started, with PID : #{pid}"
53
+ return {:case => :quiet_exit, :more => "Splash WebAdmin successfully loaded."}
54
+ else
55
+ return {:case => :unknown_error, :more => "Splash WebAdmin loading error, see logs for more details."}
56
+ end
57
+
58
+ else
59
+ return {:case => :already_exist, :more => "Pid File, please verify if Splash WebAdmin is running."}
60
+ end
61
+ end
62
+
63
+ # Stop the Splash WebAdmin
64
+ # @param [Hash] options
65
+ # @option options [Symbol] :quiet activate quiet mode for log (limit to :fatal)
66
+ # @return [Hash] Exiter Case (:quiet_exit, :not_found, other)
67
+ def stopweb(options = {})
68
+ config = get_config
69
+ log = get_logger
70
+ log.level = :fatal if options[:quiet]
71
+ if File.exist?(config.webadmin_full_pid_path) then
72
+ begin
73
+ pid = `cat #{config.webadmin_full_pid_path}`.to_i
74
+ Process.kill("TERM", pid)
75
+ acase = {:case => :quiet_exit, :more => 'Splash WebAdmin stopped succesfully'}
76
+ rescue Errno::ESRCH
77
+ acase = {:case => :not_found, :more => "Process of PID : #{pid} not found"}
78
+ end
79
+ FileUtils::rm config.webadmin_full_pid_path if File::exist? config.webadmin_full_pid_path
80
+ else
81
+ acase = {:case => :not_found, :more => "Splash WebAdmin is not running"}
82
+ end
83
+ return acase
84
+ end
85
+
86
+ # Status of the Splash WebAdmin, display status
87
+ # @param [Hash] options ignored
88
+ # @return [Hash] Exiter Case (:status_ko, :status_ok)
89
+ def statusweb(options = {})
90
+ log = get_logger
91
+ config = get_config
92
+ pid = realpid = ''
93
+ pid = `cat #{config.webadmin_full_pid_path}`.to_s if File.exist?(config.webadmin_full_pid_path)
94
+ listpid = get_processes({ :pattern => get_config.webadmin_process_name})
95
+ pid.chomp!
96
+ if listpid.empty? then
97
+ realpid = ''
98
+ else
99
+ realpid = listpid.first
100
+ end
101
+ unless realpid.empty? then
102
+ log.item "Splash WebAdmin Process is running with PID #{realpid} "
103
+ else
104
+ log.item 'Splash WebAdminProcess not found '
105
+ end
106
+ unless pid.empty? then
107
+ log.item "and PID file exist with PID #{pid}"
108
+ else
109
+ log.item "and PID file don't exist"
110
+ end
111
+ if pid == realpid then
112
+ return {:case => :status_ok }
113
+ elsif pid.empty? then
114
+ return {:case => :status_ko, :more => "PID File error, you have to kill process manualy, with : '(sudo )kill -TERM #{realpid}'"}
115
+ elsif realpid.empty? then
116
+ return {:case => :status_ko, :more => "Process Splash WebAdmin missing, run 'splash webadmin stop' before reload properly"}
117
+ end
118
+ end
119
+
120
+ end
121
+ end
122
+ end