Skip to content
This repository was archived by the owner on Jun 22, 2022. It is now read-only.

Commit 9c265e3

Browse files
author
Greg Rice
committed
First version complete
1 parent 2793fb8 commit 9c265e3

2 files changed

Lines changed: 42 additions & 22 deletions

File tree

rabbitmq.py

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ def metric_init(params):
175175
'units': 'N',
176176
'slope': 'both',
177177
'format': '%d',
178-
'description': 'Queue_Metric'}
178+
'description': 'Queue_Metric',
179+
'groups':'rabbitmq'}
179180

180181
descriptors.append(d1)
181182

@@ -186,7 +187,8 @@ def metric_init(params):
186187
'units': 'N',
187188
'slope': 'both',
188189
'format': '%d',
189-
'description': 'Get Messages Ready in Queue'}
190+
'description': 'Get Messages Ready in Queue',
191+
'groups':'rabbitmq'}
190192

191193
descriptors.append(d1)
192194

@@ -196,26 +198,11 @@ def metric_init(params):
196198
return descriptors
197199

198200

199-
200-
def get_vhost_stats(vhost, qtypes):
201-
data = {}
202-
VALID_TYPES = ['messages_ready', 'messages_unacknowledged']
203-
qtypes = [t for t in qtypes if t in VALID_TYPES]
204-
cmd = [RABBITMQCTL,
205-
'list_queues',
206-
'-p', vhost, 'name']
207-
cmd.extend(qtypes)
208-
stdout, stderr = Popen(cmd, stdout=PIPE, stderr=PIPE).communicate()
209-
for l in stdout.split("\n")[1:-2]:
210-
l = l.split()
211-
name = l.pop(0)
212-
data[name] = {}
213-
for i, t in enumerate(qtypes):
214-
data[name][t] = int(l[i])
215-
print data
216-
return data
217-
218201
if __name__ == "__main__":
219202
parameters = {"vhost":"/", "username":"guest","password":"guest"}
220-
metric_init(parameters)
203+
descriptors = metric_init(parameters)
204+
for d1 in descriptors:
205+
print d1['name']
206+
d1['call_back'](d1['name'])
207+
221208

rabbitmq.pyconf

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
3+
modules {
4+
module {
5+
name = "rabbitmq"
6+
language = "python"
7+
8+
param vhost {
9+
value = "/"
10+
}
11+
param username {
12+
value = "guest"
13+
}
14+
param password {
15+
value = "guest"
16+
}
17+
18+
param metric_group {
19+
value = "rabbitmq"
20+
}
21+
22+
}
23+
}
24+
25+
collection_group {
26+
collect_every = 30
27+
time_threshold = 60
28+
29+
metric {
30+
name_match = "rabbitmq_(.+)"
31+
}
32+
}
33+

0 commit comments

Comments
 (0)