Skip to content

Commit 8fa3d48

Browse files
author
Greg Rice
committed
Modified rabbitmq. Somehow I forgot to keep refreshing the friggin' thing.
1 parent f6689ee commit 8fa3d48

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

rabbit/python_modules/rabbitmq.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
import time
77
from string import Template
88
import itertools
9+
import threading
910

1011
global url, descriptors, last_update, vhost, username, password, url_template, result, result_dict, keyToPath
11-
INTERVAL = 20
12+
INTERVAL = 10
1213
descriptors = list()
1314
username, password = "guest", "guest"
1415
stats = {}
@@ -63,6 +64,8 @@
6364
NODE_METRICS = ['rmq_disk_free', 'rmq_mem_used', 'rmq_disk_free_alarm', 'rmq_running', 'rmq_proc_used', 'rmq_mem_proc_used', 'rmq_fd_used', 'rmq_mem_alarm', 'rmq_mem_code', 'rmq_mem_binary', 'rmq_sockets_used']
6465

6566

67+
68+
6669
def metric_cleanup():
6770
pass
6871

@@ -123,6 +126,7 @@ def list_nodes():
123126
return nodes
124127

125128
def getQueueStat(name):
129+
refreshStats(stats = STATS, vhosts = vhosts)
126130
#Split a name like "rmq_backing_queue_ack_egress_rate.access"
127131

128132
#handle queue names with . in them
@@ -147,6 +151,7 @@ def getQueueStat(name):
147151
return float(value)
148152

149153
def getNodeStat(name):
154+
refreshStats(stats = STATS, vhosts = vhosts)
150155
#Split a name like "rmq_backing_queue_ack_egress_rate.access"
151156
stat_name = name.split(".")[0]
152157
node_name, vhost = name.split(".")[1].split("#")
@@ -174,7 +179,7 @@ def product(*args, **kwds):
174179

175180
def metric_init(params):
176181
''' Create the metric definition object '''
177-
global descriptors, stats, vhost, username, password, urlstring, url_template, compiled_results, STATS
182+
global descriptors, stats, vhost, username, password, urlstring, url_template, compiled_results, STATS, vhosts
178183
print 'received the following params:'
179184
#Set this globally so we can refresh stats
180185
if 'host' not in params:
@@ -191,6 +196,13 @@ def metric_init(params):
191196

192197
refreshStats(stats = STATS, vhosts = vhosts)
193198

199+
def metric_handler(name):
200+
if 15 < time.time() - metric_handler.timestamp:
201+
metric_handler.timestamp = time.time()
202+
return refreshStats(stats = STATS, vhosts = vhosts)
203+
204+
205+
194206
def create_desc(prop):
195207
d = {
196208
'name' : 'XXX',
@@ -259,6 +271,6 @@ def metric_cleanup():
259271
metric_init(parameters)
260272
result = refreshStats(stats = ('queues', 'nodes'), vhosts = ('/'))
261273
print '***'*10
262-
getQueueStat('rmq_backing_queue_ack_egress_rate.gelf_client_three#/')
274+
getQueueStat('rmq_backing_queue_ack_egress_rate.nfl_client#/')
263275
getNodeStat('rmq_disk_free.rmqtwo@inrmq02d1#/')
264276
getNodeStat('rmq_mem_used.rmqtwo@inrmq02d1#/')

0 commit comments

Comments
 (0)