@@ -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