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

Commit 20acfda

Browse files
committed
Merge pull request ganglia#70 from monkeymantra/master
Change to fix values bug reported by Gerhard
2 parents 6d693d6 + ae63781 commit 20acfda

1 file changed

Lines changed: 26 additions & 18 deletions

File tree

rabbit/python_modules/rabbitmq.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ def metric_cleanup():
6565

6666
def dig_it_up(obj,path):
6767
try:
68-
if type(path) in (str,unicode):
69-
path = path.split('.')
68+
path = path.split('.')
7069
return reduce(lambda x,y:x[y],path,obj)
7170
except:
71+
print "Exception"
7272
return False
7373

7474
def refreshGroup(group):
@@ -123,42 +123,47 @@ def list_nodes():
123123
return results.keys()
124124

125125
def getQueueStat(name):
126-
#Split a name like "rmq_backing_queue_ack_egress_rate-access"
127-
stat_name, queue_name = name.split(".")
128-
126+
#Split a name like "rmq_backing_queue_ack_egress_rate.access"
127+
128+
#handle queue names with . in them
129+
split_name = name.split(".")
130+
stat_name = split_name[0]
131+
queue_name = ".".join(split_name[1:])
132+
129133
result = refreshGroup('queues')
130134

131135
value = dig_it_up(result, keyToPath[stat_name] % queue_name)
136+
print name, value
132137

133138
#Convert Booleans
134139
if value is True:
135140
value = 1
136141
elif value is False:
137142
value = 0
138143

139-
return value
144+
return float(value)
140145

141146
def getNodeStat(name):
142-
#Split a name like "rmq_backing_queue_ack_egress_rate-access"
143-
stat_name, node_name = name.split(".")
144-
147+
#Split a name like "rmq_backing_queue_ack_egress_rate.access"
148+
stat_name, node_name = name.split(".")
145149
result = refreshGroup('nodes')
146-
147150
value = dig_it_up(result, keyToPath[stat_name] % node_name)
148-
151+
print name,value
149152
#Convert Booleans
150153
if value is True:
151154
value = 1
152155
elif value is False:
153156
value = 0
154157

155-
return value
158+
return float(value)
156159

157160
def metric_init(params):
158161
''' Create the metric definition object '''
159162
global descriptors, stats, vhost, username, password, urlstring, url_template, compiled_results
160163
print 'received the following params:'
161164
#Set this globally so we can refresh stats
165+
if 'host' not in params:
166+
params['host'], params['vhost'],params['username'],params['password'] = "localhost", "/", "guest", "guest"
162167
vhost = params['vhost']
163168
username, password = params['username'], params['password']
164169
host = params['host']
@@ -198,15 +203,15 @@ def buildQueueDescriptors():
198203
'value_type': 'float',
199204
'units': 'N',
200205
'slope': 'both',
201-
'format': '%d',
206+
'format': '%f',
202207
'description': 'Queue_Metric',
203208
'groups' : 'rabbitmq,queue'})
204-
209+
print d1
205210
descriptors.append(d1)
206211

207212
def buildNodeDescriptors():
208213
for node in list_nodes():
209-
node = node.split('@')[0]
214+
#node = node.split('@')[0]
210215
for stat in NODE_METRICS:
211216
name = '%s.%s' % (stat, node)
212217
print name
@@ -215,7 +220,7 @@ def buildNodeDescriptors():
215220
'value_type': 'float',
216221
'units': 'N',
217222
'slope': 'both',
218-
'format': '%d',
223+
'format': '%f',
219224
'description': 'Node_Metric',
220225
'groups' : 'rabbitmq,node'})
221226
print d2
@@ -237,5 +242,8 @@ def metric_cleanup():
237242
parameters = {"vhost":"/", "username":"guest","password":"guest", "metric_group":"rabbitmq"}
238243
metric_init(parameters)
239244
result = refreshGroup('queues')
240-
print dig_it_up(result, 'clientlog.backing_queue_status.avg_egress_rate')
241-
245+
node_result = refreshGroup('nodes')
246+
print '***'*10
247+
getQueueStat('rmq_backing_queue_ack_egress_rate.gelf_client_three')
248+
getNodeStat('rmq_disk_free.rmqtwo@inrmq02d1')
249+
getNodeStat('rmq_mem_used.rmqtwo@inrmq02d1')

0 commit comments

Comments
 (0)