Author: justi9
Date: 2007-11-02 15:11:41 -0400 (Fri, 02 Nov 2007)
New Revision: 1219
Modified:
mgmt/cumin/python/cumin/exchange.py
mgmt/cumin/python/cumin/exchange.strings
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/queue.strings
mgmt/cumin/python/cumin/widgets.py
mgmt/cumin/python/cumin/widgets.strings
Log:
Adds a reusable message/byte switch widget. Uses it to enhance the
exchange list view.
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2007-11-02 17:32:47 UTC (rev 1218)
+++ mgmt/cumin/python/cumin/exchange.py 2007-11-02 19:11:41 UTC (rev 1219)
@@ -32,9 +32,18 @@
return exchange is self.param.get(session) and
"checked=\"checked\""
class ExchangeSet(ItemSet):
+ def __init__(self, app, name):
+ super(ExchangeSet, self).__init__(app, name)
+
+ self.unit = UnitSwitch(app, "unit_switch")
+ self.add_child(self.unit)
+
def render_title(self, session, vhost):
return "Exchanges (%s)" % len(vhost.exchange_items())
+ def render_unit(self, session, vhost):
+ return self.unit.get(session) == "b" and "Bytes" or
"Msgs."
+
def get_items(self, session, vhost):
return sorted_by(vhost.exchange_items())
@@ -49,18 +58,21 @@
def render_item_bindings(self, session, exchange):
return len(exchange.binding_items())
- def render_item_messages_received(self, session, exchange):
- return exchange.get_measurement("msgReceives").get_value()
+ def render_item_received(self, session, exchange):
+ unit = self.unit.get(session)
+ key = unit == "b" and "byteReceives" or
"msgReceives"
+ return exchange.get_measurement(key).get_value()
- def render_item_bytes_received(self, session, exchange):
- return exchange.get_measurement("byteReceives").get_value()
+ def render_item_dropped(self, session, exchange):
+ unit = self.unit.get(session)
+ key = unit == "b" and "byteDrops" or "msgDrops"
+ return exchange.get_measurement(key).get_value()
- def render_item_messages_routed(self, session, exchange):
- return exchange.get_measurement("msgRoutes").get_value()
+ def render_item_routed(self, session, exchange):
+ unit = self.unit.get(session)
+ key = unit == "b" and "byteRoutes" or "msgRoutes"
+ return exchange.get_measurement(key).get_value()
- def render_item_bytes_routed(self, session, exchange):
- return exchange.get_measurement("byteRoutes").get_value()
-
def render_item_status(self, session, exchange):
return status(len(exchange.errors), len(exchange.warnings))
Modified: mgmt/cumin/python/cumin/exchange.strings
===================================================================
--- mgmt/cumin/python/cumin/exchange.strings 2007-11-02 17:32:47 UTC (rev 1218)
+++ mgmt/cumin/python/cumin/exchange.strings 2007-11-02 19:11:41 UTC (rev 1219)
@@ -12,15 +12,16 @@
}
[ExchangeSet.html]
-<table class="ExchangeSet mobjects">
+{unit_switch}
+
+<table class="mobjects">
<tr>
<th>Name</th>
<th class="ralign">Producers</th>
<th class="ralign">Queue Bindings</th>
- <th class="ralign">Msgs. Received</th>
- <th class="ralign">Bytes Received</th>
- <th class="ralign">Msgs. Routed</th>
- <th class="ralign">Bytes Routed</th>
+ <th class="ralign">{unit} Received</th>
+ <th class="ralign">{unit} Dropped</th>
+ <th class="ralign">{unit} Routed</th>
<th>Status</th>
</tr>
@@ -32,10 +33,9 @@
<td>{item_link}</a></td>
<td class="ralign">{item_producers}</td>
<td class="ralign">{item_bindings}</td>
- <td class="ralign">{item_messages_received}</td>
- <td class="ralign">{item_bytes_received}</td>
- <td class="ralign">{item_messages_routed}</td>
- <td class="ralign">{item_bytes_routed}</td>
+ <td class="ralign">{item_received}</td>
+ <td class="ralign">{item_dropped}</td>
+ <td class="ralign">{item_routed}</td>
<td>{item_status}</td>
</tr>
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-11-02 17:32:47 UTC (rev 1218)
+++ mgmt/cumin/python/cumin/queue.py 2007-11-02 19:11:41 UTC (rev 1219)
@@ -33,29 +33,18 @@
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)
+ self.unit = UnitSwitch(app, "unit_switch")
+ self.add_child(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")
+ def render_unit(self, session, vhost):
+ return self.unit.get(session) == "b" and "Byte" or
"Msg."
- class_ = self.unit.get(session) == "m" and "selected"
+ def render_unit_plural(self, session, vhost):
+ return self.unit.get(session) == "b" and "Bytes" or
"Msgs."
- 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())
@@ -73,13 +62,13 @@
def render_item_bindings(self, session, queue):
return len(queue.binding_items())
- def render_item_enqueues(self, session, queue):
+ def render_item_enqueued(self, session, queue):
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):
+ def render_item_dequeued(self, session, queue):
unit = self.unit.get(session)
key = unit == "b" and "byteTotalDequeues" or
"msgTotalDequeues"
value = queue.get_measurement(key).get_rate()
@@ -150,13 +139,6 @@
value = queue.get_measurement("byteDepth").get_rate()
return rate(value, "byte", "sec")
-# def render_error_info(self, session, queue):
-# return "%i %s, %i %s" % \
-# (queue.error_count,
-# queue.error_count == 1 and "error" or "errors",
-# queue.warning_count,
-# queue.warning_count == 1 and "warning" or
"warnings")
-
class QueueView(Widget):
def __init__(self, app, name):
super(QueueView, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings 2007-11-02 17:32:47 UTC (rev 1218)
+++ mgmt/cumin/python/cumin/queue.strings 2007-11-02 19:11:41 UTC (rev 1219)
@@ -7,10 +7,7 @@
[QueueSet.html]
<form action="{href}" method="get">
- <ul class="radiotabs">
- <li>{messages_link}</li>
- <li>{bytes_link}</li>
- </ul>
+ {unit_switch}
<div class="sactions">
<h2>Act on Selected Queues:</h2>
@@ -23,10 +20,10 @@
<th>Name</th>
<th class="ralign">Consumers</th>
<th class="ralign">Exchange Bindings</th>
- <th class="ralign">Enqueues</th>
- <th class="ralign">Dequeues</th>
- <th class="ralign">Depth</th>
- <th class="ralign">Accel.</th>
+ <th class="ralign">{unit_plural} Enqueued</th>
+ <th class="ralign">{unit_plural} Dequeued</th>
+ <th class="ralign">{unit} Depth</th>
+ <th class="ralign">Depth Accel.</th>
<th>Status</th>
</tr>
@@ -40,8 +37,8 @@
<td>{item_link}</a></td>
<td class="ralign">{item_consumers}</td>
<td class="ralign">{item_bindings}</td>
- <td class="ralign">{item_enqueues}</td>
- <td class="ralign">{item_dequeues}</td>
+ <td class="ralign">{item_enqueued}</td>
+ <td class="ralign">{item_dequeued}</td>
<td class="ralign">{item_depth}</td>
<td class="ralign">{item_depth_accel}</td>
<td>{item_status}</td>
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2007-11-02 17:32:47 UTC (rev 1218)
+++ mgmt/cumin/python/cumin/widgets.py 2007-11-02 19:11:41 UTC (rev 1219)
@@ -154,3 +154,33 @@
return "%i error%s, %i warning%s" % (error_count, ess(error_count),
warning_count, ess(warning_count))
+
+class UnitSwitch(Widget):
+ def __init__(self, app, name):
+ super(UnitSwitch, self).__init__(app, name)
+
+ self.param = Parameter(app, "param")
+ self.param.set_default("m")
+ self.add_parameter(self.param)
+
+ def get(self, session):
+ return self.param.get(session)
+
+ def set(self, session, value):
+ return self.param.set(session, value)
+
+ def render_messages_link(self, session, vhost):
+ branch = session.branch()
+ self.set(branch, "m")
+
+ class_ = self.get(session) == "m" and "selected"
+
+ return link(branch.marshal(), "Messages", class_)
+
+ def render_bytes_link(self, session, vhost):
+ branch = session.branch()
+ self.set(branch, "b")
+
+ class_ = self.get(session) == "b" and "selected"
+
+ return link(branch.marshal(), "Bytes", class_)
Modified: mgmt/cumin/python/cumin/widgets.strings
===================================================================
--- mgmt/cumin/python/cumin/widgets.strings 2007-11-02 17:32:47 UTC (rev 1218)
+++ mgmt/cumin/python/cumin/widgets.strings 2007-11-02 19:11:41 UTC (rev 1219)
@@ -19,3 +19,9 @@
<div>{status_info}</div>
</div>
+
+[UnitSwitch.html]
+<ul class="radiotabs">
+ <li>{messages_link}</li>
+ <li>{bytes_link}</li>
+</ul>