prometheus-splash 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/config/splash.yml +2 -0
- data/lib/splash/backends/file.rb +4 -0
- data/lib/splash/backends/redis.rb +3 -3
- data/lib/splash/cli.rb +3 -1
- data/lib/splash/cli/commands.rb +14 -13
- data/lib/splash/cli/config.rb +7 -1
- data/lib/splash/cli/daemon.rb +2 -2
- data/lib/splash/cli/logs.rb +4 -3
- data/lib/splash/commands.rb +122 -120
- data/lib/splash/config.rb +5 -0
- data/lib/splash/config/flush.rb +22 -0
- data/lib/splash/constants.rb +4 -1
- data/lib/splash/daemon.rb +2 -0
- data/lib/splash/{controller.rb → daemon/controller.rb} +4 -4
- data/lib/splash/daemon/metrics.rb +78 -0
- data/lib/splash/{orchestrator.rb → daemon/orchestrator.rb} +35 -18
- data/lib/splash/daemon/orchestrator/grammar.rb +56 -0
- data/lib/splash/daemon/orchestrator/hooks.rb +18 -0
- data/lib/splash/dependencies.rb +2 -2
- data/lib/splash/helpers.rb +0 -2
- data/lib/splash/loggers.rb +11 -10
- data/lib/splash/loggers/dual.rb +21 -1
- data/lib/splash/logs.rb +56 -54
- data/templates/ansible-splash/roles/splash/handlers/main.yml +4 -0
- data/templates/ansible-splash/roles/splash/tasks/main.yml +24 -1
- data/templates/ansible-splash/roles/splash/templates/logrotate.splash.j2 +11 -0
- data/templates/ansible-splash/roles/splash/templates/splash.yml.j2 +1 -1
- metadata +10 -5
- data/lib/splash/orchestrator/grammar.rb +0 -54
- data/lib/splash/orchestrator/hooks.rb +0 -16
data/lib/splash/logs.rb
CHANGED
@@ -1,68 +1,70 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
module Splash
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Logs
|
4
|
+
class LogScanner
|
5
|
+
include Splash::Constants
|
6
|
+
include Splash::Config
|
6
7
|
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
9
|
+
# LogScanner Constructor
|
10
|
+
# return [LogScanner]
|
11
|
+
def initialize
|
12
|
+
@logs_target = get_config.logs
|
13
|
+
@config = get_config
|
14
|
+
@registry = Prometheus::Client::Registry::new
|
15
|
+
@metric_count = Prometheus::Client::Gauge.new(:logerrors, docstring: 'SPLASH metric log error', labels: [:log ])
|
16
|
+
@metric_missing = Prometheus::Client::Gauge.new(:logmissing, docstring: 'SPLASH metric log missing', labels: [:log ])
|
17
|
+
@metric_lines = Prometheus::Client::Gauge.new(:loglines, docstring: 'SPLASH metric log lines numbers', labels: [:log ])
|
18
|
+
@registry.register(@metric_count)
|
19
|
+
@registry.register(@metric_missing)
|
20
|
+
@registry.register(@metric_lines)
|
21
|
+
end
|
21
22
|
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
24
|
+
# start log analyse for log target in config
|
25
|
+
def analyse
|
26
|
+
@logs_target.each do |record|
|
27
|
+
record[:count]=0 if record[:count].nil?
|
28
|
+
record[:status] = :clean if record[:status].nil?
|
29
|
+
if File.exist?(record[:log]) then
|
30
|
+
record[:count] = File.readlines(record[:log]).grep(/#{record[:pattern]}/).size
|
31
|
+
record[:status] = :matched if record[:count] > 0
|
32
|
+
record[:lines] = `wc -l "#{record[:log]}"`.strip.split(/\s+/)[0].to_i unless record[:status] == :missing
|
33
|
+
else
|
34
|
+
record[:status] = :missing
|
35
|
+
end
|
34
36
|
end
|
37
|
+
return {:case => :quiet_exit }
|
35
38
|
end
|
36
|
-
return {:case => :quiet_exit }
|
37
|
-
end
|
38
|
-
|
39
|
-
# pseudo-accessor on @logs_target
|
40
|
-
def output
|
41
|
-
return @logs_target
|
42
|
-
end
|
43
39
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
unless verify_service host: @config.prometheus_pushgateway_host ,port: @config.prometheus_pushgateway_port then
|
48
|
-
return { :case => :service_dependence_missing, :more => "Prometheus Notification not send." }
|
40
|
+
# pseudo-accessor on @logs_target
|
41
|
+
def output
|
42
|
+
return @logs_target
|
49
43
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
44
|
+
|
45
|
+
# start notification on prometheus for metric logerrors, logmissing; loglines
|
46
|
+
def notify(options = {})
|
47
|
+
log = get_logger
|
48
|
+
unless verify_service host: @config.prometheus_pushgateway_host ,port: @config.prometheus_pushgateway_port then
|
49
|
+
return { :case => :service_dependence_missing, :more => "Prometheus Notification not send." }
|
50
|
+
end
|
51
|
+
session = (options[:session]) ? options[:session] : log.get_session
|
52
|
+
log.info "Sending metrics to Prometheus Pushgateway", session
|
53
|
+
@logs_target.each do |item|
|
54
|
+
missing = (item[:status] == :missing)? 1 : 0
|
55
|
+
log.item "Sending metrics for #{item[:log]}", session
|
56
|
+
@metric_count.set(item[:count], labels: { log: item[:log] })
|
57
|
+
@metric_missing.set(missing, labels: { log: item[:log] })
|
58
|
+
lines = (item[:lines])? item[:lines] : 0
|
59
|
+
@metric_lines.set(lines, labels: { log: item[:log] })
|
60
|
+
end
|
61
|
+
hostname = Socket.gethostname
|
62
|
+
url = "http://#{@config.prometheus_pushgateway_host}:#{@config.prometheus_pushgateway_port}"
|
63
|
+
Prometheus::Client::Push.new('Splash',hostname, url).add(@registry)
|
64
|
+
log.ok "Sending to Prometheus PushGateway done.", session
|
65
|
+
return {:case => :quiet_exit }
|
59
66
|
end
|
60
|
-
hostname = Socket.gethostname
|
61
|
-
url = "http://#{@config.prometheus_pushgateway_host}:#{@config.prometheus_pushgateway_port}"
|
62
|
-
Prometheus::Client::Push.new('Splash',hostname, url).add(@registry)
|
63
|
-
log.ok "Sending to Prometheus PushGateway done.", session
|
64
|
-
return {:case => :quiet_exit }
|
65
|
-
end
|
66
67
|
|
68
|
+
end
|
67
69
|
end
|
68
70
|
end
|
@@ -26,4 +26,27 @@
|
|
26
26
|
owner: root
|
27
27
|
group: root
|
28
28
|
mode: 0644
|
29
|
-
|
29
|
+
notify: restart Splashd
|
30
|
+
|
31
|
+
- name: SPLASH Check if Systemd service installed
|
32
|
+
stat:
|
33
|
+
path: /etc/systemd/system/splashd.service
|
34
|
+
register: stat_splash_result
|
35
|
+
|
36
|
+
- name: SPLASH Install systemd service
|
37
|
+
shell: splash conf service
|
38
|
+
when: not stat_splash_result.stat.exists
|
39
|
+
|
40
|
+
- name: SPLASH Splashd running
|
41
|
+
service:
|
42
|
+
name: splashd
|
43
|
+
state: started
|
44
|
+
enabled: yes
|
45
|
+
|
46
|
+
- name: SPLASH LogRotate template
|
47
|
+
template:
|
48
|
+
src: logrotate.splash.j2
|
49
|
+
dest: /etc/logrotate.d/splash
|
50
|
+
owner: root
|
51
|
+
group: root
|
52
|
+
mode: 0644
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prometheus-splash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Romain GEORGES
|
@@ -267,11 +267,17 @@ files:
|
|
267
267
|
- lib/splash/cli/logs.rb
|
268
268
|
- lib/splash/commands.rb
|
269
269
|
- lib/splash/config.rb
|
270
|
+
- lib/splash/config/flush.rb
|
270
271
|
- lib/splash/config/sanitycheck.rb
|
271
272
|
- lib/splash/config/service.rb
|
272
273
|
- lib/splash/config/setup.rb
|
273
274
|
- lib/splash/constants.rb
|
274
|
-
- lib/splash/
|
275
|
+
- lib/splash/daemon.rb
|
276
|
+
- lib/splash/daemon/controller.rb
|
277
|
+
- lib/splash/daemon/metrics.rb
|
278
|
+
- lib/splash/daemon/orchestrator.rb
|
279
|
+
- lib/splash/daemon/orchestrator/grammar.rb
|
280
|
+
- lib/splash/daemon/orchestrator/hooks.rb
|
275
281
|
- lib/splash/dependencies.rb
|
276
282
|
- lib/splash/exiter.rb
|
277
283
|
- lib/splash/helpers.rb
|
@@ -280,9 +286,6 @@ files:
|
|
280
286
|
- lib/splash/loggers/daemon.rb
|
281
287
|
- lib/splash/loggers/dual.rb
|
282
288
|
- lib/splash/logs.rb
|
283
|
-
- lib/splash/orchestrator.rb
|
284
|
-
- lib/splash/orchestrator/grammar.rb
|
285
|
-
- lib/splash/orchestrator/hooks.rb
|
286
289
|
- lib/splash/templates.rb
|
287
290
|
- lib/splash/transports.rb
|
288
291
|
- lib/splash/transports/rabbitmq.rb
|
@@ -300,7 +303,9 @@ files:
|
|
300
303
|
- templates/ansible-splash/roles/mq/handlers/main.yml
|
301
304
|
- templates/ansible-splash/roles/mq/tasks/main.yml
|
302
305
|
- templates/ansible-splash/roles/mq/templates/rabbitmq-env.conf.j2
|
306
|
+
- templates/ansible-splash/roles/splash/handlers/main.yml
|
303
307
|
- templates/ansible-splash/roles/splash/tasks/main.yml
|
308
|
+
- templates/ansible-splash/roles/splash/templates/logrotate.splash.j2
|
304
309
|
- templates/ansible-splash/roles/splash/templates/splash.yml.j2
|
305
310
|
- templates/ansible-splash/roles/supervision_gateway/handlers/main.yml
|
306
311
|
- templates/ansible-splash/roles/supervision_gateway/tasks/main.yml
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
module Splash
|
3
|
-
module Orchestrator
|
4
|
-
module Grammar
|
5
|
-
|
6
|
-
include Splash::Config
|
7
|
-
include Splash::Loggers
|
8
|
-
|
9
|
-
|
10
|
-
VERBS=[:ping,:list_commands,:execute_command,:ack_command, :shutdown]
|
11
|
-
|
12
|
-
|
13
|
-
def shutdown
|
14
|
-
terminate
|
15
|
-
end
|
16
|
-
|
17
|
-
def ping(content)
|
18
|
-
return "Pong : #{content[:payload][:hostname]} !"
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
def list_commands(content)
|
23
|
-
return get_config.commands
|
24
|
-
end
|
25
|
-
|
26
|
-
def ack_command(content)
|
27
|
-
return execute command: content[:payload][:name], ack: true
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
def execute_command(content)
|
32
|
-
payload = content[:payload]
|
33
|
-
unless get_config.commands.include? payload[:name].to_sym
|
34
|
-
@log.item "Command not found", content[:session]
|
35
|
-
return { :case => :not_found }
|
36
|
-
end
|
37
|
-
if payload.include? :schedule then
|
38
|
-
sched,value = payload[:schedule].flatten
|
39
|
-
@log.schedule "remote call command #{payload[:name]}, scheduling : #{sched.to_s} #{value}", content[:session]
|
40
|
-
@server.send sched,value do
|
41
|
-
@log.trigger "Executing Scheduled command #{payload[:name]} for Scheduling : #{sched.to_s} #{value}", content[:session]
|
42
|
-
execute command: payload[:name], session: content[:session]
|
43
|
-
end
|
44
|
-
return { :case => :quiet_exit }
|
45
|
-
else
|
46
|
-
@log.info "Execute direct command", content[:session]
|
47
|
-
res = execute command: payload[:name], session: content[:session]
|
48
|
-
return res
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|