prometheus-splash 0.7.0 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +61 -1
- data/README.md +400 -178
- data/config/splash.yml +45 -5
- data/lib/splash/backends.rb +8 -1
- data/lib/splash/backends/file.rb +1 -1
- data/lib/splash/cli.rb +2 -1
- data/lib/splash/cli/commands.rb +100 -16
- data/lib/splash/cli/config.rb +12 -1
- data/lib/splash/cli/daemon.rb +41 -1
- data/lib/splash/cli/logs.rb +144 -48
- data/lib/splash/cli/process.rb +145 -52
- data/lib/splash/cli/transfers.rb +213 -0
- data/lib/splash/cli/webadmin.rb +3 -3
- data/lib/splash/commands.rb +85 -19
- data/lib/splash/config.rb +145 -52
- data/lib/splash/config/flush.rb +2 -2
- data/lib/splash/constants.rb +7 -3
- data/lib/splash/daemon/metrics.rb +6 -6
- data/lib/splash/daemon/orchestrator.rb +76 -36
- data/lib/splash/daemon/orchestrator/grammar.rb +16 -1
- data/lib/splash/dependencies.rb +6 -1
- data/lib/splash/exiter.rb +1 -1
- data/lib/splash/helpers.rb +12 -3
- data/lib/splash/loggers/cli.rb +2 -10
- data/lib/splash/logs.rb +94 -16
- data/lib/splash/processes.rb +91 -16
- data/lib/splash/transfers.rb +229 -0
- data/lib/splash/webadmin.rb +3 -3
- data/lib/splash/webadmin/api/routes/commands.rb +2 -2
- data/lib/splash/webadmin/api/routes/config.rb +95 -2
- data/lib/splash/webadmin/api/routes/logs.rb +32 -17
- data/lib/splash/webadmin/api/routes/process.rb +21 -9
- data/lib/splash/webadmin/api/routes/sequences.rb +2 -2
- data/lib/splash/webadmin/main.rb +3 -0
- data/lib/splash/webadmin/portal/controllers/commands.rb +2 -0
- data/lib/splash/webadmin/portal/controllers/documentation.rb +2 -0
- data/lib/splash/webadmin/portal/controllers/home.rb +24 -0
- data/lib/splash/webadmin/portal/controllers/logs.rb +57 -1
- data/lib/splash/webadmin/portal/controllers/processes.rb +61 -3
- data/lib/splash/webadmin/portal/controllers/proxy.rb +12 -3
- data/lib/splash/webadmin/portal/controllers/restclient.rb +6 -1
- data/lib/splash/webadmin/portal/controllers/sequences.rb +2 -0
- data/lib/splash/webadmin/portal/public/css/ultragreen.css +6 -0
- data/lib/splash/webadmin/portal/public/favicon.ico +0 -0
- data/lib/splash/webadmin/portal/views/commands.slim +1 -1
- data/lib/splash/webadmin/portal/views/documentation.slim +1 -1
- data/lib/splash/webadmin/portal/views/home.slim +53 -9
- data/lib/splash/webadmin/portal/views/layout.slim +2 -2
- data/lib/splash/webadmin/portal/views/log_form.slim +24 -0
- data/lib/splash/webadmin/portal/views/log_history.slim +24 -0
- data/lib/splash/webadmin/portal/views/logs.slim +93 -21
- data/lib/splash/webadmin/portal/views/nav.slim +1 -1
- data/lib/splash/webadmin/portal/views/not_found.slim +1 -1
- data/lib/splash/webadmin/portal/views/process_form.slim +21 -0
- data/lib/splash/webadmin/portal/views/process_history.slim +24 -0
- data/lib/splash/webadmin/portal/views/processes.slim +73 -3
- data/lib/splash/webadmin/portal/views/proxy.slim +5 -2
- data/lib/splash/webadmin/portal/views/restclient.slim +7 -4
- data/lib/splash/webadmin/portal/views/restclient_result.slim +24 -20
- data/lib/splash/webadmin/portal/views/sequences.slim +1 -1
- data/prometheus-splash.gemspec +7 -4
- data/ultragreen_roodi_coding_convention.yml +4 -4
- metadata +71 -8
data/lib/splash/commands.rb
CHANGED
@@ -6,6 +6,78 @@ module Splash
|
|
6
6
|
# Splash Commands module/namespace
|
7
7
|
module Commands
|
8
8
|
|
9
|
+
|
10
|
+
class CmdNotifier
|
11
|
+
|
12
|
+
@@registry = Prometheus::Client::Registry::new
|
13
|
+
@@metric_exitcode = Prometheus::Client::Gauge.new(:exitcode, docstring: 'SPLASH metric batch exitcode')
|
14
|
+
@@metric_time = Prometheus::Client::Gauge.new(:exectime, docstring: 'SPLASH metric batch execution time')
|
15
|
+
@@registry.register(@@metric_exitcode)
|
16
|
+
@@registry.register(@@metric_time)
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
def initialize(options={})
|
21
|
+
@config = get_config
|
22
|
+
@url = @config.prometheus_pushgateway_url
|
23
|
+
@name = "cmd_#{options[:name].to_s}"
|
24
|
+
@exitcode = options[:exitcode]
|
25
|
+
@time = options[:time]
|
26
|
+
end
|
27
|
+
|
28
|
+
# send metrics to Prometheus PushGateway
|
29
|
+
# @return [Bool]
|
30
|
+
def notify
|
31
|
+
unless verify_service url: @url then
|
32
|
+
return { :case => :service_dependence_missing, :more => "Prometheus Notification not send."}
|
33
|
+
end
|
34
|
+
@@metric_exitcode.set(@exitcode)
|
35
|
+
@@metric_time.set(@time)
|
36
|
+
hostname = Socket.gethostname
|
37
|
+
return Prometheus::Client::Push.new(@name, hostname, @url).add(@@registry)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
class CmdRecords
|
44
|
+
include Splash::Backends
|
45
|
+
include Splash::Constants
|
46
|
+
def initialize(name)
|
47
|
+
@name = name
|
48
|
+
@backend = get_backend :execution_trace
|
49
|
+
end
|
50
|
+
|
51
|
+
def purge(retention)
|
52
|
+
retention = {} if retention.nil?
|
53
|
+
if retention.include? :hours then
|
54
|
+
adjusted_datetime = DateTime.now - retention[:hours].to_f / 24
|
55
|
+
elsif retention.include? :hours then
|
56
|
+
adjusted_datetime = DateTime.now - retention[:days].to_i
|
57
|
+
else
|
58
|
+
adjusted_datetime = DateTime.now - DEFAULT_RETENTION
|
59
|
+
end
|
60
|
+
|
61
|
+
data = get_all_records
|
62
|
+
|
63
|
+
data.delete_if { |item|
|
64
|
+
DateTime.parse(item.keys.first) <= (adjusted_datetime)}
|
65
|
+
@backend.put key: @name, value: data.to_yaml
|
66
|
+
end
|
67
|
+
|
68
|
+
def add_record(record)
|
69
|
+
data = get_all_records
|
70
|
+
data.push({ DateTime.now.to_s => record })
|
71
|
+
@backend.put key: @name, value: data.to_yaml
|
72
|
+
end
|
73
|
+
|
74
|
+
def get_all_records(options={})
|
75
|
+
return (@backend.exist?({key: @name}))? YAML::load(@backend.get({key: @name})) : []
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
|
9
81
|
# command execution wrapper
|
10
82
|
class CommandWrapper
|
11
83
|
include Splash::Templates
|
@@ -16,11 +88,7 @@ module Splash
|
|
16
88
|
include Splash::Transports
|
17
89
|
|
18
90
|
|
19
|
-
|
20
|
-
@@metric_exitcode = Prometheus::Client::Gauge.new(:errorcode, docstring: 'SPLASH metric batch errorcode')
|
21
|
-
@@metric_time = Prometheus::Client::Gauge.new(:exectime, docstring: 'SPLASH metric batch execution time')
|
22
|
-
@@registry.register(@@metric_exitcode)
|
23
|
-
@@registry.register(@@metric_time)
|
91
|
+
|
24
92
|
|
25
93
|
# Constructor
|
26
94
|
# @param [String] name the name of the command
|
@@ -43,14 +111,17 @@ module Splash
|
|
43
111
|
# @param [String] value numeric.to_s
|
44
112
|
# @param [String] time execution time numeric.to_s
|
45
113
|
# @return [Hash] Exiter case :quiet_exit
|
46
|
-
def notify(value,time)
|
114
|
+
def notify(value,time, session)
|
115
|
+
log = get_logger
|
47
116
|
unless verify_service url: @config.prometheus_pushgateway_url then
|
48
117
|
return { :case => :service_dependence_missing, :more => "Prometheus Notification not send."}
|
49
118
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
119
|
+
cmdmonitor = CmdNotifier::new({name: @name, exitcode: value, time: time})
|
120
|
+
if cmdmonitor.notify then
|
121
|
+
log.ok "Sending metrics to Prometheus Pushgateway",session
|
122
|
+
else
|
123
|
+
log.ko "Failed to send metrics to Prometheus Pushgateway",session
|
124
|
+
end
|
54
125
|
return { :case => :quiet_exit}
|
55
126
|
end
|
56
127
|
|
@@ -110,9 +181,6 @@ module Splash
|
|
110
181
|
stdout, stderr, status = Open3.capture3(@config.commands[@name.to_sym][:command])
|
111
182
|
end
|
112
183
|
time = Time.now - start
|
113
|
-
tp = Template::new(
|
114
|
-
list_token: @config.execution_template_tokens,
|
115
|
-
template_file: @config.execution_template_path)
|
116
184
|
data = Hash::new
|
117
185
|
data[:start_date] = start_date
|
118
186
|
data[:end_date] = DateTime.now.to_s
|
@@ -123,17 +191,15 @@ module Splash
|
|
123
191
|
data[:stdout] = stdout
|
124
192
|
data[:stderr] = stderr
|
125
193
|
data[:exec_time] = time.to_s
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
backend.put key: key, value: data.to_yaml
|
194
|
+
cmdrec = CmdRecords::new @name
|
195
|
+
cmdrec.purge(@config.commands[@name.to_sym][:retention])
|
196
|
+
cmdrec.add_record data
|
130
197
|
exit_code = status.exitstatus
|
131
198
|
end
|
132
199
|
log.ok "Command executed", session
|
133
200
|
log.arrow "exitcode #{exit_code}", session
|
134
201
|
if options[:notify] then
|
135
|
-
acase = notify(exit_code,time.to_i)
|
136
|
-
get_logger.ok "Prometheus Gateway notified.",session
|
202
|
+
acase = notify(exit_code,time.to_i,session)
|
137
203
|
else
|
138
204
|
log.item "Without Prometheus notification", session
|
139
205
|
end
|
data/lib/splash/config.rb
CHANGED
@@ -11,56 +11,127 @@ module Splash
|
|
11
11
|
include Splash::ConfigUtilities
|
12
12
|
|
13
13
|
|
14
|
+
class ConfigLinter
|
15
|
+
def initialize
|
16
|
+
@lints_present = {:logs => [:label, :log, :pattern ],
|
17
|
+
:processes => [:process, :patterns ]}
|
18
|
+
@lints_types = {:logs => {:label => Symbol, :log => String, :pattern => String, :retention => Hash},
|
19
|
+
:processes => {:process => Symbol, :patterns => Array, :retention => Hash}}
|
20
|
+
end
|
21
|
+
|
22
|
+
def verify(options ={})
|
23
|
+
status = :success
|
24
|
+
missings = []
|
25
|
+
type_errors = []
|
26
|
+
useless = []
|
27
|
+
options[:record].each do |key,value|
|
28
|
+
useless.push key unless @lints_present[options[:type]].include? key or @lints_types[options[:type]].keys.include? key
|
29
|
+
type_errors.push key if @lints_types[options[:type]][key] != value.class and (@lints_present[options[:type]].include? key or @lints_types[options[:type]].keys.include? key)
|
30
|
+
end
|
31
|
+
@lints_present[options[:type]].each do |item|
|
32
|
+
missings.push item unless options[:record].keys.include? item
|
33
|
+
end
|
34
|
+
|
35
|
+
status = :failure if (missings.count > 0) or (type_errors.count > 0)
|
36
|
+
return {:missings => missings, :type_errors => type_errors, :useless => useless, :status => status}
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
14
41
|
# Class to manage configuration in Splash from Splash::Constants override by Yaml CONFIG
|
15
42
|
class Configuration < Hash
|
16
43
|
include Splash::Constants
|
17
44
|
|
45
|
+
attr_accessor :config_from_file
|
46
|
+
|
18
47
|
# constructor : read config file and map against Constants
|
19
48
|
def initialize(config_file=CONFIG_FILE)
|
20
|
-
|
49
|
+
@config_file = config_file
|
50
|
+
hash_config_to_default
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def hash_config_to_default
|
56
|
+
@config_from_file = readconf @config_file
|
21
57
|
self[:version] = VERSION
|
22
58
|
self[:author] = "#{AUTHOR} <#{EMAIL}>"
|
23
59
|
self[:copyright] = "#{COPYRIGHT} #{LICENSE}"
|
24
60
|
|
25
|
-
self[:prometheus_url] = (config_from_file[:prometheus][:url])? config_from_file[:prometheus][:url] : PROMETHEUS_URL
|
26
|
-
self[:prometheus_pushgateway_url] = (config_from_file[:prometheus][:pushgateway])? config_from_file[:prometheus][:pushgateway] : PROMETHEUS_PUSHGATEWAY_URL
|
61
|
+
self[:prometheus_url] = (@config_from_file[:prometheus][:url])? @config_from_file[:prometheus][:url] : PROMETHEUS_URL
|
62
|
+
self[:prometheus_pushgateway_url] = (@config_from_file[:prometheus][:pushgateway])? @config_from_file[:prometheus][:pushgateway] : PROMETHEUS_PUSHGATEWAY_URL
|
63
|
+
self[:prometheus_alertmanager_url] = (@config_from_file[:prometheus][:alertmanager])? @config_from_file[:prometheus][:alertmanager] : PROMETHEUS_ALERTMANAGER_URL
|
27
64
|
|
28
|
-
self[:daemon_process_name] = (config_from_file[:daemon][:process_name])? config_from_file[:daemon][:process_name] : DAEMON_PROCESS_NAME
|
29
|
-
self[:daemon_logmon_scheduling] = (config_from_file[:daemon][:logmon_scheduling])? config_from_file[:daemon][:logmon_scheduling] : DAEMON_LOGMON_SCHEDULING
|
30
|
-
self[:daemon_metrics_scheduling] = (config_from_file[:daemon][:metrics_scheduling])? config_from_file[:daemon][:metrics_scheduling] : DAEMON_METRICS_SCHEDULING
|
31
|
-
self[:daemon_procmon_scheduling] = (config_from_file[:daemon][:procmon_scheduling])? config_from_file[:daemon][:procmon_scheduling] : DAEMON_PROCMON_SCHEDULING
|
65
|
+
self[:daemon_process_name] = (@config_from_file[:daemon][:process_name])? @config_from_file[:daemon][:process_name] : DAEMON_PROCESS_NAME
|
66
|
+
self[:daemon_logmon_scheduling] = (@config_from_file[:daemon][:logmon_scheduling])? @config_from_file[:daemon][:logmon_scheduling] : DAEMON_LOGMON_SCHEDULING
|
67
|
+
self[:daemon_metrics_scheduling] = (@config_from_file[:daemon][:metrics_scheduling])? @config_from_file[:daemon][:metrics_scheduling] : DAEMON_METRICS_SCHEDULING
|
68
|
+
self[:daemon_procmon_scheduling] = (@config_from_file[:daemon][:procmon_scheduling])? @config_from_file[:daemon][:procmon_scheduling] : DAEMON_PROCMON_SCHEDULING
|
69
|
+
self[:daemon_pid_file] = (@config_from_file[:daemon][:files][:pid_file])? @config_from_file[:daemon][:files][:pid_file] : DAEMON_PID_FILE
|
70
|
+
self[:daemon_stdout_trace] = (@config_from_file[:daemon][:files][:stdout_trace])? @config_from_file[:daemon][:files][:stdout_trace] : DAEMON_STDOUT_TRACE
|
71
|
+
self[:daemon_stderr_trace] = (@config_from_file[:daemon][:files][:stderr_trace])? @config_from_file[:daemon][:files][:stderr_trace] : DAEMON_STDERR_TRACE
|
32
72
|
|
33
73
|
|
34
|
-
self[:webadmin_port] = (config_from_file[:webadmin][:port])? config_from_file[:webadmin][:port] : WEBADMIN_PORT
|
35
|
-
self[:webadmin_ip] = (config_from_file[:webadmin][:ip])? config_from_file[:webadmin][:ip] : WEBADMIN_IP
|
36
|
-
self[:webadmin_proxy] = (config_from_file[:webadmin][:proxy])? config_from_file[:webadmin][:proxy] : WEBADMIN_PROXY
|
37
|
-
self[:webadmin_process_name] = (config_from_file[:webadmin][:process_name])? config_from_file[:webadmin][:process_name] : WEBADMIN_PROCESS_NAME
|
38
|
-
self[:webadmin_pid_file] = (config_from_file[:webadmin][:files][:pid_file])? config_from_file[:webadmin][:files][:pid_file] : WEBADMIN_PID_FILE
|
39
|
-
self[:webadmin_stdout_trace] = (config_from_file[:webadmin][:files][:stdout_trace])? config_from_file[:webadmin][:files][:stdout_trace] : WEBADMIN_STDOUT_TRACE
|
40
|
-
self[:webadmin_stderr_trace] = (config_from_file[:webadmin][:files][:stderr_trace])? config_from_file[:webadmin][:files][:stderr_trace] : WEBADMIN_STDERR_TRACE
|
74
|
+
self[:webadmin_port] = (@config_from_file[:webadmin][:port])? @config_from_file[:webadmin][:port] : WEBADMIN_PORT
|
75
|
+
self[:webadmin_ip] = (@config_from_file[:webadmin][:ip])? @config_from_file[:webadmin][:ip] : WEBADMIN_IP
|
76
|
+
self[:webadmin_proxy] = (@config_from_file[:webadmin][:proxy])? @config_from_file[:webadmin][:proxy] : WEBADMIN_PROXY
|
77
|
+
self[:webadmin_process_name] = (@config_from_file[:webadmin][:process_name])? @config_from_file[:webadmin][:process_name] : WEBADMIN_PROCESS_NAME
|
78
|
+
self[:webadmin_pid_file] = (@config_from_file[:webadmin][:files][:pid_file])? @config_from_file[:webadmin][:files][:pid_file] : WEBADMIN_PID_FILE
|
79
|
+
self[:webadmin_stdout_trace] = (@config_from_file[:webadmin][:files][:stdout_trace])? @config_from_file[:webadmin][:files][:stdout_trace] : WEBADMIN_STDOUT_TRACE
|
80
|
+
self[:webadmin_stderr_trace] = (@config_from_file[:webadmin][:files][:stderr_trace])? @config_from_file[:webadmin][:files][:stderr_trace] : WEBADMIN_STDERR_TRACE
|
41
81
|
|
42
82
|
|
43
|
-
self[:pid_path] = (config_from_file[:
|
44
|
-
self[:trace_path] = (config_from_file[:
|
83
|
+
self[:pid_path] = (@config_from_file[:paths][:pid_path])? @config_from_file[:paths][:pid_path] : PID_PATH
|
84
|
+
self[:trace_path] = (@config_from_file[:paths][:trace_path])? @config_from_file[:paths][:trace_path] : TRACE_PATH
|
45
85
|
|
46
86
|
|
47
87
|
self[:execution_template_tokens] = EXECUTION_TEMPLATE_TOKENS_LIST
|
48
|
-
self[:execution_template_path] = (config_from_file[:templates][:execution][:path])? config_from_file[:templates][:execution][:path] : EXECUTION_TEMPLATE
|
49
|
-
self[:pid_file] = (config_from_file[:daemon][:files][:pid_file])? config_from_file[:daemon][:files][:pid_file] : DAEMON_PID_FILE
|
50
|
-
self[:stdout_trace] = (config_from_file[:daemon][:files][:stdout_trace])? config_from_file[:daemon][:files][:stdout_trace] : DAEMON_STDOUT_TRACE
|
51
|
-
self[:stderr_trace] = (config_from_file[:daemon][:files][:stderr_trace])? config_from_file[:daemon][:files][:stderr_trace] : DAEMON_STDERR_TRACE
|
88
|
+
self[:execution_template_path] = (@config_from_file[:templates][:execution][:path])? @config_from_file[:templates][:execution][:path] : EXECUTION_TEMPLATE
|
52
89
|
|
53
|
-
self[:transports] = {} ; self[:transports].merge! TRANSPORTS_STRUCT ; self[:transports].merge! config_from_file[:transports] if config_from_file[:transports]
|
54
|
-
self[:backends] = {} ; self[:backends].merge! BACKENDS_STRUCT ; self[:backends].merge! config_from_file[:backends] if config_from_file[:backends]
|
55
|
-
self[:loggers] = {} ; self[:loggers].merge! LOGGERS_STRUCT ; self[:loggers].merge! config_from_file[:loggers] if config_from_file[:loggers]
|
90
|
+
self[:transports] = {} ; self[:transports].merge! TRANSPORTS_STRUCT ; self[:transports].merge! @config_from_file[:transports] if @config_from_file[:transports]
|
91
|
+
self[:backends] = {} ; self[:backends].merge! BACKENDS_STRUCT ; self[:backends].merge! @config_from_file[:backends] if @config_from_file[:backends]
|
92
|
+
self[:loggers] = {} ; self[:loggers].merge! LOGGERS_STRUCT ; self[:loggers].merge! @config_from_file[:loggers] if @config_from_file[:loggers]
|
56
93
|
|
57
|
-
self[:processes] = (config_from_file[:processes])? config_from_file[:processes] : {}
|
58
|
-
self[:logs] = (config_from_file[:logs])? config_from_file[:logs] : {}
|
59
|
-
self[:commands] = (config_from_file[:commands])? config_from_file[:commands] : {}
|
60
|
-
self[:sequences] = (config_from_file[:sequences])? config_from_file[:sequences] : {}
|
94
|
+
self[:processes] = (@config_from_file[:processes])? @config_from_file[:processes] : {}
|
95
|
+
self[:logs] = (@config_from_file[:logs])? @config_from_file[:logs] : {}
|
96
|
+
self[:commands] = (@config_from_file[:commands])? @config_from_file[:commands] : {}
|
97
|
+
self[:sequences] = (@config_from_file[:sequences])? @config_from_file[:sequences] : {}
|
98
|
+
self[:transfers] = (@config_from_file[:transfers])? @config_from_file[:transfers] : {}
|
99
|
+
end
|
61
100
|
|
101
|
+
|
102
|
+
def add_record(options = {})
|
103
|
+
@config_from_file = readconf @config_file
|
104
|
+
key = options[:key]
|
105
|
+
res = ConfigLinter::new.verify(options)
|
106
|
+
if res[:status] == :success then
|
107
|
+
if @config_from_file[options[:type]].select{|item| item[options[:key]] == options[:record][options[:key]]}.count > 0 then
|
108
|
+
return {:status => :already_exist}
|
109
|
+
else
|
110
|
+
res[:useless].each {|item| options[:record].delete item} if options[:clean]
|
111
|
+
@config_from_file[options[:type]].push options[:record]
|
112
|
+
writeconf
|
113
|
+
hash_config_to_default
|
114
|
+
return {:status => :success}
|
115
|
+
end
|
116
|
+
else
|
117
|
+
return res
|
118
|
+
end
|
62
119
|
end
|
63
120
|
|
121
|
+
|
122
|
+
def delete_record(options = {})
|
123
|
+
@config_from_file = readconf @config_file
|
124
|
+
unless @config_from_file[options[:type]].select{|item| item[options[:key]] == options[options[:key]]}.count > 0 then
|
125
|
+
return {:status => :not_found}
|
126
|
+
else
|
127
|
+
@config_from_file[options[:type]].delete_if {|value| options[options[:key]] == value[options[:key]] }
|
128
|
+
writeconf
|
129
|
+
hash_config_to_default
|
130
|
+
return {:status => :success}
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
|
64
135
|
# @!group accessors on configurations Items
|
65
136
|
|
66
137
|
# getter for full Config Hash
|
@@ -87,6 +158,12 @@ module Splash
|
|
87
158
|
return self[:transports]
|
88
159
|
end
|
89
160
|
|
161
|
+
# getter for transfers Hash Config sample
|
162
|
+
# @return [Hash]
|
163
|
+
def transfers
|
164
|
+
return self[:transfers]
|
165
|
+
end
|
166
|
+
|
90
167
|
# getter for daemon_logmon_scheduling Hash Config sample
|
91
168
|
# @return [Hash]
|
92
169
|
def daemon_logmon_scheduling
|
@@ -105,6 +182,31 @@ module Splash
|
|
105
182
|
return self[:daemon_metrics_scheduling]
|
106
183
|
end
|
107
184
|
|
185
|
+
# getter for daemon_process_name Config sample
|
186
|
+
# @return [String]
|
187
|
+
def daemon_process_name
|
188
|
+
return self[:daemon_process_name]
|
189
|
+
end
|
190
|
+
|
191
|
+
|
192
|
+
# getter for daemon_full_pid_path Config sample
|
193
|
+
# @return [String]
|
194
|
+
def daemon_full_pid_path
|
195
|
+
return "#{self[:pid_path]}/#{self[:daemon_pid_file]}"
|
196
|
+
end
|
197
|
+
|
198
|
+
# getter for daemon_full_stdout_trace_path Config sample
|
199
|
+
# @return [String]
|
200
|
+
def daemon_full_stdout_trace_path
|
201
|
+
return "#{self[:trace_path]}/#{self[:daemon_stdout_trace]}"
|
202
|
+
end
|
203
|
+
|
204
|
+
# getter for daemon_full_stderr_trace_path Config sample
|
205
|
+
# @return [String]
|
206
|
+
def daemon_full_stderr_trace_path
|
207
|
+
return "#{self[:trace_path]}/#{self[:daemon_stderr_trace]}"
|
208
|
+
end
|
209
|
+
|
108
210
|
# getter for execution_template_path Hash Config sample
|
109
211
|
# @return [String]
|
110
212
|
def execution_template_path
|
@@ -215,36 +317,17 @@ module Splash
|
|
215
317
|
return self[:prometheus_pushgateway_url]
|
216
318
|
end
|
217
319
|
|
218
|
-
# getter for
|
219
|
-
# @return [String]
|
220
|
-
def prometheus_url
|
221
|
-
return self[:prometheus_url]
|
222
|
-
end
|
223
|
-
|
224
|
-
|
225
|
-
# getter for daemon_process_name Config sample
|
226
|
-
# @return [String]
|
227
|
-
def daemon_process_name
|
228
|
-
return self[:daemon_process_name]
|
229
|
-
end
|
230
|
-
|
231
|
-
|
232
|
-
# getter for daemon_full_pid_path Config sample
|
320
|
+
# getter for prometheus_alertmanager_url Config sample
|
233
321
|
# @return [String]
|
234
|
-
def
|
235
|
-
return
|
322
|
+
def prometheus_alertmanager_url
|
323
|
+
return self[:prometheus_alertmanager_url]
|
236
324
|
end
|
237
325
|
|
238
|
-
# getter for daemon_full_stdout_trace_path Config sample
|
239
|
-
# @return [String]
|
240
|
-
def daemon_full_stdout_trace_path
|
241
|
-
return "#{self[:trace_path]}/#{self[:stdout_trace]}"
|
242
|
-
end
|
243
326
|
|
244
|
-
# getter for
|
327
|
+
# getter for prometheus_url Config sample
|
245
328
|
# @return [String]
|
246
|
-
def
|
247
|
-
return
|
329
|
+
def prometheus_url
|
330
|
+
return self[:prometheus_url]
|
248
331
|
end
|
249
332
|
|
250
333
|
# @!endgroup
|
@@ -258,6 +341,16 @@ module Splash
|
|
258
341
|
return YAML.load_file(file)[:splash]
|
259
342
|
end
|
260
343
|
|
344
|
+
# write config to file from @config_from_file
|
345
|
+
# @param [String] file default from CONFIG_FILE
|
346
|
+
# @return [Bool] if ok
|
347
|
+
def writeconf(file = CONFIG_FILE)
|
348
|
+
File.open(file,"w") do |f|
|
349
|
+
data = {}
|
350
|
+
data[:splash] = @config_from_file
|
351
|
+
f.write(data.to_yaml)
|
352
|
+
end
|
353
|
+
end
|
261
354
|
|
262
355
|
end
|
263
356
|
|
data/lib/splash/config/flush.rb
CHANGED
@@ -16,8 +16,8 @@ module Splash
|
|
16
16
|
self.extend Splash::Backends
|
17
17
|
self.extend Splash::Loggers
|
18
18
|
log = get_logger
|
19
|
-
|
20
|
-
|
19
|
+
name = (options[:name])? options[:name].to_sym : :execution_trace
|
20
|
+
log.info "Splash backend #{name.to_s} flushing"
|
21
21
|
backend = get_backend name
|
22
22
|
if backend.flush then
|
23
23
|
return { :case => :quiet_exit, :more => "Splash backend #{name.to_s} flushed" }
|
data/lib/splash/constants.rb
CHANGED
@@ -7,8 +7,7 @@ module Splash
|
|
7
7
|
module Constants
|
8
8
|
|
9
9
|
# Current splash version
|
10
|
-
VERSION = "0.
|
11
|
-
|
10
|
+
VERSION = "0.8.4"
|
12
11
|
# the path to th config file, not overridable by config
|
13
12
|
CONFIG_FILE = "/etc/splash.yml"
|
14
13
|
# the default execution trace_path if backend file
|
@@ -43,7 +42,10 @@ module Splash
|
|
43
42
|
LICENSE="BSD-2-Clause"
|
44
43
|
|
45
44
|
# the default prometheus pushgateway URL
|
46
|
-
PROMETHEUS_PUSHGATEWAY_URL = 'http://localhost:
|
45
|
+
PROMETHEUS_PUSHGATEWAY_URL = 'http://localhost:9091/'
|
46
|
+
|
47
|
+
# the default prometheus Alertmanager URL
|
48
|
+
PROMETHEUS_ALERTMANAGER_URL = 'http://localhost:9092/'
|
47
49
|
|
48
50
|
# the default prometheus URL
|
49
51
|
PROMETHEUS_URL = "http://localhost:9090/"
|
@@ -84,6 +86,8 @@ module Splash
|
|
84
86
|
# the default sdterr trace file
|
85
87
|
WEBADMIN_STDERR_TRACE="stderr.txt"
|
86
88
|
|
89
|
+
# default retention for trace
|
90
|
+
DEFAULT_RETENTION=1
|
87
91
|
|
88
92
|
end
|
89
93
|
end
|
@@ -17,8 +17,8 @@ module Splash
|
|
17
17
|
|
18
18
|
# metrics manager factory
|
19
19
|
# @return [Splash::Daemon::Metrics::Manager]
|
20
|
-
def get_metrics_manager
|
21
|
-
return @@manager ||= Manager::new
|
20
|
+
def get_metrics_manager(session)
|
21
|
+
return @@manager ||= Manager::new(:session => session)
|
22
22
|
end
|
23
23
|
|
24
24
|
# Metrics Manager (collect and sending to Prometheus)
|
@@ -32,7 +32,8 @@ module Splash
|
|
32
32
|
attr_reader :monitoring_processes_count
|
33
33
|
|
34
34
|
# Constructor prepare prometheus-client, defined metrics and init attributes
|
35
|
-
def initialize
|
35
|
+
def initialize(options ={})
|
36
|
+
@session = options[:session]
|
36
37
|
@config = get_config
|
37
38
|
@starttime = Time.now
|
38
39
|
@execution_count = 0
|
@@ -75,12 +76,11 @@ module Splash
|
|
75
76
|
# @return [Hash] Exiter case ( :service_dependence_missing , :quiet_exit)
|
76
77
|
def notify
|
77
78
|
log = get_logger
|
78
|
-
session = get_session
|
79
79
|
unless verify_service url: @config.prometheus_pushgateway_url then
|
80
80
|
return { :case => :service_dependence_missing, :more => "Prometheus Notification not send." }
|
81
81
|
end
|
82
82
|
|
83
|
-
log.
|
83
|
+
log.ok "Sending Splash self metrics to PushGateway." , @session
|
84
84
|
@metric_uptime.set uptime
|
85
85
|
@metric_execution.set execution_count
|
86
86
|
@metric_logs_monitoring.set monitoring_logs_count
|
@@ -89,7 +89,7 @@ module Splash
|
|
89
89
|
hostname = Socket.gethostname
|
90
90
|
url = @config.prometheus_pushgateway_url
|
91
91
|
Prometheus::Client::Push.new('Splash',hostname, url).add(@registry)
|
92
|
-
log.debug "Sending to Prometheus PushGateway done.", session
|
92
|
+
log.debug "Sending to Prometheus PushGateway done.", @session
|
93
93
|
return {:case => :quiet_exit }
|
94
94
|
end
|
95
95
|
|