Author: justi9
Date: 2007-11-02 17:37:21 -0400 (Fri, 02 Nov 2007)
New Revision: 1227
Modified:
mgmt/cumin/python/cumin/__init__.py
mgmt/cumin/python/cumin/charts.py
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
Log:
Adds exchange charts to the history subtab of the exchange view. Adds
a CuminChartPage that both ExchangeChartPage and QueueChartPage use.
Modified: mgmt/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/cumin/python/cumin/__init__.py 2007-11-02 21:33:50 UTC (rev 1226)
+++ mgmt/cumin/python/cumin/__init__.py 2007-11-02 21:37:21 UTC (rev 1227)
@@ -10,8 +10,8 @@
from model import CuminModel
from demo import DemoData
from page import CuminPage
-from queue import QueueXmlPage
-from charts import QueueChartPage
+from queue import QueueXmlPage, QueueChartPage
+from exchange import ExchangeChartPage
class Cumin(Application):
def __init__(self, model):
@@ -36,6 +36,7 @@
self.add_page(DevelPage(self, "devel.html"))
self.add_page(QueueXmlPage(self, "queue.xml"))
self.add_page(QueueChartPage(self, "queue.png"))
+ self.add_page(ExchangeChartPage(self, "exchange.png"))
class RandomIntegerPage(Page):
def __init__(self, app, name):
Modified: mgmt/cumin/python/cumin/charts.py
===================================================================
--- mgmt/cumin/python/cumin/charts.py 2007-11-02 21:33:50 UTC (rev 1226)
+++ mgmt/cumin/python/cumin/charts.py 2007-11-02 21:37:21 UTC (rev 1227)
@@ -1,10 +1,6 @@
from cairo import *
from random import random
-from wooly import *
-from wooly.parameters import *
-from parameters import *
-
class LineChart(object):
def __init__(self, width, height):
self.width = width
@@ -61,53 +57,3 @@
def write(self, writer):
self.surface.write_to_png(writer)
-
-class QueueChartPage(Page):
- def __init__(self, app, name):
- super(QueueChartPage, self).__init__(app, name)
-
- self.queue = QueueParameter(app, "id")
- self.add_parameter(self.queue)
-
- self.param = Parameter(app, "param")
- self.add_parameter(self.param)
-
- self.measurements = ListParameter(app, "m", self.param)
- self.add_parameter(self.measurements)
-
- def get_object(self, session, object):
- return self.queue.get(session)
-
- def get_content_type(self, session):
- return "image/png"
-
- def do_render(self, session, queue):
- chart = LineChart(600, 120)
-
- measures = [queue.get_measurement(x) \
- for x in self.measurements.get(session)]
-
- values = dict()
- for m in measures:
- values[m] = m.get_values(250)
-
- max_value = 0
- for m in measures:
- max_value = max(max(values[m]), max_value)
- max_value = max_value * 1.1
- max_value = max_value + (100 - max_value % 100)
- chart.set_max_value(int(max_value))
-
- chart.plot_x_intervals()
- chart.plot_y_axis()
-
- colors = ((1,0,0), (0,0,1), (0,1,0))
-
- for m, c in zip(measures, colors):
- chart.plot_values(values[m], color=c)
-
- chart.plot_frame()
-
- writer = Writer()
- chart.write(writer)
- return writer.to_string()
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2007-11-02 21:33:50 UTC (rev 1226)
+++ mgmt/cumin/python/cumin/exchange.py 2007-11-02 21:37:21 UTC (rev 1227)
@@ -286,9 +286,19 @@
return "Current"
class StatisticsHistory(Widget):
- def render_title(self, session, exchange):
+ def render_title(self, session, queue):
return "History"
+ def render_received_chart_url(self, session, queue):
+ return "exchange.png?id=%i;m=msgReceives;m=byteReceives" %
queue.id
+
+ def render_dropped_chart_url(self, session, queue):
+ return "exchange.png?id=%i;m=msgDrops;byteDrops" % queue.id
+
+ def render_routed_chart_url(self, session, queue):
+ return "exchange.png?id=%i;m=msgRoutes;m=byteRoutes" \
+ % queue.id
+
class ExchangeProducerSet(ItemSet):
def render_title(self, session, queue):
return "Producers (%i)" % len(queue.producer_items())
@@ -304,3 +314,11 @@
def render_item_bytes_produced(self, session, producer):
return producer.get_measurement("bytesProduced").get_value()
+
+class ExchangeChartPage(CuminChartPage):
+ def __init__(self, app, name):
+ super(ExchangeChartPage, self).__init__(app, name)
+
+ self.param = ExchangeParameter(app, "id")
+ self.add_parameter(self.param)
+ self.set_object_parameter(self.param)
Modified: mgmt/cumin/python/cumin/exchange.strings
===================================================================
--- mgmt/cumin/python/cumin/exchange.strings 2007-11-02 21:33:50 UTC (rev 1226)
+++ mgmt/cumin/python/cumin/exchange.strings 2007-11-02 21:37:21 UTC (rev 1227)
@@ -129,6 +129,22 @@
</tr>
</table>
+[StatisticsHistory.html]
+<h2>Received</h2>
+<div class="iblock chart">
+ <img src="{received_chart_url}"/>
+</div>
+
+<h2>Dropped</h2>
+<div class="iblock chart">
+ <img src="{dropped_chart_url}"/>
+</div>
+
+<h2>Routed</h2>
+<div class="iblock chart">
+ <img src="{routed_chart_url}"/>
+</div>
+
[ExchangeProducerSet.html]
<div class="sactions">
<h2>Act on Selected Producers:</h2>
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-11-02 21:33:50 UTC (rev 1226)
+++ mgmt/cumin/python/cumin/queue.py 2007-11-02 21:37:21 UTC (rev 1227)
@@ -11,24 +11,6 @@
strings = StringCatalog(__file__)
-class QueueXmlPage(Page):
- def __init__(self, app, name):
- super(QueueXmlPage, self).__init__(app, name)
-
- self.queue = QueueParameter(app, "id")
- self.add_parameter(self.queue)
-
- def get_content_type(self, session):
- return Page.xml_content_type
-
- def do_render(self, session, object):
- writer = Writer()
-
- writer.write(Page.xml_1_0_declaration)
- self.queue.get(session).write_xml(writer)
-
- return writer.to_string()
-
class QueueSet(ItemSet):
def __init__(self, app, name):
super(QueueSet, self).__init__(app, name)
@@ -413,7 +395,7 @@
def render_title(self, session, queue):
return "History"
- def render_queue_depth_chart_url(self, session, queue):
+ def render_depth_chart_url(self, session, queue):
return "queue.png?id=%i;m=msgDepth;m=byteDepth" % queue.id
def render_consumers_chart_url(self, session, queue):
@@ -441,3 +423,29 @@
def render_item_unacked_messages(self, session, consumer):
return consumer.get_measurement("unackedMessages").get_value()
+
+class QueueXmlPage(Page):
+ def __init__(self, app, name):
+ super(QueueXmlPage, self).__init__(app, name)
+
+ self.queue = QueueParameter(app, "id")
+ self.add_parameter(self.queue)
+
+ def get_content_type(self, session):
+ return Page.xml_content_type
+
+ def do_render(self, session, object):
+ writer = Writer()
+
+ writer.write(Page.xml_1_0_declaration)
+ self.queue.get(session).write_xml(writer)
+
+ return writer.to_string()
+
+class QueueChartPage(CuminChartPage):
+ def __init__(self, app, name):
+ super(QueueChartPage, self).__init__(app, name)
+
+ self.param = QueueParameter(app, "id")
+ self.add_parameter(self.param)
+ self.set_object_parameter(self.param)
Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings 2007-11-02 21:33:50 UTC (rev 1226)
+++ mgmt/cumin/python/cumin/queue.strings 2007-11-02 21:37:21 UTC (rev 1227)
@@ -240,18 +240,10 @@
</tr>
</table>
-[StatisticsHistory.css]
-/*
-.chart img {
- background-color: #f9f9f9;
- border: 1px dotted #ddd;
-}
-*/
-
[StatisticsHistory.html]
-<h2>Queue Depth</h2>
+<h2>Depth</h2>
<div class="iblock chart">
- <img src="{queue_depth_chart_url}"/>
+ <img src="{depth_chart_url}"/>
</div>
<h2>Consumers</h2>
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2007-11-02 21:33:50 UTC (rev 1226)
+++ mgmt/cumin/python/cumin/widgets.py 2007-11-02 21:37:21 UTC (rev 1227)
@@ -3,6 +3,7 @@
from wooly.forms import *
from util import *
+from charts import *
strings = StringCatalog(__file__)
@@ -155,6 +156,58 @@
return "%i error%s, %i warning%s" % (error_count, ess(error_count),
warning_count, ess(warning_count))
+class CuminChartPage(Page):
+ def __init__(self, app, name):
+ super(CuminChartPage, self).__init__(app, name)
+
+ self.__param = None
+
+ self.iparam = Parameter(app, "param")
+ self.add_parameter(self.iparam)
+
+ self.measurements = ListParameter(app, "m", self.iparam)
+ self.add_parameter(self.measurements)
+
+ def set_object_parameter(self, param):
+ self.__param = param
+
+ def get_object(self, session, object):
+ return self.__param.get(session)
+
+ def get_content_type(self, session):
+ return "image/png"
+
+ def do_render(self, session, object):
+ chart = LineChart(600, 120)
+
+ measures = [object.get_measurement(x) \
+ for x in self.measurements.get(session)]
+
+ values = dict()
+ for m in measures:
+ values[m] = m.get_values(250)
+
+ max_value = 0
+ for m in measures:
+ max_value = max(max(values[m]), max_value)
+ max_value = max_value * 1.1
+ max_value = max_value + (100 - max_value % 100)
+ chart.set_max_value(int(max_value))
+
+ chart.plot_x_intervals()
+ chart.plot_y_axis()
+
+ colors = ((1,0,0), (0,0,1), (0,1,0))
+
+ for m, c in zip(measures, colors):
+ chart.plot_values(values[m], color=c)
+
+ chart.plot_frame()
+
+ writer = Writer()
+ chart.write(writer)
+ return writer.to_string()
+
class UnitSwitch(Widget):
def __init__(self, app, name):
super(UnitSwitch, self).__init__(app, name)