[rhmessaging-commits] rhmessaging commits: r1161 - mgmt/cumin/python/cumin.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Thu Oct 25 13:38:48 EDT 2007
Author: justi9
Date: 2007-10-25 13:38:48 -0400 (Thu, 25 Oct 2007)
New Revision: 1161
Modified:
mgmt/cumin/python/cumin/charts.py
mgmt/cumin/python/cumin/demo.py
mgmt/cumin/python/cumin/page.strings
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/queue.strings
Log:
Displays 3 different graphs on the queue stats history tab. Pretties
them up a little. Makes the chart lines issue from the right.
Modified: mgmt/cumin/python/cumin/charts.py
===================================================================
--- mgmt/cumin/python/cumin/charts.py 2007-10-25 14:09:30 UTC (rev 1160)
+++ mgmt/cumin/python/cumin/charts.py 2007-10-25 17:38:48 UTC (rev 1161)
@@ -1,6 +1,7 @@
from cairo import *
from random import random
from wooly import *
+from wooly.parameters import *
from parameters import *
@@ -13,26 +14,26 @@
def plot_values(self, values, interval=5, color=(0, 0, 0)):
max_value = max(100, max(values) * 1.2)
- ctx = Context(self.surface)
- ctx.set_line_width(2)
- ctx.set_source_rgb(*color)
+ cr = Context(self.surface)
+ cr.set_line_width(2)
+ cr.set_source_rgb(*color)
- for x, value in zip(range(0, self.width, interval), values):
- y = (value / float(max_value)) * self.height
- ctx.line_to(x, y)
+ for x, value in zip(range(self.width, 0, -interval), reversed(values)):
+ y = self.height - (value / float(max_value)) * self.height
+ cr.line_to(x, y)
- ctx.stroke()
+ cr.stroke()
def plot_intervals(self, interval=40):
- ctx = Context(self.surface)
- ctx.set_line_width(0.5)
- ctx.set_source_rgb(0.8, 0.8, 0.8)
+ cr = Context(self.surface)
+ cr.set_line_width(0.2)
+ cr.set_source_rgb(0.8, 0.8, 0.8)
for x in range(0, self.width, interval):
- ctx.move_to(x, 0)
- ctx.line_to(x, self.height)
+ cr.move_to(x, 0)
+ cr.line_to(x, self.height)
- ctx.stroke()
+ cr.stroke()
def write(self, name):
self.surface.write_to_png(name)
@@ -41,23 +42,31 @@
def __init__(self, app, name):
super(QueueChartPage, self).__init__(app, name)
- self.param = QueueParameter(app, "id")
+ 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.param.get(session)
+ return self.queue.get(session)
def get_content_type(self, session):
return "image/png"
def do_render(self, session, queue):
- messages = queue.get_measurement("msgDepth")
- bytes = queue.get_measurement("byteDepth")
-
chart = LineChart(600, 120)
chart.plot_intervals()
- chart.plot_values(messages.values, color=(1, 0, 0))
- chart.plot_values(bytes.values, color=(0, 0, 1))
+
+ measures = [queue.get_measurement(x) \
+ for x in self.measurements.get(session)]
+ colors = ((1,0,0), (0,0,1), (0,1,0))
+
+ for m, c in zip(measures, colors):
+ chart.plot_values(m.values, color=c)
name = "/tmp/whoa.png"
chart.write(name)
Modified: mgmt/cumin/python/cumin/demo.py
===================================================================
--- mgmt/cumin/python/cumin/demo.py 2007-10-25 14:09:30 UTC (rev 1160)
+++ mgmt/cumin/python/cumin/demo.py 2007-10-25 17:38:48 UTC (rev 1161)
@@ -176,13 +176,17 @@
self.setDaemon(True)
def frob_measure(self, measure):
- if measure.type == "int" and random() < 0.33:
+ if measure.type == "int":
if random() < 0.5:
- value = measure.get_value()
- measure.add_value(value + randint(4, 12))
+ if random() < 0.66:
+ value = measure.get_value()
+ measure.add_value(value + randint(4, 12))
+ else:
+ value = measure.get_value() - randint(3, 9)
+ measure.add_value(value > 0 and value or 0)
else:
- value = measure.get_value() - randint(3, 9)
- measure.add_value(value > 0 and value or 0)
+ measure.add_value(measure.get_value())
+
def run(self):
while True:
Modified: mgmt/cumin/python/cumin/page.strings
===================================================================
--- mgmt/cumin/python/cumin/page.strings 2007-10-25 14:09:30 UTC (rev 1160)
+++ mgmt/cumin/python/cumin/page.strings 2007-10-25 17:38:48 UTC (rev 1161)
@@ -107,7 +107,7 @@
}
.iblock {
- margin: 0;
+ margin: 1em 0;
padding: 0 1em;
}
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-10-25 14:09:30 UTC (rev 1160)
+++ mgmt/cumin/python/cumin/queue.py 2007-10-25 17:38:48 UTC (rev 1161)
@@ -379,9 +379,16 @@
def render_title(self, session, queue):
return "History"
- def render_chart_url(self, session, queue):
- return "queue.png?id=%i" % queue.id
+ def render_queue_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):
+ return "queue.png?id=%i;m=consumers" % queue.id
+
+ def render_transactions_chart_url(self, session, queue):
+ return "queue.png?id=%i;m=enqueueTxCount;m=dequeueTxCount" \
+ % queue.id
+
class ConsumerSet(ItemSet):
def render_title(self, session, queue):
return "Consumers (%i)" % len(queue.consumer_items())
Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings 2007-10-25 14:09:30 UTC (rev 1160)
+++ mgmt/cumin/python/cumin/queue.strings 2007-10-25 17:38:48 UTC (rev 1161)
@@ -205,20 +205,26 @@
</tr>
</table>
+[StatisticsHistory.css]
+.chart img {
+ background-color: #f9f9f9;
+ border: 1px dotted #ddd;
+}
+
[StatisticsHistory.html]
<h2>Queue Depth</h2>
-<div class="iblock">
- <img src="{chart_url}"/>
+<div class="iblock chart">
+ <img src="{queue_depth_chart_url}"/>
</div>
<h2>Consumers</h2>
-<div class="iblock">
- <img src="{chart_url}"/>
+<div class="iblock chart">
+ <img src="{consumers_chart_url}"/>
</div>
<h2>Transactions</h2>
-<div class="iblock">
- <img src="{chart_url}"/>
+<div class="iblock chart">
+ <img src="{transactions_chart_url}"/>
</div>
[ConsumerSet.html]
More information about the rhmessaging-commits
mailing list