riemann-tools 1.0.0 → 1.1.0
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/.github/dependabot.yml +11 -0
- data/.github/workflows/ci.yml +13 -0
- data/.github/workflows/codeql-analysis.yml +72 -0
- data/.rubocop.yml +32 -0
- data/CHANGELOG.md +31 -2
- data/README.markdown +8 -24
- data/Rakefile +4 -2
- data/SECURITY.md +42 -0
- data/bin/riemann-apache-status +92 -78
- data/bin/riemann-bench +54 -49
- data/bin/riemann-cloudant +44 -40
- data/bin/riemann-consul +82 -76
- data/bin/riemann-dir-files-count +53 -47
- data/bin/riemann-dir-space +53 -47
- data/bin/riemann-diskstats +78 -75
- data/bin/riemann-fd +68 -48
- data/bin/riemann-freeswitch +108 -103
- data/bin/riemann-haproxy +46 -40
- data/bin/riemann-health +4 -343
- data/bin/riemann-kvminstance +18 -13
- data/bin/riemann-memcached +35 -29
- data/bin/riemann-net +4 -104
- data/bin/riemann-nginx-status +74 -67
- data/bin/riemann-ntp +4 -33
- data/bin/riemann-portcheck +40 -31
- data/bin/riemann-proc +96 -90
- data/bin/riemann-varnish +51 -45
- data/bin/riemann-zookeeper +38 -34
- data/lib/riemann/tools/health.rb +347 -0
- data/lib/riemann/tools/net.rb +104 -0
- data/lib/riemann/tools/ntp.rb +41 -0
- data/lib/riemann/tools/version.rb +1 -1
- data/lib/riemann/tools.rb +37 -40
- data/riemann-tools.gemspec +4 -1
- data/tools/riemann-aws/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-aws/bin/riemann-aws-billing +72 -66
- data/tools/riemann-aws/bin/riemann-aws-rds-status +55 -41
- data/tools/riemann-aws/bin/riemann-aws-sqs-status +37 -31
- data/tools/riemann-aws/bin/riemann-aws-status +63 -51
- data/tools/riemann-aws/bin/riemann-elb-metrics +149 -148
- data/tools/riemann-aws/bin/riemann-s3-list +70 -65
- data/tools/riemann-aws/bin/riemann-s3-status +85 -82
- data/tools/riemann-chronos/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-chronos/bin/riemann-chronos +136 -119
- data/tools/riemann-docker/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-docker/bin/riemann-docker +163 -174
- data/tools/riemann-elasticsearch/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-elasticsearch/bin/riemann-elasticsearch +155 -147
- data/tools/riemann-marathon/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-marathon/bin/riemann-marathon +138 -122
- data/tools/riemann-mesos/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-mesos/bin/riemann-mesos +125 -110
- data/tools/riemann-munin/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-munin/bin/riemann-munin +28 -22
- data/tools/riemann-rabbitmq/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-rabbitmq/bin/riemann-rabbitmq +226 -222
- data/tools/riemann-riak/{Rakefile.rb → Rakefile} +2 -0
- data/tools/riemann-riak/bin/riemann-riak +281 -289
- data/tools/riemann-riak/riak_status/riak_status.rb +39 -39
- metadata +65 -16
@@ -1,140 +1,157 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
class Riemann::Tools::Chronos
|
7
|
-
include Riemann::Tools
|
8
|
-
|
9
|
-
require 'faraday'
|
10
|
-
require 'json'
|
11
|
-
require 'uri'
|
4
|
+
Process.setproctitle($PROGRAM_NAME)
|
12
5
|
|
13
|
-
|
14
|
-
opt :open_timeout, 'Faraday open timeout', type: :int, default: 1
|
15
|
-
opt :path_prefix, 'Chronos path prefix for proxied installations e.g. "chronos" for target http://localhost/chronos/metrics', default: "/"
|
16
|
-
opt :chronos_host, 'Chronos host', default: "localhost"
|
17
|
-
opt :chronos_port, 'Chronos port', type: :int, default: 4400
|
6
|
+
require 'riemann/tools'
|
18
7
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
8
|
+
module Riemann
|
9
|
+
module Tools
|
10
|
+
class Chronos
|
11
|
+
include Riemann::Tools
|
12
|
+
|
13
|
+
require 'faraday'
|
14
|
+
require 'json'
|
15
|
+
require 'uri'
|
16
|
+
|
17
|
+
opt :read_timeout, 'Faraday read timeout', type: :int, default: 2
|
18
|
+
opt :open_timeout, 'Faraday open timeout', type: :int, default: 1
|
19
|
+
opt :path_prefix,
|
20
|
+
'Chronos path prefix for proxied installations e.g. "chronos" for target http://localhost/chronos/metrics', default: '/'
|
21
|
+
opt :chronos_host, 'Chronos host', default: 'localhost'
|
22
|
+
opt :chronos_port, 'Chronos port', type: :int, default: 4400
|
23
|
+
|
24
|
+
def initialize
|
25
|
+
options[:interval] = 60
|
26
|
+
options[:ttl] = 120
|
27
|
+
end
|
23
28
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
# Handles HTTP connections and GET requests safely
|
30
|
+
def safe_get(uri)
|
31
|
+
# Handle connection timeouts
|
32
|
+
response = nil
|
33
|
+
begin
|
34
|
+
connection = Faraday.new(uri)
|
35
|
+
response = connection.get do |req|
|
36
|
+
req.options[:timeout] = options[:read_timeout]
|
37
|
+
req.options[:open_timeout] = options[:open_timeout]
|
38
|
+
end
|
39
|
+
rescue StandardError => e
|
40
|
+
report(
|
41
|
+
host: uri.host,
|
42
|
+
service: 'chronos health',
|
43
|
+
state: 'critical',
|
44
|
+
description: "HTTP connection error: #{e.class} - #{e.message}",
|
45
|
+
)
|
33
46
|
end
|
34
|
-
|
35
|
-
report(:host => uri.host,
|
36
|
-
:service => "chronos health",
|
37
|
-
:state => "critical",
|
38
|
-
:description => "HTTP connection error: #{e.class} - #{e.message}"
|
39
|
-
)
|
47
|
+
response
|
40
48
|
end
|
41
|
-
response
|
42
|
-
end
|
43
49
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
+
def health_url
|
51
|
+
path_prefix = options[:path_prefix]
|
52
|
+
path_prefix[0] = '' if path_prefix[0] == '/'
|
53
|
+
path_prefix[path_prefix.length - 1] = '' if path_prefix[path_prefix.length - 1] == '/'
|
54
|
+
"http://#{options[:chronos_host]}:#{options[:chronos_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/metrics"
|
55
|
+
end
|
50
56
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
+
def jobs_url
|
58
|
+
path_prefix = options[:path_prefix]
|
59
|
+
path_prefix[0] = '' if path_prefix[0] == '/'
|
60
|
+
path_prefix[path_prefix.length - 1] = '' if path_prefix[path_prefix.length - 1] == '/'
|
61
|
+
"http://#{options[:chronos_host]}:#{options[:chronos_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/scheduler/jobs"
|
62
|
+
end
|
57
63
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
64
|
+
def tick
|
65
|
+
tick_health
|
66
|
+
tick_jobs
|
67
|
+
end
|
68
|
+
|
69
|
+
def tick_health
|
70
|
+
uri = URI(health_url)
|
71
|
+
response = safe_get(uri)
|
72
|
+
|
73
|
+
return if response.nil?
|
74
|
+
|
75
|
+
if response.status != 200
|
76
|
+
report(
|
77
|
+
host: uri.host,
|
78
|
+
service: 'chronos health',
|
79
|
+
state: 'critical',
|
80
|
+
description: "HTTP connection error: #{response.status} - #{response.body}",
|
81
|
+
)
|
82
|
+
else
|
83
|
+
# Assuming that a 200 will give json
|
84
|
+
json = JSON.parse(response.body)
|
85
|
+
|
86
|
+
report(
|
87
|
+
host: uri.host,
|
88
|
+
service: 'chronos health',
|
89
|
+
state: 'ok',
|
90
|
+
)
|
91
|
+
|
92
|
+
json.each_pair do |t, d|
|
93
|
+
next unless d.respond_to? :each_pair
|
94
|
+
|
95
|
+
d.each_pair do |service, counters|
|
96
|
+
report(
|
97
|
+
host: uri.host,
|
98
|
+
service: "chronos_metric #{t} #{service}",
|
99
|
+
metric: 1,
|
100
|
+
tags: ['metric_name'],
|
101
|
+
ttl: 600,
|
102
|
+
)
|
103
|
+
next unless counters.respond_to? :each_pair
|
62
104
|
|
63
|
-
def tick_health
|
64
|
-
uri = URI(health_url)
|
65
|
-
response = safe_get(uri)
|
66
|
-
|
67
|
-
return if response.nil?
|
68
|
-
|
69
|
-
if response.status != 200
|
70
|
-
report(:host => uri.host,
|
71
|
-
:service => "chronos health",
|
72
|
-
:state => "critical",
|
73
|
-
:description => "HTTP connection error: #{response.status} - #{response.body}"
|
74
|
-
)
|
75
|
-
else
|
76
|
-
# Assuming that a 200 will give json
|
77
|
-
json = JSON.parse(response.body)
|
78
|
-
|
79
|
-
report(:host => uri.host,
|
80
|
-
:service => "chronos health",
|
81
|
-
:state => "ok")
|
82
|
-
|
83
|
-
json.each_pair do |t, d|
|
84
|
-
if d.respond_to? :each_pair
|
85
|
-
d.each_pair do |service, counters|
|
86
|
-
report(:host => uri.host,
|
87
|
-
:service => "chronos_metric #{t} #{service}",
|
88
|
-
:metric => 1,
|
89
|
-
:tags => ["metric_name"],
|
90
|
-
:ttl => 600
|
91
|
-
)
|
92
|
-
if counters.respond_to? :each_pair
|
93
105
|
counters.each_pair do |k, v|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
106
|
+
next unless v.is_a? Numeric
|
107
|
+
|
108
|
+
report(
|
109
|
+
host: uri.host,
|
110
|
+
service: "chronos #{service} #{k}",
|
111
|
+
metric: v,
|
112
|
+
tags: ['metric', t.to_s],
|
113
|
+
ttl: 600,
|
114
|
+
)
|
102
115
|
end
|
103
116
|
end
|
104
117
|
end
|
105
118
|
end
|
106
119
|
end
|
107
|
-
end
|
108
|
-
end
|
109
120
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
121
|
+
def tick_jobs
|
122
|
+
uri = URI(jobs_url)
|
123
|
+
response = safe_get(uri)
|
124
|
+
|
125
|
+
return if response.nil?
|
126
|
+
|
127
|
+
if response.status != 200
|
128
|
+
report(
|
129
|
+
host: uri.host,
|
130
|
+
service: 'chronos health',
|
131
|
+
state: 'critical',
|
132
|
+
description: "HTTP connection error: #{response.status} - #{response.body}",
|
133
|
+
)
|
134
|
+
else
|
135
|
+
# Assuming that a 200 will give json
|
136
|
+
json = JSON.parse(response.body)
|
137
|
+
|
138
|
+
report(
|
139
|
+
host: uri.host,
|
140
|
+
service: 'chronos health',
|
141
|
+
state: 'ok',
|
142
|
+
)
|
143
|
+
|
144
|
+
json.each do |job|
|
145
|
+
job.each_pair do |k, v|
|
146
|
+
next unless v.is_a? Numeric
|
147
|
+
|
148
|
+
report(
|
149
|
+
host: uri.host,
|
150
|
+
service: "chronos job #{job['name']} #{k}",
|
151
|
+
metric: v,
|
152
|
+
ttl: 120,
|
153
|
+
)
|
154
|
+
end
|
138
155
|
end
|
139
156
|
end
|
140
157
|
end
|