riemann-tools 1.1.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +2 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +8 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +55 -2
- data/Rakefile +17 -3
- data/bin/riemann-apache-status +1 -106
- data/bin/riemann-bench +2 -70
- data/bin/riemann-cloudant +1 -56
- data/bin/riemann-consul +1 -106
- data/bin/riemann-dir-files-count +1 -55
- data/bin/riemann-dir-space +1 -55
- data/bin/riemann-diskstats +1 -92
- data/bin/riemann-fd +2 -81
- data/bin/riemann-freeswitch +2 -119
- data/bin/riemann-haproxy +1 -58
- data/bin/riemann-health +0 -2
- data/bin/riemann-kvminstance +2 -22
- data/bin/riemann-md +8 -0
- data/bin/riemann-memcached +1 -37
- data/bin/riemann-net +0 -2
- data/bin/riemann-nginx-status +1 -85
- data/bin/riemann-ntp +0 -2
- data/bin/riemann-portcheck +1 -44
- data/bin/riemann-proc +1 -108
- data/bin/riemann-varnish +1 -54
- data/bin/riemann-wrapper +113 -0
- data/bin/riemann-zookeeper +1 -39
- data/bin/riemann-zpool +8 -0
- data/lib/riemann/tools/apache_status.rb +107 -0
- data/lib/riemann/tools/bench.rb +72 -0
- data/lib/riemann/tools/cloudant.rb +57 -0
- data/lib/riemann/tools/consul_health.rb +107 -0
- data/lib/riemann/tools/dir_files_count.rb +56 -0
- data/lib/riemann/tools/dir_space.rb +56 -0
- data/lib/riemann/tools/diskstats.rb +94 -0
- data/lib/riemann/tools/fd.rb +81 -0
- data/lib/riemann/tools/freeswitch.rb +119 -0
- data/lib/riemann/tools/haproxy.rb +59 -0
- data/lib/riemann/tools/health.rb +150 -19
- data/lib/riemann/tools/kvm.rb +23 -0
- data/lib/riemann/tools/md.rb +35 -0
- data/lib/riemann/tools/mdstat_parser.tab.rb +340 -0
- data/lib/riemann/tools/memcached.rb +38 -0
- data/lib/riemann/tools/net.rb +2 -1
- data/lib/riemann/tools/nginx_status.rb +86 -0
- data/lib/riemann/tools/ntp.rb +1 -0
- data/lib/riemann/tools/portcheck.rb +45 -0
- data/lib/riemann/tools/proc.rb +109 -0
- data/lib/riemann/tools/riemann_client_wrapper.rb +43 -0
- data/lib/riemann/tools/uptime_parser.tab.rb +323 -0
- data/lib/riemann/tools/varnish.rb +55 -0
- data/lib/riemann/tools/version.rb +1 -1
- data/lib/riemann/tools/zookeeper.rb +40 -0
- data/lib/riemann/tools/zpool.rb +29 -0
- data/lib/riemann/tools.rb +2 -20
- data/riemann-tools.gemspec +10 -1
- data/tools/riemann-aws/Rakefile +6 -9
- data/tools/riemann-aws/bin/riemann-aws-billing +2 -87
- data/tools/riemann-aws/bin/riemann-aws-rds-status +2 -62
- data/tools/riemann-aws/bin/riemann-aws-sqs-status +2 -44
- data/tools/riemann-aws/bin/riemann-aws-status +2 -77
- data/tools/riemann-aws/bin/riemann-elb-metrics +2 -162
- data/tools/riemann-aws/bin/riemann-s3-list +2 -81
- data/tools/riemann-aws/bin/riemann-s3-status +2 -96
- data/tools/riemann-aws/lib/riemann/tools/aws/billing.rb +87 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/elb_metrics.rb +163 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/rds_status.rb +63 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/s3_list.rb +82 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/s3_status.rb +97 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/sqs_status.rb +45 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/status.rb +74 -0
- data/tools/riemann-chronos/Rakefile +6 -9
- data/tools/riemann-chronos/bin/riemann-chronos +1 -154
- data/tools/riemann-chronos/lib/riemann/tools/chronos.rb +157 -0
- data/tools/riemann-docker/Rakefile +5 -8
- data/tools/riemann-docker/bin/riemann-docker +2 -200
- data/tools/riemann-docker/lib/riemann/tools/docker.rb +200 -0
- data/tools/riemann-elasticsearch/Rakefile +6 -9
- data/tools/riemann-elasticsearch/bin/riemann-elasticsearch +1 -167
- data/tools/riemann-elasticsearch/lib/riemann/tools/elasticsearch.rb +170 -0
- data/tools/riemann-marathon/Rakefile +6 -9
- data/tools/riemann-marathon/bin/riemann-marathon +1 -156
- data/tools/riemann-marathon/lib/riemann/tools/marathon.rb +159 -0
- data/tools/riemann-mesos/Rakefile +6 -9
- data/tools/riemann-mesos/bin/riemann-mesos +1 -139
- data/tools/riemann-mesos/lib/riemann/tools/mesos.rb +142 -0
- data/tools/riemann-munin/Rakefile +5 -8
- data/tools/riemann-munin/bin/riemann-munin +1 -36
- data/tools/riemann-munin/lib/riemann/tools/munin.rb +37 -0
- data/tools/riemann-rabbitmq/Rakefile +6 -9
- data/tools/riemann-rabbitmq/bin/riemann-rabbitmq +1 -266
- data/tools/riemann-rabbitmq/lib/riemann/tools/rabbitmq.rb +269 -0
- data/tools/riemann-riak/Rakefile +5 -8
- data/tools/riemann-riak/bin/riemann-riak +1 -316
- data/tools/riemann-riak/bin/riemann-riak-keys +0 -1
- data/tools/riemann-riak/bin/riemann-riak-ring +0 -1
- data/tools/riemann-riak/lib/riemann/tools/riak.rb +317 -0
- metadata +61 -7
- data/.travis.yml +0 -31
- data/tools/riemann-riak/riak_status/key_count.erl +0 -13
- data/tools/riemann-riak/riak_status/riak_status.rb +0 -152
- data/tools/riemann-riak/riak_status/ringready.erl +0 -9
@@ -0,0 +1,142 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'riemann/tools'
|
4
|
+
|
5
|
+
module Riemann
|
6
|
+
module Tools
|
7
|
+
class Mesos
|
8
|
+
include Riemann::Tools
|
9
|
+
|
10
|
+
require 'faraday'
|
11
|
+
require 'json'
|
12
|
+
require 'uri'
|
13
|
+
|
14
|
+
opt :read_timeout, 'Faraday read timeout', type: :int, default: 2
|
15
|
+
opt :open_timeout, 'Faraday open timeout', type: :int, default: 1
|
16
|
+
opt :path_prefix,
|
17
|
+
'Mesos path prefix for proxied installations e.g. "mesos" for target http://localhost/mesos/metrics/snapshot', default: '/'.dup
|
18
|
+
opt :mesos_host, 'Mesos host', default: 'localhost'
|
19
|
+
opt :mesos_port, 'Mesos port', type: :int, default: 5050
|
20
|
+
|
21
|
+
# Handles HTTP connections and GET requests safely
|
22
|
+
def safe_get(uri)
|
23
|
+
# Handle connection timeouts
|
24
|
+
response = nil
|
25
|
+
begin
|
26
|
+
connection = Faraday.new(uri)
|
27
|
+
response = connection.get do |req|
|
28
|
+
req.options[:timeout] = options[:read_timeout]
|
29
|
+
req.options[:open_timeout] = options[:open_timeout]
|
30
|
+
end
|
31
|
+
rescue StandardError => e
|
32
|
+
report(
|
33
|
+
host: uri.host,
|
34
|
+
service: 'mesos health',
|
35
|
+
state: 'critical',
|
36
|
+
description: "HTTP connection error: #{e.class} - #{e.message}",
|
37
|
+
)
|
38
|
+
end
|
39
|
+
response
|
40
|
+
end
|
41
|
+
|
42
|
+
def health_url
|
43
|
+
path_prefix = options[:path_prefix]
|
44
|
+
path_prefix[0] = '' if path_prefix[0] == '/'
|
45
|
+
path_prefix[path_prefix.length - 1] = '' if path_prefix[path_prefix.length - 1] == '/'
|
46
|
+
"http://#{options[:mesos_host]}:#{options[:mesos_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/metrics/snapshot"
|
47
|
+
end
|
48
|
+
|
49
|
+
def slaves_url
|
50
|
+
path_prefix = options[:path_prefix]
|
51
|
+
path_prefix[0] = '' if path_prefix[0] == '/'
|
52
|
+
path_prefix[path_prefix.length - 1] = '' if path_prefix[path_prefix.length - 1] == '/'
|
53
|
+
"http://#{options[:mesos_host]}:#{options[:mesos_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/master/slaves"
|
54
|
+
end
|
55
|
+
|
56
|
+
def tick
|
57
|
+
tick_slaves
|
58
|
+
uri = URI(health_url)
|
59
|
+
response = safe_get(uri)
|
60
|
+
|
61
|
+
return if response.nil?
|
62
|
+
|
63
|
+
if response.status != 200
|
64
|
+
report(
|
65
|
+
host: uri.host,
|
66
|
+
service: 'mesos health',
|
67
|
+
state: 'critical',
|
68
|
+
description: "HTTP connection error: #{response.status} - #{response.body}",
|
69
|
+
)
|
70
|
+
else
|
71
|
+
# Assuming that a 200 will give json
|
72
|
+
json = JSON.parse(response.body)
|
73
|
+
state = 'ok'
|
74
|
+
|
75
|
+
report(
|
76
|
+
host: uri.host,
|
77
|
+
service: 'mesos health',
|
78
|
+
state: state,
|
79
|
+
)
|
80
|
+
|
81
|
+
json.each_pair do |k, v|
|
82
|
+
report(
|
83
|
+
host: uri.host,
|
84
|
+
service: "mesos #{k}",
|
85
|
+
metric: v,
|
86
|
+
)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def tick_slaves
|
92
|
+
uri = URI(slaves_url)
|
93
|
+
response = safe_get(uri)
|
94
|
+
|
95
|
+
return if response.nil?
|
96
|
+
|
97
|
+
if response.status != 200
|
98
|
+
report(
|
99
|
+
host: uri.host,
|
100
|
+
service: 'mesos health',
|
101
|
+
state: 'critical',
|
102
|
+
description: "HTTP connection error: #{response.status} - #{response.body}",
|
103
|
+
)
|
104
|
+
else
|
105
|
+
# Assuming that a 200 will give json
|
106
|
+
json = JSON.parse(response.body)
|
107
|
+
state = 'ok'
|
108
|
+
|
109
|
+
report(
|
110
|
+
host: uri.host,
|
111
|
+
service: 'mesos health',
|
112
|
+
state: state,
|
113
|
+
)
|
114
|
+
|
115
|
+
json['slaves'].each do |slave|
|
116
|
+
next unless slave.respond_to? 'each_pair'
|
117
|
+
|
118
|
+
slave.each_pair do |k, v|
|
119
|
+
if v.respond_to? 'each_pair'
|
120
|
+
v.each_pair do |k1, v1|
|
121
|
+
next unless v1.is_a? Numeric
|
122
|
+
|
123
|
+
report(
|
124
|
+
host: slave['hostname'],
|
125
|
+
service: "mesos slave/#{k}/#{k1}",
|
126
|
+
metric: v1,
|
127
|
+
)
|
128
|
+
end
|
129
|
+
elsif v.is_a? Numeric
|
130
|
+
report(
|
131
|
+
host: slave['hostname'],
|
132
|
+
service: "mesos slave/#{k}",
|
133
|
+
metric: v,
|
134
|
+
)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
@@ -11,10 +11,8 @@ ENV['COPYFILE_DISABLE'] = 'true'
|
|
11
11
|
|
12
12
|
# Gemspec
|
13
13
|
gemspec = Gem::Specification.new do |s|
|
14
|
-
s.rubyforge_project = 'riemann-munin'
|
15
|
-
|
16
14
|
s.name = 'riemann-munin'
|
17
|
-
s.version = '0.1.
|
15
|
+
s.version = '0.1.4'
|
18
16
|
s.author = 'Kyle Kingsbury'
|
19
17
|
s.email = 'aphyr@aphyr.com'
|
20
18
|
s.homepage = 'https://github.com/riemann/riemann-tools'
|
@@ -22,14 +20,13 @@ gemspec = Gem::Specification.new do |s|
|
|
22
20
|
s.summary = 'Submits munin stats to riemann.'
|
23
21
|
s.license = 'MIT'
|
24
22
|
|
25
|
-
s.
|
26
|
-
s.
|
23
|
+
s.add_runtime_dependency 'riemann-tools', '~> 1.0', '>= 1.1.1'
|
24
|
+
s.add_runtime_dependency 'munin-ruby', '~> 0.2', '>= 0.2.5'
|
27
25
|
|
28
|
-
s.files = FileList['bin/*', 'LICENSE', 'README.md'].to_a
|
26
|
+
s.files = FileList['bin/*', 'lib/**/*.rb', 'LICENSE', 'README.md'].to_a
|
29
27
|
s.executables |= Dir.entries('bin/')
|
30
|
-
s.has_rdoc = false
|
31
28
|
|
32
|
-
s.required_ruby_version = '>=
|
29
|
+
s.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
|
33
30
|
end
|
34
31
|
|
35
32
|
Gem::PackageTask.new gemspec do |p|
|
@@ -3,41 +3,6 @@
|
|
3
3
|
|
4
4
|
Process.setproctitle($PROGRAM_NAME)
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
require 'riemann/tools'
|
9
|
-
|
10
|
-
module Riemann
|
11
|
-
module Tools
|
12
|
-
class Munin
|
13
|
-
include Riemann::Tools
|
14
|
-
require 'munin-ruby'
|
15
|
-
|
16
|
-
def initialize
|
17
|
-
@munin = ::Munin::Node.new
|
18
|
-
end
|
19
|
-
|
20
|
-
def tick
|
21
|
-
services = opts[:services] || @munin.list
|
22
|
-
services.each do |service_name|
|
23
|
-
@munin.fetch(service_name).each do |service, parts|
|
24
|
-
parts.each do |part, metric|
|
25
|
-
report(
|
26
|
-
service: "#{service} #{part}",
|
27
|
-
metric: metric.to_f,
|
28
|
-
state: 'ok',
|
29
|
-
tags: ['munin'],
|
30
|
-
)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
opt :munin_host, 'Munin hostname', default: 'localhost'
|
37
|
-
opt :munin_port, 'Munin port', default: 4949
|
38
|
-
opt :services, 'Munin services to translate (if not specified, all services are relayed)', type: :strings
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
6
|
+
require 'riemann/tools/munin'
|
42
7
|
|
43
8
|
Riemann::Tools::Munin.run
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'riemann/tools'
|
4
|
+
|
5
|
+
# Gathers munin statistics and submits them to Riemann.
|
6
|
+
module Riemann
|
7
|
+
module Tools
|
8
|
+
class Munin
|
9
|
+
include Riemann::Tools
|
10
|
+
require 'munin-ruby'
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@munin = ::Munin::Node.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def tick
|
17
|
+
services = opts[:services] || @munin.list
|
18
|
+
services.each do |service_name|
|
19
|
+
@munin.fetch(service_name).each do |service, parts|
|
20
|
+
parts.each do |part, metric|
|
21
|
+
report(
|
22
|
+
service: "#{service} #{part}",
|
23
|
+
metric: metric.to_f,
|
24
|
+
state: 'ok',
|
25
|
+
tags: ['munin'],
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
opt :munin_host, 'Munin hostname', default: 'localhost'
|
33
|
+
opt :munin_port, 'Munin port', default: 4949
|
34
|
+
opt :services, 'Munin services to translate (if not specified, all services are relayed)', type: :strings
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -11,10 +11,8 @@ ENV['COPYFILE_DISABLE'] = 'true'
|
|
11
11
|
|
12
12
|
# Gemspec
|
13
13
|
gemspec = Gem::Specification.new do |s|
|
14
|
-
s.rubyforge_project = 'riemann-rabbitmq'
|
15
|
-
|
16
14
|
s.name = 'riemann-rabbitmq'
|
17
|
-
s.version = '0.1.
|
15
|
+
s.version = '0.1.5'
|
18
16
|
s.author = 'Gavin Sandie'
|
19
17
|
s.email = 'beach@vicecity.co.uk'
|
20
18
|
s.homepage = 'https://github.com/riemann/riemann-tools'
|
@@ -22,15 +20,14 @@ gemspec = Gem::Specification.new do |s|
|
|
22
20
|
s.summary = 'Submits RabbitMQ stats to riemann.'
|
23
21
|
s.license = 'MIT'
|
24
22
|
|
25
|
-
s.
|
26
|
-
s.
|
27
|
-
s.
|
23
|
+
s.add_runtime_dependency 'riemann-tools', '~> 1.0', '>= 1.1.1'
|
24
|
+
s.add_runtime_dependency 'faraday', '~> 2.3', '>= 2.3.0'
|
25
|
+
s.add_runtime_dependency 'json', '~> 2.6', '>=2.6.2'
|
28
26
|
|
29
|
-
s.files = FileList['bin/*', 'LICENSE', 'README.md'].to_a
|
27
|
+
s.files = FileList['bin/*', 'lib/**/*.rb', 'LICENSE', 'README.md'].to_a
|
30
28
|
s.executables |= Dir.entries('bin/')
|
31
|
-
s.has_rdoc = false
|
32
29
|
|
33
|
-
s.required_ruby_version = '>=
|
30
|
+
s.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
|
34
31
|
end
|
35
32
|
|
36
33
|
Gem::PackageTask.new gemspec do |p|
|
@@ -3,271 +3,6 @@
|
|
3
3
|
|
4
4
|
Process.setproctitle($PROGRAM_NAME)
|
5
5
|
|
6
|
-
require 'riemann/tools'
|
6
|
+
require 'riemann/tools/rabbitmq'
|
7
7
|
|
8
|
-
module Riemann
|
9
|
-
module Tools
|
10
|
-
class Rabbitmq
|
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
|
-
|
20
|
-
opt :monitor_user, 'RabbitMQ monitoring user', type: :string
|
21
|
-
opt :monitor_pass, 'RabbitMQ monitoring user password', type: :string
|
22
|
-
opt :monitor_port, 'RabbitMQ monitoring port', type: :int, default: 15_672
|
23
|
-
opt :monitor_host, 'RabbitMQ monitoring host', type: :string, default: 'localhost'
|
24
|
-
opt :monitor_use_tls, 'RabbitMQ use tls', type: :bool, default: false
|
25
|
-
|
26
|
-
opt :max_queue_size, 'max number of items in a queue that is acceptable', type: :int, default: 1_000_000
|
27
|
-
opt :ignore_max_size_queues, "A regular expression to match queues that shouldn't be size-checked", type: :string
|
28
|
-
|
29
|
-
opt :node, 'Specify a node to monitor', type: :strings
|
30
|
-
|
31
|
-
def base_url
|
32
|
-
protocol = 'http'
|
33
|
-
protocol = 'https' if options[:monitor_use_tls] && (options[:monitor_use_tls] == true)
|
34
|
-
"#{protocol}://#{options[:monitor_user]}:#{options[:monitor_pass]}@#{options[:monitor_host]}:#{options[:monitor_port]}/api"
|
35
|
-
end
|
36
|
-
|
37
|
-
def overview_url
|
38
|
-
"#{base_url}/overview"
|
39
|
-
end
|
40
|
-
|
41
|
-
def node_url(node)
|
42
|
-
"#{base_url}/nodes/#{node}"
|
43
|
-
end
|
44
|
-
|
45
|
-
def queues_url
|
46
|
-
"#{base_url}/queues"
|
47
|
-
end
|
48
|
-
|
49
|
-
def event_host
|
50
|
-
options[:event_host] || :monitor_host
|
51
|
-
end
|
52
|
-
|
53
|
-
def safe_get(uri, event_host)
|
54
|
-
# Handle connection timeouts
|
55
|
-
response = nil
|
56
|
-
begin
|
57
|
-
connection = Faraday.new(uri)
|
58
|
-
response = connection.get do |req|
|
59
|
-
req.options[:timeout] = options[:read_timeout]
|
60
|
-
req.options[:open_timeout] = options[:open_timeout]
|
61
|
-
end
|
62
|
-
report(
|
63
|
-
host: event_host,
|
64
|
-
service: 'rabbitmq monitoring',
|
65
|
-
state: 'ok',
|
66
|
-
description: 'Monitoring operational',
|
67
|
-
)
|
68
|
-
rescue StandardError => e
|
69
|
-
report(
|
70
|
-
host: event_host,
|
71
|
-
service: 'rabbitmq monitoring',
|
72
|
-
state: 'critical',
|
73
|
-
description: "HTTP connection error: #{e.class} - #{e.message}",
|
74
|
-
)
|
75
|
-
end
|
76
|
-
response
|
77
|
-
end
|
78
|
-
|
79
|
-
def check_queues
|
80
|
-
response = safe_get(queues_url, event_host)
|
81
|
-
max_size_check_filter = (Regexp.new(options[:ignore_max_size_queues]) if options[:ignore_max_size_queues])
|
82
|
-
|
83
|
-
return if response.nil?
|
84
|
-
|
85
|
-
if response.status != 200
|
86
|
-
report(
|
87
|
-
host: event_host,
|
88
|
-
service: 'rabbitmq.queue',
|
89
|
-
state: 'critical',
|
90
|
-
description: "HTTP connection error to /api/queues: #{response.status} - #{response.body}",
|
91
|
-
)
|
92
|
-
else
|
93
|
-
report(
|
94
|
-
host: event_host,
|
95
|
-
service: 'rabbitmq.queue',
|
96
|
-
state: 'ok',
|
97
|
-
description: 'HTTP connection ok',
|
98
|
-
)
|
99
|
-
|
100
|
-
json = JSON.parse(response.body)
|
101
|
-
|
102
|
-
json.each do |queue|
|
103
|
-
svc = "rabbitmq.queue.#{queue['vhost']}.#{queue['name']}"
|
104
|
-
errs = []
|
105
|
-
|
106
|
-
errs << 'Queue has jobs but no consumers' if !queue['messages_ready'].nil? && (queue['messages_ready']).positive? && (queue['consumers']).zero?
|
107
|
-
|
108
|
-
errs << "Queue has #{queue['messages_ready']} jobs" if (max_size_check_filter.nil? || queue['name'] !~ (max_size_check_filter)) && !queue['messages_ready'].nil? && (queue['messages_ready'] > options[:max_queue_size])
|
109
|
-
|
110
|
-
if errs.empty?
|
111
|
-
report(
|
112
|
-
host: event_host,
|
113
|
-
service: svc,
|
114
|
-
state: 'ok',
|
115
|
-
description: 'Queue is looking good',
|
116
|
-
)
|
117
|
-
else
|
118
|
-
report(
|
119
|
-
host: event_host,
|
120
|
-
service: svc,
|
121
|
-
state: 'critical',
|
122
|
-
description: errs.join('; '),
|
123
|
-
)
|
124
|
-
end
|
125
|
-
|
126
|
-
stats = (queue['message_stats'] || {}).merge(
|
127
|
-
'messages' => queue['messages'],
|
128
|
-
'messages_details' => queue['messages_details'],
|
129
|
-
'messages_ready' => queue['messages_ready'],
|
130
|
-
'messages_ready_details' => queue['messages_ready_details'],
|
131
|
-
'messages_unacknowledged' => queue['messages_unacknowledged'],
|
132
|
-
'messages_unacknowledged_details' => queue['messages_unacknowledged_details'],
|
133
|
-
'consumers' => queue['consumers'],
|
134
|
-
'memory' => queue['memory'],
|
135
|
-
)
|
136
|
-
|
137
|
-
stats.each_pair do |k, v|
|
138
|
-
service = "#{svc}.#{k}"
|
139
|
-
metric = if k =~ (/details$/) && !v.nil?
|
140
|
-
v['rate']
|
141
|
-
else
|
142
|
-
v
|
143
|
-
end
|
144
|
-
|
145
|
-
# TODO: Set state via thresholds which can be configured
|
146
|
-
|
147
|
-
report(
|
148
|
-
host: event_host,
|
149
|
-
service: service,
|
150
|
-
metric: metric,
|
151
|
-
description: 'RabbitMQ monitor',
|
152
|
-
)
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
def check_overview
|
159
|
-
uri = URI(overview_url)
|
160
|
-
response = safe_get(uri, event_host)
|
161
|
-
|
162
|
-
return if response.nil?
|
163
|
-
|
164
|
-
json = JSON.parse(response.body)
|
165
|
-
|
166
|
-
if response.status != 200
|
167
|
-
report(
|
168
|
-
host: event_host,
|
169
|
-
service: 'rabbitmq',
|
170
|
-
state: 'critical',
|
171
|
-
description: "HTTP connection error: #{response.status} - #{response.body}",
|
172
|
-
)
|
173
|
-
else
|
174
|
-
report(
|
175
|
-
host: event_host,
|
176
|
-
service: 'rabbitmq monitoring',
|
177
|
-
state: 'ok',
|
178
|
-
description: 'HTTP connection ok',
|
179
|
-
)
|
180
|
-
|
181
|
-
%w[message_stats queue_totals object_totals].each do |stat|
|
182
|
-
# NOTE: / BUG ?
|
183
|
-
# Brand new servers can have blank message stats. Is this ok?
|
184
|
-
# I can't decide.
|
185
|
-
next if json[stat].empty?
|
186
|
-
|
187
|
-
json[stat].each_pair do |k, v|
|
188
|
-
service = "rabbitmq.#{stat}.#{k}"
|
189
|
-
metric = if k =~ /details$/
|
190
|
-
v['rate']
|
191
|
-
else
|
192
|
-
v
|
193
|
-
end
|
194
|
-
|
195
|
-
# TODO: Set state via thresholds which can be configured
|
196
|
-
|
197
|
-
report(
|
198
|
-
host: event_host,
|
199
|
-
service: service,
|
200
|
-
metric: metric,
|
201
|
-
description: 'RabbitMQ monitor',
|
202
|
-
)
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
def check_node
|
209
|
-
opts[:node].each do |n|
|
210
|
-
uri = URI(node_url(n))
|
211
|
-
response = safe_get(uri, event_host)
|
212
|
-
|
213
|
-
break if response.nil?
|
214
|
-
|
215
|
-
if response.status != 200
|
216
|
-
if response.status == 404
|
217
|
-
report(
|
218
|
-
host: event_host,
|
219
|
-
service: "rabbitmq.node.#{n}",
|
220
|
-
state: 'critical',
|
221
|
-
description: 'Node was not found in the cluster',
|
222
|
-
)
|
223
|
-
else
|
224
|
-
report(
|
225
|
-
host: event_host,
|
226
|
-
service: "rabbitmq.node.#{n}",
|
227
|
-
state: 'critical',
|
228
|
-
description: "HTTP error: #{response.status} - #{response.body}",
|
229
|
-
)
|
230
|
-
end
|
231
|
-
break
|
232
|
-
end
|
233
|
-
|
234
|
-
json = JSON.parse(response.body)
|
235
|
-
|
236
|
-
if json['mem_alarm']
|
237
|
-
report(
|
238
|
-
host: event_host,
|
239
|
-
service: "rabbitmq.node.#{n}",
|
240
|
-
state: 'critical',
|
241
|
-
description: 'Memory alarm has triggered; job submission throttled',
|
242
|
-
)
|
243
|
-
break
|
244
|
-
end
|
245
|
-
|
246
|
-
if json['disk_free_alarm']
|
247
|
-
report(
|
248
|
-
host: event_host,
|
249
|
-
service: "rabbitmq.node.#{n}",
|
250
|
-
state: 'critical',
|
251
|
-
description: 'Disk free alarm has triggered; job submission throttled',
|
252
|
-
)
|
253
|
-
break
|
254
|
-
end
|
255
|
-
|
256
|
-
report(
|
257
|
-
host: event_host,
|
258
|
-
service: "rabbitmq.node.#{n}",
|
259
|
-
state: 'ok',
|
260
|
-
description: 'Node looks OK to me',
|
261
|
-
)
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
def tick
|
266
|
-
check_overview
|
267
|
-
check_node if opts[:node]
|
268
|
-
check_queues
|
269
|
-
end
|
270
|
-
end
|
271
|
-
end
|
272
|
-
end
|
273
8
|
Riemann::Tools::Rabbitmq.run
|