Author: justi9
Date: 2007-11-01 15:41:40 -0400 (Thu, 01 Nov 2007)
New Revision: 1207
Modified:
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/queue.strings
Log:
Adds radio buttons to the queue list for switching between bytes and
messages stats.
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-11-01 18:59:46 UTC (rev 1206)
+++ mgmt/cumin/python/cumin/queue.py 2007-11-01 19:41:40 UTC (rev 1207)
@@ -32,9 +32,32 @@
return writer.to_string()
class QueueSet(ItemSet):
+ def __init__(self, app, name):
+ super(QueueSet, self).__init__(app, name)
+
+ self.unit = Parameter(app, "unit")
+ self.unit.set_default("m")
+ self.add_parameter(self.unit)
+
def render_title(self, session, vhost):
return "Queues (%s)" % len(vhost.queue_items())
+ def render_messages_link(self, session, vhost):
+ branch = session.branch()
+ self.unit.set(branch, "m")
+
+ class_ = self.unit.get(session) == "m" and "selected"
+
+ return link(branch.marshal(), "Messages", class_)
+
+ def render_bytes_link(self, session, vhost):
+ branch = session.branch()
+ self.unit.set(branch, "b")
+
+ class_ = self.unit.get(session) == "b" and "selected"
+
+ return link(branch.marshal(), "Bytes", class_)
+
def get_items(self, session, vhost):
return sorted_by(vhost.queue_items())
@@ -53,21 +76,27 @@
return len(queue.binding_items())
def render_item_enqueues(self, session, queue):
- value = queue.get_measurement("msgTotalEnqueues").get_rate()
- return rate(value, "msg", "sec")
+ unit = self.unit.get(session)
+ key = unit == "b" and "byteTotalEnqueues" or
"msgTotalEnqueues"
+ value = queue.get_measurement(key).get_rate()
+ return rate(value, unit == "b" and "byte" or "msg",
"sec")
def render_item_dequeues(self, session, queue):
- value = queue.get_measurement("msgTotalDequeues").get_rate()
- return rate(value, "msg", "sec")
+ unit = self.unit.get(session)
+ key = unit == "b" and "byteTotalDequeues" or
"msgTotalDequeues"
+ value = queue.get_measurement(key).get_rate()
+ return rate(value, unit == "b" and "byte" or "msg",
"sec")
def render_item_depth(self, session, queue):
- return queue.get_measurement("msgDepth").get_value()
+ key = self.unit.get(session) == "b" and "byteDepth" or
"msgDepth"
+ return queue.get_measurement(key).get_value()
def render_item_ratio(self, session, queue):
- values = queue.get_measurement("msgDepth").get_values(2)
+ key = self.unit.get(session) == "b" and "byteDepth" or
"msgDepth"
+ values = queue.get_measurement(key).get_values(2)
if len(values) > 1 and values[0] != None:
- return "%0.00f" % (values[1] - values[0] / 3)
+ return "%0.00f" % (values[0] - values[1] / 3)
def render_item_status(self, session, queue):
return status(len(queue.errors), len(queue.warnings))
Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings 2007-11-01 18:59:46 UTC (rev 1206)
+++ mgmt/cumin/python/cumin/queue.strings 2007-11-01 19:41:40 UTC (rev 1207)
@@ -7,6 +7,11 @@
[QueueSet.html]
<form action="{href}" method="get">
+ <ul class="radiotabs">
+ <li>{messages_link}</li>
+ <li>{bytes_link}</li>
+ </ul>
+
<div class="sactions">
<h2>Act on Selected Queues:</h2>
<button>Purge Messages</button>