riemann-smith 0.2.0 → 0.2.1
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/bin/queue-lengths +65 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddabc131163b71844a1d0252bd9f5eecf18e06c0
|
4
|
+
data.tar.gz: 6f9b585f1491efdfe0d4f766893451506842ae12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac33d63cb456c2a4a22e9ce616e04e4551f58220d9c7c6f4b79e386e06fa64c1fa443181abc860b81b7b5e99411192ecd061b37a859fd2df2a4adb75545aaa37
|
7
|
+
data.tar.gz: 49a96af674fc7fa8133abd16477d7c8c37bf11e4edaf18df7447382178472ef721d0448550bd6eb6849a26a09804de8de8404c6d74f69e9721eacdc5cef39174
|
data/bin/queue-lengths
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "pp"
|
4
|
+
require "pathname"
|
5
|
+
|
6
|
+
require "rabbitmq/http/client"
|
7
|
+
require 'riemann/tools'
|
8
|
+
|
9
|
+
class QueueLength
|
10
|
+
include Riemann::Tools
|
11
|
+
|
12
|
+
opt :limits, "JSON file containing queue:limit key value pairs", :type => :string, :required => true
|
13
|
+
opt :queue_prefix, "Queue prefix", :type => :string, :default => "smith"
|
14
|
+
opt :exclusion_regex, "Exclude queue names that conform to the regex", :type => :string
|
15
|
+
opt :exclusions, "Exclude the given queue names.", :type => :string
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@rabbitmq = RabbitMQ::HTTP::Client.new("http://guest:guest@localhost:15672")
|
19
|
+
end
|
20
|
+
|
21
|
+
def tick
|
22
|
+
@rabbitmq.list_queues.each do |queue|
|
23
|
+
over_limit(queue)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def over_limit(queue)
|
30
|
+
alert(queue, state(queue), queue.messages, "Number of messages")
|
31
|
+
end
|
32
|
+
|
33
|
+
def state(queue)
|
34
|
+
if queue.messages > limit(queue)['critical']
|
35
|
+
state = :critial
|
36
|
+
elsif queue.messages > limit(queue)['warning']
|
37
|
+
state = :warning
|
38
|
+
else
|
39
|
+
state = :ok
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def alert(queue, state, metric, description)
|
44
|
+
report(
|
45
|
+
:service => normliased_queue_name(queue),
|
46
|
+
:state => state.to_s,
|
47
|
+
:metric => metric.to_f,
|
48
|
+
:description => description
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
def limit(queue)
|
53
|
+
(limits[normliased_queue_name(queue)] || limits['default'])
|
54
|
+
end
|
55
|
+
|
56
|
+
def normliased_queue_name(queue)
|
57
|
+
queue.name.sub(Regexp.new("#{opts[:queue_prefix]}."), '')
|
58
|
+
end
|
59
|
+
|
60
|
+
def limits
|
61
|
+
@limits ||= MultiJson.load(Pathname.new(opts[:limits]))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
QueueLength.run
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riemann-smith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Heycock
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git-version-bump
|
@@ -124,10 +124,13 @@ dependencies:
|
|
124
124
|
version: '0'
|
125
125
|
description:
|
126
126
|
email: rgh@digivizer.com
|
127
|
-
executables:
|
127
|
+
executables:
|
128
|
+
- queue-lengths
|
129
|
+
- riemann-smith
|
128
130
|
extensions: []
|
129
131
|
extra_rdoc_files: []
|
130
132
|
files:
|
133
|
+
- bin/queue-lengths
|
131
134
|
- bin/riemann-smith
|
132
135
|
- doc/LICENSE
|
133
136
|
- doc/README
|