From 8fa3d4838dc83304a49b2ab90242c0600a4b6177 Mon Sep 17 00:00:00 2001 From: Greg Rice Date: Fri, 2 Nov 2012 21:30:37 +0000 Subject: [PATCH 1/2] Modified rabbitmq. Somehow I forgot to keep refreshing the friggin' thing. --- rabbit/python_modules/rabbitmq.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/rabbit/python_modules/rabbitmq.py b/rabbit/python_modules/rabbitmq.py index 2bdccbb5..3280edc7 100644 --- a/rabbit/python_modules/rabbitmq.py +++ b/rabbit/python_modules/rabbitmq.py @@ -6,9 +6,10 @@ import time from string import Template import itertools +import threading global url, descriptors, last_update, vhost, username, password, url_template, result, result_dict, keyToPath -INTERVAL = 20 +INTERVAL = 10 descriptors = list() username, password = "guest", "guest" stats = {} @@ -63,6 +64,8 @@ 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'] + + def metric_cleanup(): pass @@ -123,6 +126,7 @@ def list_nodes(): return nodes def getQueueStat(name): + refreshStats(stats = STATS, vhosts = vhosts) #Split a name like "rmq_backing_queue_ack_egress_rate.access" #handle queue names with . in them @@ -147,6 +151,7 @@ def getQueueStat(name): return float(value) def getNodeStat(name): + refreshStats(stats = STATS, vhosts = vhosts) #Split a name like "rmq_backing_queue_ack_egress_rate.access" stat_name = name.split(".")[0] node_name, vhost = name.split(".")[1].split("#") @@ -174,7 +179,7 @@ def product(*args, **kwds): def metric_init(params): ''' Create the metric definition object ''' - global descriptors, stats, vhost, username, password, urlstring, url_template, compiled_results, STATS + global descriptors, stats, vhost, username, password, urlstring, url_template, compiled_results, STATS, vhosts print 'received the following params:' #Set this globally so we can refresh stats if 'host' not in params: @@ -191,6 +196,13 @@ def metric_init(params): refreshStats(stats = STATS, vhosts = vhosts) + def metric_handler(name): + if 15 < time.time() - metric_handler.timestamp: + metric_handler.timestamp = time.time() + return refreshStats(stats = STATS, vhosts = vhosts) + + + def create_desc(prop): d = { 'name' : 'XXX', @@ -259,6 +271,6 @@ def metric_cleanup(): metric_init(parameters) result = refreshStats(stats = ('queues', 'nodes'), vhosts = ('/')) print '***'*10 - getQueueStat('rmq_backing_queue_ack_egress_rate.gelf_client_three#/') + getQueueStat('rmq_backing_queue_ack_egress_rate.nfl_client#/') getNodeStat('rmq_disk_free.rmqtwo@inrmq02d1#/') getNodeStat('rmq_mem_used.rmqtwo@inrmq02d1#/') From 5d31557bc0a7b782fdf1b9c5299fb12912504c6a Mon Sep 17 00:00:00 2001 From: Greg Rice Date: Fri, 2 Nov 2012 21:32:53 +0000 Subject: [PATCH 2/2] Removed extra junk --- rabbit/python_modules/rabbitmq.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/rabbit/python_modules/rabbitmq.py b/rabbit/python_modules/rabbitmq.py index 3280edc7..e8976af6 100644 --- a/rabbit/python_modules/rabbitmq.py +++ b/rabbit/python_modules/rabbitmq.py @@ -196,13 +196,6 @@ def metric_init(params): refreshStats(stats = STATS, vhosts = vhosts) - def metric_handler(name): - if 15 < time.time() - metric_handler.timestamp: - metric_handler.timestamp = time.time() - return refreshStats(stats = STATS, vhosts = vhosts) - - - def create_desc(prop): d = { 'name' : 'XXX',