Skip to content

Loading…

Change to fix values bug reported by Gerhard #70

Merged
merged 1 commit into from

3 participants

@monkeymantra

All values were being reported as 108 due to a formatting error. Also, queue names with "." in them are now supported.

Changes have been tested and seem to work fine.

@jbuchbinder jbuchbinder merged commit 20acfda into ganglia:master
@gerhard

Cheers Greg, that definitely works! Would you mind reviewing my host additions and merging into yours if you feel it's helpful?

Also, wasn't sure if those were hardcoded.

While we're at it, in our setup, we use different vhosts with different credentials:

  :rabbitmq => {
    :users => {
      :graphite => {
        :vhosts => ["graphite"]
      },
      :admin => {
        :vhosts => ["/", "graphite"],
        :tags => "administrator"
      },
      :guest => {
        :action => :delete
      }
    }

How difficult would it be to support multiple vhosts?

Gerhard, I just branched a version that supports multiple vhosts. It's not the cleanest code, but here's the branch I'm working on:

Multiple Vhosts

You ought to be able to put a list of comma-separated VHosts in the pyconf. I haven't tried it out yet. Could you see if it works?

Thanks,
Greg Rice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 2, 2012
  1. Changes to fix bug reported by Gerhard

    Greg Rice committed
Showing with 26 additions and 18 deletions.
  1. +26 −18 rabbit/python_modules/rabbitmq.py
View
44 rabbit/python_modules/rabbitmq.py
@@ -65,10 +65,10 @@ def metric_cleanup():
def dig_it_up(obj,path):
try:
- if type(path) in (str,unicode):
- path = path.split('.')
+ path = path.split('.')
return reduce(lambda x,y:x[y],path,obj)
except:
+ print "Exception"
return False
def refreshGroup(group):
@@ -123,12 +123,17 @@ def list_nodes():
return results.keys()
def getQueueStat(name):
- #Split a name like "rmq_backing_queue_ack_egress_rate-access"
- stat_name, queue_name = name.split(".")
-
+ #Split a name like "rmq_backing_queue_ack_egress_rate.access"
+
+ #handle queue names with . in them
+ split_name = name.split(".")
+ stat_name = split_name[0]
+ queue_name = ".".join(split_name[1:])
+
result = refreshGroup('queues')
value = dig_it_up(result, keyToPath[stat_name] % queue_name)
+ print name, value
#Convert Booleans
if value is True:
@@ -136,29 +141,29 @@ def getQueueStat(name):
elif value is False:
value = 0
- return value
+ return float(value)
def getNodeStat(name):
- #Split a name like "rmq_backing_queue_ack_egress_rate-access"
- stat_name, node_name = name.split(".")
-
+ #Split a name like "rmq_backing_queue_ack_egress_rate.access"
+ stat_name, node_name = name.split(".")
result = refreshGroup('nodes')
-
value = dig_it_up(result, keyToPath[stat_name] % node_name)
-
+ print name,value
#Convert Booleans
if value is True:
value = 1
elif value is False:
value = 0
- return value
+ return float(value)
def metric_init(params):
''' Create the metric definition object '''
global descriptors, stats, vhost, username, password, urlstring, url_template, compiled_results
print 'received the following params:'
#Set this globally so we can refresh stats
+ if 'host' not in params:
+ params['host'], params['vhost'],params['username'],params['password'] = "localhost", "/", "guest", "guest"
vhost = params['vhost']
username, password = params['username'], params['password']
host = params['host']
@@ -198,15 +203,15 @@ def buildQueueDescriptors():
'value_type': 'float',
'units': 'N',
'slope': 'both',
- 'format': '%d',
+ 'format': '%f',
'description': 'Queue_Metric',
'groups' : 'rabbitmq,queue'})
-
+ print d1
descriptors.append(d1)
def buildNodeDescriptors():
for node in list_nodes():
- node = node.split('@')[0]
+ #node = node.split('@')[0]
for stat in NODE_METRICS:
name = '%s.%s' % (stat, node)
print name
@@ -215,7 +220,7 @@ def buildNodeDescriptors():
'value_type': 'float',
'units': 'N',
'slope': 'both',
- 'format': '%d',
+ 'format': '%f',
'description': 'Node_Metric',
'groups' : 'rabbitmq,node'})
print d2
@@ -237,5 +242,8 @@ def metric_cleanup():
parameters = {"vhost":"/", "username":"guest","password":"guest", "metric_group":"rabbitmq"}
metric_init(parameters)
result = refreshGroup('queues')
- print dig_it_up(result, 'clientlog.backing_queue_status.avg_egress_rate')
-
+ node_result = refreshGroup('nodes')
+ print '***'*10
+ getQueueStat('rmq_backing_queue_ack_egress_rate.gelf_client_three')
+ getNodeStat('rmq_disk_free.rmqtwo@inrmq02d1')
+ getNodeStat('rmq_mem_used.rmqtwo@inrmq02d1')
Something went wrong with that request. Please try again.