[rhmessaging-commits] rhmessaging commits: r1557 - mgmt/cumin/python/cumin.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Sun Jan 13 16:19:22 EST 2008
Author: justi9
Date: 2008-01-13 16:19:22 -0500 (Sun, 13 Jan 2008)
New Revision: 1557
Modified:
mgmt/cumin/python/cumin/broker.py
mgmt/cumin/python/cumin/charts.py
mgmt/cumin/python/cumin/client.py
mgmt/cumin/python/cumin/exchange.py
mgmt/cumin/python/cumin/stat.py
mgmt/cumin/python/cumin/util.py
Log:
Adds a rate mode to charts and uses it for some client and exchange
charts.
Makes all the charts chart only one value series, for now.
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2008-01-13 18:57:33 UTC (rev 1556)
+++ mgmt/cumin/python/cumin/broker.py 2008-01-13 21:19:22 UTC (rev 1557)
@@ -89,13 +89,16 @@
def render_content(self, session, data):
broker = Identifiable(data["id"])
branch = session.branch()
- self.frame().show_broker(branch, broker).show_view(branch)
+ self.page().show_broker(branch, broker).show_view(branch)
return fmt_olink(branch, broker, name=data["name"])
class GroupsColumn(SqlTableColumn):
def get_title(self, session, model):
return "Groups"
+ def get_orderby_sql(self, session):
+ return None
+
def render_content(self, session, data):
broker = BrokerRegistration.get(data["id"])
count = broker.groups.count()
Modified: mgmt/cumin/python/cumin/charts.py
===================================================================
--- mgmt/cumin/python/cumin/charts.py 2008-01-13 18:57:33 UTC (rev 1556)
+++ mgmt/cumin/python/cumin/charts.py 2008-01-13 21:19:22 UTC (rev 1557)
@@ -52,6 +52,7 @@
cr.set_line_width(0.2)
cr.set_source_rgb(0.6, 0.6, 0.6)
+ absmax = self.x_max - self.x_min
i = 0
for x in range(self.width, 0 - interval, -interval):
@@ -59,7 +60,7 @@
cr.line_to(x, self.height + 10)
if i % step == 0:
- value = self.x_max - (self.x_max * x / float(self.width))
+ value = absmax - (absmax * x / float(self.width))
cr.show_text(fmt_duration_brief(value))
i += 1
@@ -73,15 +74,19 @@
i = 0
- for y in range(self.height, 0 - interval, -interval):
+ for y in range(0, self.height, interval):
cr.move_to(0, y)
cr.line_to(self.width + 2, y)
if i % step == 0:
- value = self.y_max - (self.y_max * y / float(self.height))
+ fraction = (self.height - y) / float(self.height)
+ value = fraction * self.y_max - self.y_min
+ value = value + self.y_min
- if value < 10:
- svalue = "%0.0f" % value
+ if value == 0:
+ svalue = "0"
+ elif value < 10:
+ svalue = str(value)
elif value > 10000:
svalue = "%ik" % int(round(value / 1000, -1))
else:
Modified: mgmt/cumin/python/cumin/client.py
===================================================================
--- mgmt/cumin/python/cumin/client.py 2008-01-13 18:57:33 UTC (rev 1556)
+++ mgmt/cumin/python/cumin/client.py 2008-01-13 21:19:22 UTC (rev 1557)
@@ -303,11 +303,13 @@
super(ClientStatistics.StatisticsHistory, self).__init__(app, name)
chart = StatValueChart(app, "sent")
- chart.stats = ("framesFromClient", "bytesFromClient")
+ chart.stats = ("bytesFromClient",)
+ chart.mode = "rate"
self.add_child(chart)
chart = StatValueChart(app, "received")
- chart.stats = ("framesToClient", "bytesToClient")
+ chart.stats = ("bytesToClient",)
+ chart.mode = "rate"
self.add_child(chart)
def get_title(self, session, client):
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2008-01-13 18:57:33 UTC (rev 1556)
+++ mgmt/cumin/python/cumin/exchange.py 2008-01-13 21:19:22 UTC (rev 1557)
@@ -434,15 +434,17 @@
(app, name)
chart = StatValueChart(app, "received")
- chart.stats = ("msgReceives", "byteReceives")
+ chart.stats = ("msgReceives",)
+ chart.mode = "rate"
self.add_child(chart)
chart = StatValueChart(app, "routed")
- chart.stats = ("msgRoutes", "byteRoutes")
+ chart.stats = ("msgRoutes",)
+ chart.mode = "rate"
self.add_child(chart)
chart = StatValueChart(app, "dropped")
- chart.stats = ("msgDrops", "byteDrops")
+ chart.stats = ("msgDrops",)
self.add_child(chart)
def get_title(self, session, queue):
Modified: mgmt/cumin/python/cumin/stat.py
===================================================================
--- mgmt/cumin/python/cumin/stat.py 2008-01-13 18:57:33 UTC (rev 1556)
+++ mgmt/cumin/python/cumin/stat.py 2008-01-13 21:19:22 UTC (rev 1557)
@@ -71,6 +71,8 @@
def __init__(self, app, name):
super(StatValueChart, self).__init__(app, name)
+ self.mode = None
+
self.stats = ()
self.stats_tmpl = Template(self, "stat_html")
@@ -96,6 +98,9 @@
elif duration == "d":
params.append("duration=%i" % 86400)
+ if self.mode:
+ params.append("mode=%s" % self.mode)
+
return "stats.png?" + ";".join(params)
def render_stats(self, session, object):
@@ -113,8 +118,14 @@
def render_stat_value(self, session, args):
stat, object = args
- return stat.value_html(object)
+ if self.mode == "rate":
+ html = stat.rate_html(object)
+ else:
+ html = stat.value_html(object)
+
+ return html
+
def render_stat_unit(self, session, args):
stat, object = args
value = stat.value(object)
@@ -162,26 +173,53 @@
stats = [cls.get_stat(x) for x in self.stats.get(session)]
samples = dict()
- times = dict()
values = dict()
duration = self.duration.get(session)
+ if self.mode.get(session) == "rate":
+ for stat in stats:
+ os = stat.samples(object, duration)
+ ns = list()
+ prev = None
+
+ for sample in reversed(os):
+ if prev is None:
+ ns.insert(0, (sample[0], 0.0))
+ else:
+ rate = calc_rate(sample[1], prev[1],
+ secs(sample[0]), secs(prev[0]))
+
+ ns.insert(0, (sample[0], rate))
+
+ prev = sample
+
+ samples[stat] = ns
+ else:
+ for stat in stats:
+ samples[stat] = stat.samples(object, duration)
+
for stat in stats:
- samples[stat] = stat.samples(object, duration)
values[stat] = [x[1] for x in samples[stat]]
- max_value = 0
+ max_value = 1
+ min_value = 0
for stat in stats:
vals = values[stat]
if vals:
max_value = max(max(vals), max_value)
+ min_value = min(min(vals), min_value)
- max_value = int(max_value * 1.1) + 1
+ max_value = round(max_value * 1.1 + 1)
+ if min_value < 0:
+ min_value = round(min_value * 1.1 - 1)
+
chart.x_max = duration
+ chart.x_min = 0
chart.y_max = max_value
+ chart.y_min = min_value
x_interval = 40
x_step = 2
Modified: mgmt/cumin/python/cumin/util.py
===================================================================
--- mgmt/cumin/python/cumin/util.py 2008-01-13 18:57:33 UTC (rev 1556)
+++ mgmt/cumin/python/cumin/util.py 2008-01-13 21:19:22 UTC (rev 1557)
@@ -14,7 +14,9 @@
def calc_rate(curr, prev, csecs, psecs):
if None not in (curr, prev, csecs, psecs):
- return (curr - prev) / float(csecs - psecs)
+ secs = csecs - psecs
+ if secs > 0:
+ return (curr - prev) / float(secs)
def secs(dt):
if dt is not None:
More information about the rhmessaging-commits
mailing list