prometheus-splash 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/config/splash.yml +9 -0
- data/lib/splash/cli/logs.rb +7 -7
- data/lib/splash/cli/process.rb +94 -0
- data/lib/splash/cli.rb +8 -3
- data/lib/splash/config.rb +10 -0
- data/lib/splash/constants.rb +5 -3
- data/lib/splash/daemon/metrics.rb +17 -7
- data/lib/splash/daemon/orchestrator.rb +39 -13
- data/lib/splash/dependencies.rb +2 -0
- data/lib/splash/helpers.rb +7 -2
- data/lib/splash/processes.rb +71 -0
- data/prometheus-splash.gemspec +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 762fd0659906d6b1360ce3d430faca573b1a2aded2675a298b35172811f18e13
|
4
|
+
data.tar.gz: 7d45440cd560b97ad893d07e95faaf3fbafc7343d52eaf36f652eee5ad5181e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5afd8f284807b1c0abfa0f68177bd5d75bf5f5941a38c02ad54047ed450a24b08a6d9d1a8b2c455655e30f4fd9d93f49fa81a5ec8d027906b85e45626cbde1a6
|
7
|
+
data.tar.gz: 2c3f67a0d5736ae24de861593df2b3b1ad397c2544b18c3d05d3b826ab3fc9bc7d0e06989064f0aa5964e269949db8315bd983f5c4ba9de1a0450f6aa8ba96ae
|
data/CHANGELOG.md
CHANGED
@@ -112,3 +112,16 @@
|
|
112
112
|
* Ansible Splash role logrotate copytruncate for splash logs
|
113
113
|
* Prometheus Registry mismatch=> cumulative metrics on each groups #42
|
114
114
|
* logger Dual level conservation #43
|
115
|
+
|
116
|
+
## V 0.5.2 2020/04/18
|
117
|
+
|
118
|
+
### FIX
|
119
|
+
|
120
|
+
* dual logger daemon shutdown foreground error
|
121
|
+
|
122
|
+
## V 0.5.3 2020/04/18
|
123
|
+
|
124
|
+
### FEATURE
|
125
|
+
|
126
|
+
* processes monitoring #23
|
127
|
+
|
data/config/splash.yml
CHANGED
@@ -35,6 +35,8 @@
|
|
35
35
|
:logmon_scheduling:
|
36
36
|
:every: 20s
|
37
37
|
:metrics_scheduling:
|
38
|
+
:every: 15s
|
39
|
+
:procmon_scheduling:
|
38
40
|
:every: 20s
|
39
41
|
:process_name: "Splash : daemon."
|
40
42
|
:paths:
|
@@ -108,3 +110,10 @@
|
|
108
110
|
:pattern: ERROR
|
109
111
|
- :log: /tmp/test2
|
110
112
|
:pattern: ERROR
|
113
|
+
|
114
|
+
|
115
|
+
### configuration of monitored processes
|
116
|
+
:processes:
|
117
|
+
- :process: cron
|
118
|
+
:patterns:
|
119
|
+
- cron
|
data/lib/splash/cli/logs.rb
CHANGED
@@ -7,12 +7,12 @@ module CLISplash
|
|
7
7
|
include Splash::Logs
|
8
8
|
|
9
9
|
|
10
|
-
desc "analyse", "analyze logs in config"
|
10
|
+
desc "analyse", "analyze logs defined in Splash config"
|
11
11
|
def analyse
|
12
12
|
log = get_logger
|
13
13
|
results = LogScanner::new
|
14
14
|
res = results.analyse
|
15
|
-
log.info "SPlash Configured
|
15
|
+
log.info "SPlash Configured log monitors :"
|
16
16
|
full_status = true
|
17
17
|
results.output.each do |result|
|
18
18
|
if result[:status] == :clean then
|
@@ -30,7 +30,7 @@ module CLISplash
|
|
30
30
|
|
31
31
|
full_status = false unless result[:status] == :clean
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
if full_status then
|
35
35
|
log.ok "Global status : no error found"
|
36
36
|
else
|
@@ -39,7 +39,7 @@ module CLISplash
|
|
39
39
|
splash_exit case: :quiet_exit
|
40
40
|
end
|
41
41
|
|
42
|
-
desc "monitor", "monitor logs in config"
|
42
|
+
desc "monitor", "monitor logs defined in Splash config"
|
43
43
|
def monitor
|
44
44
|
log = get_logger
|
45
45
|
log.level = :fatal if options[:quiet]
|
@@ -49,7 +49,7 @@ module CLISplash
|
|
49
49
|
|
50
50
|
end
|
51
51
|
|
52
|
-
desc "show LOG", "show configured log monitoring for LOG"
|
52
|
+
desc "show LOG", "show Splash configured log monitoring for LOG"
|
53
53
|
def show(logrecord)
|
54
54
|
log = get_logger
|
55
55
|
log_record_set = get_config.logs.select{|item| item[:log] == logrecord }
|
@@ -63,7 +63,7 @@ module CLISplash
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
desc "list", "
|
66
|
+
desc "list", "List all Splash configured logs monitoring"
|
67
67
|
long_desc <<-LONGDESC
|
68
68
|
Show configured logs monitoring\n
|
69
69
|
with --detail, show logs monitor details
|
@@ -77,7 +77,7 @@ module CLISplash
|
|
77
77
|
log_record_set.each do |record|
|
78
78
|
log.item "log monitor : #{record[:log]}"
|
79
79
|
if options[:detail] then
|
80
|
-
log.
|
80
|
+
log.arrow "pattern : /#{record[:pattern]}/"
|
81
81
|
end
|
82
82
|
end
|
83
83
|
splash_exit case: :quiet_exit
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module CLISplash
|
2
|
+
|
3
|
+
class Processes < Thor
|
4
|
+
include Splash::Config
|
5
|
+
include Splash::Exiter
|
6
|
+
include Splash::Processes
|
7
|
+
|
8
|
+
desc "analyse", "analyze processes defined in Splash config"
|
9
|
+
def analyse
|
10
|
+
log = get_logger
|
11
|
+
results = ProcessScanner::new
|
12
|
+
res = results.analyse
|
13
|
+
log.info "Splash Configured process records :"
|
14
|
+
full_status = true
|
15
|
+
results.output.each do |result|
|
16
|
+
if result[:status] == :running then
|
17
|
+
log.ok "Process : #{result[:process]} : running"
|
18
|
+
log.item "Detected patterns : "
|
19
|
+
result[:patterns].each do |pattern|
|
20
|
+
log.arrow "/#{pattern}/"
|
21
|
+
end
|
22
|
+
log.item "CPU usage in % : #{result[:cpu]} "
|
23
|
+
log.item "Memory usage in % : #{result[:mem]} "
|
24
|
+
else
|
25
|
+
log.ko "Process : #{result[:process]} : inexistant"
|
26
|
+
log.item "Detected patterns : "
|
27
|
+
result[:patterns].each do |pattern|
|
28
|
+
log.arrow "/#{pattern}/"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
full_status = false unless result[:status] == :running
|
33
|
+
end
|
34
|
+
|
35
|
+
if full_status then
|
36
|
+
log.ok "Global status : no error found"
|
37
|
+
else
|
38
|
+
log.error "Global status : some error found"
|
39
|
+
end
|
40
|
+
splash_exit case: :quiet_exit
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "monitor", "monitor processes defined in Splash config"
|
44
|
+
def monitor
|
45
|
+
log = get_logger
|
46
|
+
log.level = :fatal if options[:quiet]
|
47
|
+
result = ProcessScanner::new
|
48
|
+
result.analyse
|
49
|
+
splash_exit result.notify
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "show PROCESS", "show Splash configured process record for PROCESS"
|
53
|
+
def show(record)
|
54
|
+
log = get_logger
|
55
|
+
process_recordset = get_config.processes.select{|item| item[:process] == record }
|
56
|
+
unless process_recordset.empty? then
|
57
|
+
record = process_recordset.first
|
58
|
+
log.item "Process monitor : #{record[:process]}"
|
59
|
+
log.arrow "patterns :"
|
60
|
+
record[:patterns].each do |pattern|
|
61
|
+
log.flat " - /#{pattern}/"
|
62
|
+
end
|
63
|
+
splash_exit case: :quiet_exit
|
64
|
+
else
|
65
|
+
splash_exit case: :not_found, :more => "Process not configured"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
desc "list", "List all Splash configured process records"
|
70
|
+
long_desc <<-LONGDESC
|
71
|
+
List all Splash configured processes record\n
|
72
|
+
with --detail, show process records details
|
73
|
+
LONGDESC
|
74
|
+
option :detail, :type => :boolean, :aliases => "-D"
|
75
|
+
def list
|
76
|
+
log = get_logger
|
77
|
+
log.info "Splash configured process records :"
|
78
|
+
process_recordset = get_config.processes
|
79
|
+
log.ko 'No configured process found' if process_recordset.empty?
|
80
|
+
process_recordset.each do |record|
|
81
|
+
log.item "Process monitor : #{record[:process]}"
|
82
|
+
if options[:detail] then
|
83
|
+
log.arrow "patterns :"
|
84
|
+
record[:patterns].each do |pattern|
|
85
|
+
log.flat " - /#{pattern}/"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
splash_exit case: :quiet_exit
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
data/lib/splash/cli.rb
CHANGED
@@ -24,14 +24,19 @@ class CLI < Thor
|
|
24
24
|
|
25
25
|
|
26
26
|
include CLISplash
|
27
|
-
desc "commands SUBCOMMAND ...ARGS", "Managing commands/batchs supervision"
|
27
|
+
desc "commands SUBCOMMAND ...ARGS", "Managing commands/batchs supervision & orchestration"
|
28
28
|
subcommand "commands", Commands
|
29
29
|
desc "logs SUBCOMMAND ...ARGS", "Managing Files/Logs supervision"
|
30
30
|
subcommand "logs", Logs
|
31
|
-
desc "
|
31
|
+
desc "processes SUBCOMMAND ...ARGS", "Managing processes supervision"
|
32
|
+
subcommand "processes", Processes
|
33
|
+
desc "daemon SUBCOMMAND ...ARGS", "Splash daemon contoller"
|
32
34
|
subcommand "daemon", CLIController
|
33
|
-
desc "config SUBCOMMAND ...ARGS", "
|
35
|
+
desc "config SUBCOMMAND ...ARGS", "Config tools for Splash"
|
34
36
|
subcommand "config", Config
|
35
37
|
desc "documentation SUBCOMMAND ...ARGS", "Documentation for Splash"
|
36
38
|
subcommand "documentation", Documentation
|
39
|
+
|
40
|
+
|
41
|
+
|
37
42
|
end
|
data/lib/splash/config.rb
CHANGED
@@ -22,6 +22,7 @@ module Splash
|
|
22
22
|
self[:daemon_process_name] = (config_from_file[:daemon][:process_name])? config_from_file[:daemon][:process_name] : DAEMON_PROCESS_NAME
|
23
23
|
self[:daemon_logmon_scheduling] = (config_from_file[:daemon][:logmon_scheduling])? config_from_file[:daemon][:logmon_scheduling] : DAEMON_LOGMON_SCHEDULING
|
24
24
|
self[:daemon_metrics_scheduling] = (config_from_file[:daemon][:metrics_scheduling])? config_from_file[:daemon][:metrics_scheduling] : DAEMON_METRICS_SCHEDULING
|
25
|
+
self[:daemon_procmon_scheduling] = (config_from_file[:daemon][:procmon_scheduling])? config_from_file[:daemon][:procmon_scheduling] : DAEMON_PROCMON_SCHEDULING
|
25
26
|
self[:execution_template_tokens] = EXECUTION_TEMPLATE_TOKENS_LIST
|
26
27
|
self[:execution_template_path] = (config_from_file[:templates][:execution][:path])? config_from_file[:templates][:execution][:path] : EXECUTION_TEMPLATE
|
27
28
|
self[:pid_path] = (config_from_file[:daemon][:paths][:pid_path])? config_from_file[:daemon][:paths][:pid_path] : DAEMON_PID_PATH
|
@@ -34,6 +35,7 @@ module Splash
|
|
34
35
|
self[:backends] = {} ; self[:backends].merge! BACKENDS_STRUCT ; self[:backends].merge! config_from_file[:backends] if config_from_file[:backends]
|
35
36
|
self[:loggers] = {} ; self[:loggers].merge! LOGGERS_STRUCT ; self[:loggers].merge! config_from_file[:loggers] if config_from_file[:loggers]
|
36
37
|
|
38
|
+
self[:processes] = (config_from_file[:processes])? config_from_file[:processes] : {}
|
37
39
|
self[:logs] = (config_from_file[:logs])? config_from_file[:logs] : {}
|
38
40
|
self[:commands] = (config_from_file[:commands])? config_from_file[:commands] : {}
|
39
41
|
|
@@ -57,6 +59,10 @@ module Splash
|
|
57
59
|
return self[:daemon_logmon_scheduling]
|
58
60
|
end
|
59
61
|
|
62
|
+
def daemon_procmon_scheduling
|
63
|
+
return self[:daemon_procmon_scheduling]
|
64
|
+
end
|
65
|
+
|
60
66
|
def daemon_metrics_scheduling
|
61
67
|
return self[:daemon_metrics_scheduling]
|
62
68
|
end
|
@@ -75,6 +81,10 @@ module Splash
|
|
75
81
|
return self[:commands]
|
76
82
|
end
|
77
83
|
|
84
|
+
def processes
|
85
|
+
return self[:processes]
|
86
|
+
end
|
87
|
+
|
78
88
|
def author
|
79
89
|
return self[:author]
|
80
90
|
end
|
data/lib/splash/constants.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
module Splash
|
3
3
|
module Constants
|
4
|
-
VERSION = "0.5.
|
4
|
+
VERSION = "0.5.3"
|
5
5
|
|
6
6
|
# the path to th config file, not overridable by config
|
7
7
|
CONFIG_FILE = "/etc/splash.yml"
|
@@ -11,8 +11,10 @@ module Splash
|
|
11
11
|
|
12
12
|
# default scheduling criteria for log monitoring
|
13
13
|
DAEMON_LOGMON_SCHEDULING={ :every => '20s'}
|
14
|
-
# default scheduling criteria for
|
15
|
-
DAEMON_METRICS_SCHEDULING={ :every => '
|
14
|
+
# default scheduling criteria for metrics notifications
|
15
|
+
DAEMON_METRICS_SCHEDULING={ :every => '15s'}
|
16
|
+
# default scheduling criteria for process monitoring
|
17
|
+
DAEMON_PROCMON_SCHEDULING={ :every => '20s'}
|
16
18
|
|
17
19
|
# the display name of daemon in proc info (ps/top)
|
18
20
|
DAEMON_PROCESS_NAME="Splash : daemon."
|
@@ -18,21 +18,26 @@ module Splash
|
|
18
18
|
class Manager
|
19
19
|
|
20
20
|
attr_reader :execution_count
|
21
|
-
attr_reader :
|
21
|
+
attr_reader :monitoring_logs_count
|
22
|
+
attr_reader :monitoring_processes_count
|
22
23
|
|
23
24
|
def initialize
|
24
25
|
@config = get_config
|
25
26
|
@starttime = Time.now
|
26
27
|
@execution_count = 0
|
27
|
-
@
|
28
|
+
@monitoring_logs_count = 0
|
29
|
+
@monitoring_processes_count = 0
|
30
|
+
|
28
31
|
|
29
32
|
@registry = Prometheus::Client::Registry::new
|
30
33
|
@metric_uptime = Prometheus::Client::Gauge.new(:splash_uptime, docstring: 'SPLASH self metric uptime')
|
31
34
|
@metric_execution = Prometheus::Client::Gauge.new(:splash_execution, docstring: 'SPLASH self metric total commands execution count')
|
32
|
-
@
|
35
|
+
@metric_logs_monitoring = Prometheus::Client::Gauge.new(:splash_logs_monitoring, docstring: 'SPLASH self metric total logs monitoring count')
|
36
|
+
@metric_processes_monitoring = Prometheus::Client::Gauge.new(:splash_processes_monitoring, docstring: 'SPLASH self metric total processes monitoring count')
|
33
37
|
@registry.register(@metric_uptime)
|
34
38
|
@registry.register(@metric_execution)
|
35
|
-
@registry.register(@
|
39
|
+
@registry.register(@metric_logs_monitoring)
|
40
|
+
@registry.register(@metric_processes_monitoring)
|
36
41
|
end
|
37
42
|
|
38
43
|
|
@@ -45,10 +50,13 @@ module Splash
|
|
45
50
|
end
|
46
51
|
|
47
52
|
|
48
|
-
def
|
49
|
-
@
|
53
|
+
def inc_logs_monitoring
|
54
|
+
@monitoring_logs_count += 1
|
50
55
|
end
|
51
56
|
|
57
|
+
def inc_processes_monitoring
|
58
|
+
@monitoring_processes_count += 1
|
59
|
+
end
|
52
60
|
|
53
61
|
def notify
|
54
62
|
log = get_logger
|
@@ -60,7 +68,9 @@ module Splash
|
|
60
68
|
log.debug "Sending Splash self metrics to PushGateway." , session
|
61
69
|
@metric_uptime.set uptime
|
62
70
|
@metric_execution.set execution_count
|
63
|
-
@
|
71
|
+
@metric_logs_monitoring.set monitoring_logs_count
|
72
|
+
@metric_processes_monitoring.set monitoring_processes_count
|
73
|
+
|
64
74
|
hostname = Socket.gethostname
|
65
75
|
url = "http://#{@config.prometheus_pushgateway_host}:#{@config.prometheus_pushgateway_port}"
|
66
76
|
Prometheus::Client::Push.new('Splash',hostname, url).add(@registry)
|
@@ -13,6 +13,7 @@ module Splash
|
|
13
13
|
include Splash::Daemon::Orchestrator::Grammar
|
14
14
|
include Splash::Loggers
|
15
15
|
include Splash::Logs
|
16
|
+
include Splash::Processes
|
16
17
|
include Splash::Commands
|
17
18
|
|
18
19
|
|
@@ -25,28 +26,53 @@ module Splash
|
|
25
26
|
@server = Rufus::Scheduler::new
|
26
27
|
@server.extend SchedulerHooks
|
27
28
|
@config = get_config
|
28
|
-
|
29
|
+
|
29
30
|
@log.info "Splash Orchestrator starting :"
|
30
31
|
if options[:scheduling] then
|
31
32
|
@log.item "Initializing commands Scheduling."
|
32
33
|
init_commands_scheduling
|
33
34
|
end
|
34
|
-
|
35
|
-
@
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
35
|
+
|
36
|
+
if @config.logs.empty? then
|
37
|
+
@log.item "No logs to monitor"
|
38
|
+
else
|
39
|
+
sched,value = @config.daemon_procmon_scheduling.flatten
|
40
|
+
@log.item "Initializing logs monitorings & notifications."
|
41
|
+
@log_result = LogScanner::new
|
42
|
+
@server.send sched,value do
|
43
|
+
begin
|
44
|
+
session = get_session
|
45
|
+
@metric_manager.inc_logs_monitoring
|
46
|
+
@log.trigger "Logs monitoring for Scheduling : #{sched.to_s} #{value.to_s}", session
|
47
|
+
@log_result.analyse
|
48
|
+
@log_result.notify :session => session
|
49
|
+
rescue Errno::ECONNREFUSED
|
50
|
+
@log.error "PushGateway seems to be done, please start it.", session
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
if @config.processes.empty? then
|
56
|
+
@log.item "No processes to monitor"
|
57
|
+
else
|
58
|
+
sched,value = @config.daemon_logmon_scheduling.flatten
|
59
|
+
@log.item "Initializing processes monitorings & notifications."
|
60
|
+
@process_result = ProcessScanner::new
|
61
|
+
@server.send sched,value do
|
62
|
+
begin
|
63
|
+
session = get_session
|
64
|
+
@metric_manager.inc_processes_monitoring
|
65
|
+
@log.trigger "Processes monitoring for Scheduling : #{sched.to_s} #{value.to_s}", session
|
66
|
+
@process_result.analyse
|
67
|
+
@process_result.notify :session => session
|
68
|
+
rescue Errno::ECONNREFUSED
|
69
|
+
@log.error "PushGateway seems to be done, please start it.", session
|
70
|
+
end
|
45
71
|
end
|
46
72
|
end
|
47
73
|
|
48
|
-
sched,value = @config.daemon_metrics_scheduling.flatten
|
49
74
|
|
75
|
+
sched,value = @config.daemon_metrics_scheduling.flatten
|
50
76
|
@log.item "Initializing Splash metrics notifications."
|
51
77
|
@server.send sched,value do
|
52
78
|
begin
|
data/lib/splash/dependencies.rb
CHANGED
data/lib/splash/helpers.rb
CHANGED
@@ -17,7 +17,8 @@ module Splash
|
|
17
17
|
# @param [Hash] options
|
18
18
|
# @option options [String] :pattern un motif de regexp
|
19
19
|
# @option options [Array] :patterns Un tableau de motif de regexp
|
20
|
-
# @
|
20
|
+
# @option options [Bool] :full renvoie tout les details si True
|
21
|
+
# @return [String|Array] le PID or tout les détails
|
21
22
|
def get_processes(options = {})
|
22
23
|
patterns = []
|
23
24
|
patterns = options[:patterns] if options[:patterns]
|
@@ -26,7 +27,11 @@ module Splash
|
|
26
27
|
patterns.each do |item|
|
27
28
|
res = res.find_processes item
|
28
29
|
end
|
29
|
-
|
30
|
+
if options[:full] then
|
31
|
+
return res
|
32
|
+
else
|
33
|
+
return res.pick_attr('PID')
|
34
|
+
end
|
30
35
|
end
|
31
36
|
|
32
37
|
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Splash
|
2
|
+
module Processes
|
3
|
+
class ProcessScanner
|
4
|
+
include Splash::Constants
|
5
|
+
include Splash::Config
|
6
|
+
|
7
|
+
|
8
|
+
# LogScanner Constructor
|
9
|
+
# return [LogScanner]
|
10
|
+
def initialize
|
11
|
+
@processes_target = get_config.processes
|
12
|
+
@config = get_config
|
13
|
+
@registry = Prometheus::Client::Registry::new
|
14
|
+
@metric_status = Prometheus::Client::Gauge.new(:process_status, docstring: 'SPLASH metric process status', labels: [:process ])
|
15
|
+
@metric_cpu_percent = Prometheus::Client::Gauge.new(:process_cpu_percent, docstring: 'SPLASH metric process CPU usage in percent', labels: [:process ])
|
16
|
+
@metric_mem_percent = Prometheus::Client::Gauge.new(:process_mem_percent, docstring: 'SPLASH metric process MEM usage in percent', labels: [:process ])
|
17
|
+
@registry.register(@metric_status)
|
18
|
+
@registry.register(@metric_cpu_percent)
|
19
|
+
@registry.register(@metric_mem_percent)
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# start log analyse for log target in config
|
25
|
+
def analyse
|
26
|
+
@processes_target.each do |record|
|
27
|
+
list = get_processes patterns: record[:patterns], full: true
|
28
|
+
if list.empty?
|
29
|
+
record[:status] = :inexistant
|
30
|
+
record[:cpu] = 0
|
31
|
+
record[:mem] = 0
|
32
|
+
else
|
33
|
+
record[:status] = :running
|
34
|
+
record[:cpu] = list[0]['%CPU']
|
35
|
+
record[:mem] = list[0]['%MEM']
|
36
|
+
end
|
37
|
+
end
|
38
|
+
return {:case => :quiet_exit }
|
39
|
+
end
|
40
|
+
|
41
|
+
# pseudo-accessor on @processes_target
|
42
|
+
def output
|
43
|
+
return @processes_target
|
44
|
+
end
|
45
|
+
|
46
|
+
# start notification on prometheus for metrics
|
47
|
+
def notify(options = {})
|
48
|
+
log = get_logger
|
49
|
+
unless verify_service host: @config.prometheus_pushgateway_host ,port: @config.prometheus_pushgateway_port then
|
50
|
+
return { :case => :service_dependence_missing, :more => "Prometheus Notification not send." }
|
51
|
+
end
|
52
|
+
session = (options[:session]) ? options[:session] : log.get_session
|
53
|
+
log.info "Sending metrics to Prometheus Pushgateway", session
|
54
|
+
@processes_target.each do |item|
|
55
|
+
missing = (item[:status] == :missing)? 1 : 0
|
56
|
+
log.item "Sending metrics for #{item[:process]}", session
|
57
|
+
val = (item[:status] == :running )? 1 : 0
|
58
|
+
@metric_status.set(val, labels: { process: item[:process] })
|
59
|
+
@metric_cpu_percent.set(item[:cpu], labels: { process: item[:process] })
|
60
|
+
@metric_mem_percent.set(item[:mem], labels: { process: item[:process] })
|
61
|
+
end
|
62
|
+
hostname = Socket.gethostname
|
63
|
+
url = "http://#{@config.prometheus_pushgateway_host}:#{@config.prometheus_pushgateway_port}"
|
64
|
+
Prometheus::Client::Push.new('Splash',hostname, url).add(@registry)
|
65
|
+
log.ok "Sending to Prometheus PushGateway done.", session
|
66
|
+
return {:case => :quiet_exit }
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/prometheus-splash.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = [Splash::Constants::EMAIL]
|
11
11
|
spec.description = %q{Prometheus Logs and Batchs supervision over PushGateway and commands orchestration}
|
12
12
|
spec.summary = %q{Supervision with Prometheus of Logs and Asynchronous tasks orchestration for Services or Hosts }
|
13
|
-
spec.homepage = "
|
13
|
+
spec.homepage = "https://github.com/Ultragreen/prometheus-splash"
|
14
14
|
spec.license = Splash::Constants::LICENSE
|
15
15
|
spec.require_paths << 'bin'
|
16
16
|
spec.bindir = 'bin'
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Romain GEORGES
|
@@ -265,6 +265,7 @@ files:
|
|
265
265
|
- lib/splash/cli/daemon.rb
|
266
266
|
- lib/splash/cli/documentation.rb
|
267
267
|
- lib/splash/cli/logs.rb
|
268
|
+
- lib/splash/cli/process.rb
|
268
269
|
- lib/splash/commands.rb
|
269
270
|
- lib/splash/config.rb
|
270
271
|
- lib/splash/config/flush.rb
|
@@ -286,6 +287,7 @@ files:
|
|
286
287
|
- lib/splash/loggers/daemon.rb
|
287
288
|
- lib/splash/loggers/dual.rb
|
288
289
|
- lib/splash/logs.rb
|
290
|
+
- lib/splash/processes.rb
|
289
291
|
- lib/splash/templates.rb
|
290
292
|
- lib/splash/transports.rb
|
291
293
|
- lib/splash/transports/rabbitmq.rb
|
@@ -317,7 +319,7 @@ files:
|
|
317
319
|
- templates/splashd.service
|
318
320
|
- test.sh
|
319
321
|
- ultragreen_roodi_coding_convention.yml
|
320
|
-
homepage:
|
322
|
+
homepage: https://github.com/Ultragreen/prometheus-splash
|
321
323
|
licenses:
|
322
324
|
- BSD-2-Clause
|
323
325
|
metadata: {}
|