riemann-tools 1.0.0 → 1.2.0

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