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,166 +1,174 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
Process.setproctitle($PROGRAM_NAME)
|
3
5
|
|
4
6
|
require 'riemann/tools'
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
8
|
+
module Riemann
|
9
|
+
module Tools
|
10
|
+
class Elasticsearch
|
11
|
+
include Riemann::Tools
|
12
|
+
require 'faraday'
|
13
|
+
require 'json'
|
14
|
+
require 'uri'
|
15
|
+
|
16
|
+
opt :read_timeout, 'Faraday read timeout', type: :int, default: 2
|
17
|
+
opt :open_timeout, 'Faraday open timeout', type: :int, default: 1
|
18
|
+
opt :path_prefix,
|
19
|
+
'Elasticsearch path prefix for proxied installations e.g. "els" for target http://localhost/els/_cluster/health', default: '/'
|
20
|
+
opt :es_host, 'Elasticsearch host', default: 'localhost'
|
21
|
+
opt :es_port, 'Elasticsearch port', type: :int, default: 9200
|
22
|
+
opt :es_search_index, 'Elasticsearch index to fetch search statistics for', default: '_all'
|
23
|
+
|
24
|
+
# Handles HTTP connections and GET requests safely
|
25
|
+
def safe_get(uri)
|
26
|
+
# Handle connection timeouts
|
27
|
+
response = nil
|
28
|
+
begin
|
29
|
+
connection = Faraday.new(uri)
|
30
|
+
response = connection.get do |req|
|
31
|
+
req.options[:timeout] = options[:read_timeout]
|
32
|
+
req.options[:open_timeout] = options[:open_timeout]
|
33
|
+
end
|
34
|
+
rescue StandardError => e
|
35
|
+
report(
|
36
|
+
host: uri.host,
|
37
|
+
service: 'elasticsearch health',
|
38
|
+
state: 'critical',
|
39
|
+
description: "HTTP connection error: #{e.class} - #{e.message}",
|
40
|
+
)
|
29
41
|
end
|
30
|
-
|
31
|
-
report(:host => uri.host,
|
32
|
-
:service => "elasticsearch health",
|
33
|
-
:state => "critical",
|
34
|
-
:description => "HTTP connection error: #{e.class} - #{e.message}"
|
35
|
-
)
|
42
|
+
response
|
36
43
|
end
|
37
|
-
response
|
38
|
-
end
|
39
|
-
|
40
|
-
def make_es_url(path)
|
41
|
-
path_prefix = options[:path_prefix]
|
42
|
-
path_prefix[0] = '' if path_prefix[0]=='/'
|
43
|
-
path_prefix[path_prefix.length-1] = '' if path_prefix[path_prefix.length-1]=='/'
|
44
|
-
"http://#{options[:es_host]}:#{options[:es_port]}#{path_prefix.length>0?'/':''}#{path_prefix}/#{path}"
|
45
|
-
end
|
46
|
-
|
47
|
-
def health_url
|
48
|
-
make_es_url("_cluster/health")
|
49
|
-
end
|
50
|
-
|
51
|
-
def indices_url
|
52
|
-
make_es_url("_stats/store")
|
53
|
-
end
|
54
|
-
|
55
|
-
def search_url
|
56
|
-
es_search_index = options[:es_search_index]
|
57
|
-
make_es_url("#{es_search_index}/_stats/search")
|
58
|
-
end
|
59
|
-
|
60
|
-
def is_bad?(response, uri)
|
61
|
-
if response.success?
|
62
|
-
false
|
63
|
-
else
|
64
|
-
report(:host => uri.host,
|
65
|
-
:service => "elasticsearch health",
|
66
|
-
:state => "critical",
|
67
|
-
:description => response.nil? ? "HTTP response is empty!" : "HTTP connection error: #{response.status} - #{response.body}"
|
68
|
-
)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def tick_indices
|
73
|
-
uri = URI(indices_url)
|
74
|
-
response = safe_get(uri)
|
75
44
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
45
|
+
def make_es_url(path)
|
46
|
+
path_prefix = options[:path_prefix]
|
47
|
+
path_prefix[0] = '' if path_prefix[0] == '/'
|
48
|
+
path_prefix[path_prefix.length - 1] = '' if path_prefix[path_prefix.length - 1] == '/'
|
49
|
+
"http://#{options[:es_host]}:#{options[:es_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/#{path}"
|
50
|
+
end
|
80
51
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
:metric => v["primaries"]["store"]["size_in_bytes"]
|
85
|
-
)
|
86
|
-
report(:host => uri.host,
|
87
|
-
:service => "elasticsearch index/#{k}/total/size_in_bytes",
|
88
|
-
:metric => v["total"]["store"]["size_in_bytes"]
|
89
|
-
)
|
90
|
-
end
|
91
|
-
end
|
52
|
+
def health_url
|
53
|
+
make_es_url('_cluster/health')
|
54
|
+
end
|
92
55
|
|
93
|
-
|
94
|
-
|
95
|
-
|
56
|
+
def indices_url
|
57
|
+
make_es_url('_stats/store')
|
58
|
+
end
|
96
59
|
|
97
|
-
|
60
|
+
def search_url
|
61
|
+
es_search_index = options[:es_search_index]
|
62
|
+
make_es_url("#{es_search_index}/_stats/search")
|
63
|
+
end
|
98
64
|
|
99
|
-
|
100
|
-
|
101
|
-
|
65
|
+
def bad?(response, uri)
|
66
|
+
if response.success?
|
67
|
+
false
|
68
|
+
else
|
69
|
+
report(
|
70
|
+
host: uri.host,
|
71
|
+
service: 'elasticsearch health',
|
72
|
+
state: 'critical',
|
73
|
+
description: response.nil? ? 'HTTP response is empty!' : "HTTP connection error: #{response.status} - #{response.body}",
|
74
|
+
)
|
75
|
+
end
|
76
|
+
end
|
102
77
|
|
103
|
-
|
104
|
-
|
105
|
-
|
78
|
+
def tick_indices
|
79
|
+
uri = URI(indices_url)
|
80
|
+
response = safe_get(uri)
|
81
|
+
|
82
|
+
return if bad?(response, uri)
|
83
|
+
|
84
|
+
# Assuming that a 200 will give json
|
85
|
+
json = JSON.parse(response.body)
|
86
|
+
|
87
|
+
json['indices'].each_pair do |k, v|
|
88
|
+
report(
|
89
|
+
host: uri.host,
|
90
|
+
service: "elasticsearch index/#{k}/primaries/size_in_bytes",
|
91
|
+
metric: v['primaries']['store']['size_in_bytes'],
|
92
|
+
)
|
93
|
+
report(
|
94
|
+
host: uri.host,
|
95
|
+
service: "elasticsearch index/#{k}/total/size_in_bytes",
|
96
|
+
metric: v['total']['store']['size_in_bytes'],
|
97
|
+
)
|
98
|
+
end
|
99
|
+
end
|
106
100
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
101
|
+
def tick_search
|
102
|
+
uri = URI(search_url)
|
103
|
+
response = safe_get(uri)
|
104
|
+
|
105
|
+
return if bad?(response, uri)
|
106
|
+
|
107
|
+
es_search_index = options[:es_search_index]
|
108
|
+
# Assuming that a 200 will give json
|
109
|
+
json = JSON.parse(response.body)
|
110
|
+
|
111
|
+
json['_all'].each_pair do |_type, data|
|
112
|
+
query = data['search']['query_time_in_millis'].to_f / data['search']['query_total']
|
113
|
+
fetch = data['search']['fetch_time_in_millis'].to_f / data['search']['fetch_total']
|
114
|
+
|
115
|
+
report(
|
116
|
+
host: uri.host,
|
117
|
+
service: "elasticsearch search/#{es_search_index}/query",
|
118
|
+
metric: query,
|
119
|
+
)
|
120
|
+
report(
|
121
|
+
host: uri.host,
|
122
|
+
service: "elasticsearch search/#{es_search_index}/fetch",
|
123
|
+
metric: fetch,
|
124
|
+
)
|
125
|
+
end
|
126
|
+
end
|
117
127
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
json.each_pair do |k,v|
|
152
|
-
report(:host => uri.host,
|
153
|
-
:service => "elasticsearch #{k}",
|
154
|
-
:metric => v,
|
155
|
-
:description => "Elasticsearch cluster #{k}"
|
156
|
-
)
|
128
|
+
def tick
|
129
|
+
begin
|
130
|
+
tick_indices
|
131
|
+
tick_search
|
132
|
+
rescue StandardError => e
|
133
|
+
report(
|
134
|
+
host: options[:es_host],
|
135
|
+
service: 'elasticsearch error',
|
136
|
+
state: 'critical',
|
137
|
+
description: "Elasticsearch cluster error: #{e.message}",
|
138
|
+
)
|
139
|
+
end
|
140
|
+
uri = URI(health_url)
|
141
|
+
response = safe_get(uri)
|
142
|
+
|
143
|
+
return if bad?(response, uri)
|
144
|
+
|
145
|
+
# Assuming that a 200 will give json
|
146
|
+
json = JSON.parse(response.body)
|
147
|
+
cluster_name = json.delete('cluster_name')
|
148
|
+
cluster_status = json.delete('status')
|
149
|
+
state = {
|
150
|
+
'green' => 'ok',
|
151
|
+
'yellow' => 'warning',
|
152
|
+
'red' => 'critical',
|
153
|
+
}[cluster_status]
|
154
|
+
|
155
|
+
report(
|
156
|
+
host: uri.host,
|
157
|
+
service: 'elasticsearch health',
|
158
|
+
state: state,
|
159
|
+
description: "Elasticsearch cluster: #{cluster_name} - #{cluster_status}",
|
160
|
+
)
|
157
161
|
|
162
|
+
json.each_pair do |k, v|
|
163
|
+
report(
|
164
|
+
host: uri.host,
|
165
|
+
service: "elasticsearch #{k}",
|
166
|
+
metric: v,
|
167
|
+
description: "Elasticsearch cluster #{k}",
|
168
|
+
)
|
169
|
+
end
|
170
|
+
end
|
158
171
|
end
|
159
|
-
|
160
172
|
end
|
161
|
-
|
162
|
-
|
163
|
-
|
164
173
|
end
|
165
174
|
Riemann::Tools::Elasticsearch.run
|
166
|
-
|
@@ -1,142 +1,159 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
4
|
+
Process.setproctitle($PROGRAM_NAME)
|
5
5
|
|
6
|
-
|
7
|
-
include Riemann::Tools
|
6
|
+
require 'riemann/tools'
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
module Riemann
|
9
|
+
module Tools
|
10
|
+
class Marathon
|
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
|
+
'Marathon path prefix for proxied installations e.g. "marathon" for target http://localhost/marathon/metrics', default: '/'
|
21
|
+
opt :marathon_host, 'Marathon host', default: 'localhost'
|
22
|
+
opt :marathon_port, 'Marathon port', type: :int, default: 8080
|
23
|
+
|
24
|
+
def initialize
|
25
|
+
options[:interval] = 60
|
26
|
+
options[:ttl] = 120
|
27
|
+
end
|
12
28
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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: 'marathon health',
|
43
|
+
state: 'critical',
|
44
|
+
description: "HTTP connection error: #{e.class} - #{e.message}",
|
45
|
+
)
|
46
|
+
end
|
47
|
+
response
|
48
|
+
end
|
18
49
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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[:marathon_host]}:#{options[:marathon_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/metrics"
|
55
|
+
end
|
23
56
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
connection = Faraday.new(uri)
|
30
|
-
response = connection.get do |req|
|
31
|
-
req.options[:timeout] = options[:read_timeout]
|
32
|
-
req.options[:open_timeout] = options[:open_timeout]
|
33
|
-
end
|
34
|
-
rescue => e
|
35
|
-
report(:host => uri.host,
|
36
|
-
:service => "marathon health",
|
37
|
-
:state => "critical",
|
38
|
-
:description => "HTTP connection error: #{e.class} - #{e.message}"
|
39
|
-
)
|
57
|
+
def apps_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[:marathon_host]}:#{options[:marathon_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/v2/apps"
|
40
62
|
end
|
41
|
-
response
|
42
|
-
end
|
43
63
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
"http://#{options[:marathon_host]}:#{options[:marathon_port]}#{path_prefix.length>0?'/':''}#{path_prefix}/metrics"
|
49
|
-
end
|
64
|
+
def tick
|
65
|
+
tick_health
|
66
|
+
tick_apps
|
67
|
+
end
|
50
68
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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: 'marathon 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
|
+
state = 'ok'
|
86
|
+
|
87
|
+
report(
|
88
|
+
host: uri.host,
|
89
|
+
service: 'marathon health',
|
90
|
+
state: state,
|
91
|
+
)
|
92
|
+
|
93
|
+
json.each_pair do |t, d|
|
94
|
+
next unless d.respond_to? :each_pair
|
95
|
+
|
96
|
+
d.each_pair do |service, counters|
|
97
|
+
report(
|
98
|
+
host: uri.host,
|
99
|
+
service: "marathon_metric #{t} #{service}",
|
100
|
+
metric: 1,
|
101
|
+
tags: ['metric_name'],
|
102
|
+
ttl: 600,
|
103
|
+
)
|
104
|
+
next unless counters.respond_to? :each_pair
|
57
105
|
|
58
|
-
def tick
|
59
|
-
tick_health
|
60
|
-
tick_apps
|
61
|
-
end
|
62
|
-
|
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 => "marathon 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
|
-
state = "ok"
|
79
|
-
|
80
|
-
report(:host => uri.host,
|
81
|
-
:service => "marathon health",
|
82
|
-
:state => state)
|
83
|
-
|
84
|
-
json.each_pair do |t, d|
|
85
|
-
if d.respond_to? :each_pair
|
86
|
-
d.each_pair do |service, counters|
|
87
|
-
report(:host => uri.host,
|
88
|
-
:service => "marathon_metric #{t} #{service}",
|
89
|
-
:metric => 1,
|
90
|
-
:tags => ["metric_name"],
|
91
|
-
:ttl => 600
|
92
|
-
)
|
93
|
-
if counters.respond_to? :each_pair
|
94
106
|
counters.each_pair do |k, v|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
107
|
+
next unless v.is_a? Numeric
|
108
|
+
|
109
|
+
report(
|
110
|
+
host: uri.host,
|
111
|
+
service: "marathon #{service} #{k}",
|
112
|
+
metric: v,
|
113
|
+
tags: ['metric', t.to_s],
|
114
|
+
ttl: 600,
|
115
|
+
)
|
103
116
|
end
|
104
117
|
end
|
105
118
|
end
|
106
119
|
end
|
107
120
|
end
|
108
|
-
end
|
109
|
-
end
|
110
121
|
|
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
|
-
|
138
|
-
|
139
|
-
|
122
|
+
def tick_apps
|
123
|
+
uri = URI(apps_url)
|
124
|
+
response = safe_get(uri)
|
125
|
+
|
126
|
+
return if response.nil?
|
127
|
+
|
128
|
+
if response.status != 200
|
129
|
+
report(
|
130
|
+
host: uri.host,
|
131
|
+
service: 'marathon health',
|
132
|
+
state: 'critical',
|
133
|
+
description: "HTTP connection error: #{response.status} - #{response.body}",
|
134
|
+
)
|
135
|
+
else
|
136
|
+
# Assuming that a 200 will give json
|
137
|
+
json = JSON.parse(response.body)
|
138
|
+
state = 'ok'
|
139
|
+
|
140
|
+
report(
|
141
|
+
host: uri.host,
|
142
|
+
service: 'marathon health',
|
143
|
+
state: state,
|
144
|
+
)
|
145
|
+
|
146
|
+
json['apps'].each do |app|
|
147
|
+
app.each_pair do |k, v|
|
148
|
+
next unless v.is_a? Numeric
|
149
|
+
|
150
|
+
report(
|
151
|
+
host: uri.host,
|
152
|
+
service: "marathon apps#{app['id']}/#{k}",
|
153
|
+
metric: v,
|
154
|
+
ttl: 120,
|
155
|
+
)
|
156
|
+
end
|
140
157
|
end
|
141
158
|
end
|
142
159
|
end
|
@@ -144,4 +161,3 @@ class Riemann::Tools::Marathon
|
|
144
161
|
end
|
145
162
|
end
|
146
163
|
Riemann::Tools::Marathon.run
|
147
|
-
|