Skip to content

Commit bb8fbfd

Browse files
committed
configuration parameter for which types of metrics to emit
1 parent ee02d52 commit bb8fbfd

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

rabbit/conf.d/rabbitmq.pyconf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ modules {
1212
value = "localhost"
1313
}
1414

15+
# CSV of which type of stats to emit
16+
# * nodes: per broker details about mem, sockets, etc
17+
# * queues: per queue stats, may result in many metrics on brokers with many queues
18+
param stats {
19+
value = "nodes,queues"
20+
}
21+
1522
param vhost {
1623
value = "/,vhost1,vhost2"
1724
}

rabbit/python_modules/rabbitmq.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ def metric_init(params):
223223
username, password = params['username'], params['password']
224224
host = params['host']
225225
port = params['port']
226+
STATS = params['stats']
226227

227228
zero_rates_when_idle = str2bool(params['zero_rates_when_idle'])
228229

@@ -296,8 +297,10 @@ def buildNodeDescriptors():
296297
log.debug(d2)
297298
descriptors.append(d2)
298299

299-
buildQueueDescriptors()
300-
buildNodeDescriptors()
300+
if 'queues' in STATS:
301+
buildQueueDescriptors()
302+
if 'nodes' in STATS:
303+
buildNodeDescriptors()
301304
# buildTestNodeStat()
302305

303306
return descriptors
@@ -338,6 +341,9 @@ def parse_args(argv):
338341
parser.add_option('--admin-port',
339342
action='store', dest='admin_port', default=15672,
340343
help='')
344+
parser.add_option('--stats',
345+
action='store', dest='stats', default='nodes',
346+
help='csv of which stats to emit, choies: nodes, queues')
341347
parser.add_option('--log',
342348
action='store', dest='log', default='stderr', choices=['stderr', 'syslog', 'both'],
343349
help='log to stderr and/or syslog')
@@ -359,9 +365,10 @@ def main(argv):
359365
### in config files we use '/' in vhosts names but we should convert '/' to '-' when calculating a metric
360366
parameters = {"vhost":"/", "username":"guest","password":"guest", "metric_group":"rabbitmq",
361367
"zero_rates_when_idle": "yes",
362-
"host": opts.admin_host, "port": opts.admin_port}
368+
"host": opts.admin_host, "port": opts.admin_port,
369+
"stats": opts.stats.split(',')}
363370
descriptors = metric_init(parameters)
364-
result = refreshStats(stats = ('queues', 'nodes'), vhosts = ('/'))
371+
result = refreshStats(stats = parameters['stats'], vhosts = ('/'))
365372
print '***'*20
366373
try:
367374
while True:

0 commit comments

Comments
 (0)