@@ -192,12 +192,6 @@ def getQueueStat(name):
192192 if zero_rates_when_idle and stat_name in RATE_METRICS and 'idle_since' in result [queue_name ].keys ():
193193 value = 0
194194
195- # Convert Booleans
196- if value is True :
197- value = 1
198- elif value is False :
199- value = 0
200-
201195 return float (value )
202196
203197
@@ -211,14 +205,24 @@ def getNodeStat(name):
211205 value = dig_it_up (result , keyToPath [stat_name ] % node_name )
212206
213207 log .debug ('name: %r value: %r' % (name , value ))
214- # Convert Booleans
215- if value is True :
216- value = 1
217- elif value is False :
218- value = 0
219208
220209 return float (value )
221210
211+ def getNodeSumStat (name ):
212+ refreshStats (stats = STATS , vhosts = vhosts )
213+ # Split a name like "rmq_backing_queue_ack_egress_rate.access"
214+ stat_name , dummyName , vhost = name .split (METRIC_TOKEN_SEPARATOR )
215+ vhost = vhost .replace ('-' , '/' ) # decoding vhost from metric name
216+
217+ result = compiled_results [('nodes' , '/' )]
218+ total = 0.0
219+ for node_name in list_nodes ():
220+ value = dig_it_up (result , keyToPath [stat_name ] % node_name )
221+ total += value
222+
223+ log .debug ('name: %r value: %r' % (name , total ))
224+
225+ return total
222226
223227def getOverviewStat (name ):
224228 refreshStats (stats = STATS , vhosts = vhosts )
@@ -235,12 +239,6 @@ def getOverviewStat(name):
235239
236240 value = dig_it_up (result , keyToPath [stat_name ])
237241
238- # Convert Booleans
239- if value is True :
240- value = 1
241- elif value is False :
242- value = 0
243-
244242 return float (value )
245243
246244def getExchangeStat (name ):
@@ -261,12 +259,6 @@ def getExchangeStat(name):
261259 if zero_rates_when_idle and stat_name in RATE_METRICS and 'idle_since' in result [exchange_name ].keys ():
262260 value = 0
263261
264- # Convert Booleans
265- if value is True :
266- value = 1
267- elif value is False :
268- value = 0
269-
270262 return float (value )
271263
272264
@@ -364,6 +356,18 @@ def buildQueueDescriptors():
364356
365357 def buildNodeDescriptors ():
366358 for metric in NODE_METRICS :
359+ name = "{1}{0}total{0}-" .format (METRIC_TOKEN_SEPARATOR , metric )
360+ log .debug (name )
361+ d2 = create_desc ({'name' : name .encode ('ascii' , 'ignore' ),
362+ 'call_back' : getNodeSumStat ,
363+ 'value_type' : 'float' ,
364+ 'units' : 'N' ,
365+ 'slope' : 'both' ,
366+ 'format' : '%f' ,
367+ 'description' : 'Node_Metric' ,
368+ 'groups' : 'rabbitmq,node' })
369+ log .debug (d2 )
370+ descriptors .append (d2 )
367371 for node in list_nodes ():
368372 name = "{1}{0}{2}{0}-" .format (METRIC_TOKEN_SEPARATOR , metric , node )
369373 log .debug (name )
0 commit comments