rhmessaging commits: r3400 - mgmt/trunk/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2009-05-28 11:56:24 -0400 (Thu, 28 May 2009)
New Revision: 3400
Modified:
mgmt/trunk/cumin/python/cumin/charts.py
mgmt/trunk/cumin/python/cumin/stat.py
Log:
Remove the 'Standard Devation' from the legend
Modified: mgmt/trunk/cumin/python/cumin/charts.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/charts.py 2009-05-28 15:41:37 UTC (rev 3399)
+++ mgmt/trunk/cumin/python/cumin/charts.py 2009-05-28 15:56:24 UTC (rev 3400)
@@ -223,16 +223,8 @@
cr.stroke()
cr.set_source_rgb(*color)
- if title == "Standard Deviation":
- cr.move_to(8, y-8)
- cr.line_to(16, y-8)
- cr.move_to(12, y-8)
- cr.line_to(12, y)
- cr.move_to(8, y)
- cr.line_to(16, y)
- else:
- cr.rectangle(8, y, 8, -8)
- cr.fill()
+ cr.rectangle(8, y, 8, -8)
+ cr.fill()
cr.stroke()
cr.move_to(20, y)
Modified: mgmt/trunk/cumin/python/cumin/stat.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/stat.py 2009-05-28 15:41:37 UTC (rev 3399)
+++ mgmt/trunk/cumin/python/cumin/stat.py 2009-05-28 15:56:24 UTC (rev 3400)
@@ -443,25 +443,7 @@
method = self.method.get(session)
for stat in stats:
samples[stat] = stat.samples(object, duration, interval, method)
- """
- for stat in stats:
- values[stat] = [x[1] for x in samples[stat]]
- max_value = 1
- min_value = 0
-
- for stat in stats:
- vals = values[stat]
- if vals:
- max_value = max(nvl(max(vals), 0), max_value)
- min_value = min(nvl(min(vals), 0), min_value)
-
- max_value = round(max_value * 1.1 + 1)
-
- if min_value < 0:
- min_value = round(min_value * 1.1 - 1)
- """
-
# take stddev into account for max and min y values
deviated_values = [(nvl(x[1],0) + float(nvl(x[2],0))/2,
nvl(x[1],0) - float(nvl(x[2],0))/2)
@@ -509,13 +491,6 @@
else:
titles = [x.title for x in stats]
- stds = [x[2] for x in samples[stat] if x[2] is not None and int(x[2]) is not 0 for stat in stats]
- if len(stds):
- clrs = list(colors)
- clrs[len(titles)] = (0,0,0)
- colors = tuple(clrs)
- titles.append("Standard Deviation")
-
chart.plot_legend(titles, colors)
self.cache_it(session, chart, recent)
15 years, 7 months
rhmessaging commits: r3399 - mgmt/trunk/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2009-05-28 11:41:37 -0400 (Thu, 28 May 2009)
New Revision: 3399
Modified:
mgmt/trunk/cumin/python/cumin/stat.py
Log:
Handle case when there are no samples to graph
Modified: mgmt/trunk/cumin/python/cumin/stat.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/stat.py 2009-05-28 15:33:19 UTC (rev 3398)
+++ mgmt/trunk/cumin/python/cumin/stat.py 2009-05-28 15:41:37 UTC (rev 3399)
@@ -466,8 +466,8 @@
deviated_values = [(nvl(x[1],0) + float(nvl(x[2],0))/2,
nvl(x[1],0) - float(nvl(x[2],0))/2)
for x in samples[stat] for stat in stats]
- max_value = max(max(deviated_values))
- min_value = min(min(deviated_values))
+ max_value = deviated_values and max(max(deviated_values)) or 1
+ min_value = deviated_values and min(min(deviated_values)) or 0
max_value = round(max_value * 1.1 + 1)
15 years, 7 months
rhmessaging commits: r3398 - mgmt/trunk/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2009-05-28 11:33:19 -0400 (Thu, 28 May 2009)
New Revision: 3398
Modified:
mgmt/trunk/cumin/python/cumin/stat.py
Log:
Take stddev into account for max and min y values
Modified: mgmt/trunk/cumin/python/cumin/stat.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/stat.py 2009-05-28 15:32:40 UTC (rev 3397)
+++ mgmt/trunk/cumin/python/cumin/stat.py 2009-05-28 15:33:19 UTC (rev 3398)
@@ -443,7 +443,7 @@
method = self.method.get(session)
for stat in stats:
samples[stat] = stat.samples(object, duration, interval, method)
-
+ """
for stat in stats:
values[stat] = [x[1] for x in samples[stat]]
@@ -460,7 +460,20 @@
if min_value < 0:
min_value = round(min_value * 1.1 - 1)
+ """
+
+ # take stddev into account for max and min y values
+ deviated_values = [(nvl(x[1],0) + float(nvl(x[2],0))/2,
+ nvl(x[1],0) - float(nvl(x[2],0))/2)
+ for x in samples[stat] for stat in stats]
+ max_value = max(max(deviated_values))
+ min_value = min(min(deviated_values))
+ 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
@@ -495,8 +508,8 @@
titles = ["%s / sec" % x.title for x in stats]
else:
titles = [x.title for x in stats]
+
stds = [x[2] for x in samples[stat] if x[2] is not None and int(x[2]) is not 0 for stat in stats]
-
if len(stds):
clrs = list(colors)
clrs[len(titles)] = (0,0,0)
15 years, 7 months
rhmessaging commits: r3397 - mgmt/trunk/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2009-05-28 11:32:40 -0400 (Thu, 28 May 2009)
New Revision: 3397
Modified:
mgmt/trunk/cumin/python/cumin/charts.py
Log:
Make the stddev marker much more subtle(transparent)
Modified: mgmt/trunk/cumin/python/cumin/charts.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/charts.py 2009-05-28 14:42:22 UTC (rev 3396)
+++ mgmt/trunk/cumin/python/cumin/charts.py 2009-05-28 15:32:40 UTC (rev 3397)
@@ -196,7 +196,7 @@
cr.fill()
if dev:
- cr.set_source_rgba(0, 0, 0, 0.66)
+ cr.set_source_rgba(0, 0, 0, 0.1)
half_dev = int(((float(dev) / float(self.y_max)) * self.height) / 2)
cr.move_to(x - dot_size, y - half_dev)
cr.line_to(x + dot_size, y - half_dev)
15 years, 7 months
rhmessaging commits: r3396 - mgmt/trunk/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2009-05-28 10:42:22 -0400 (Thu, 28 May 2009)
New Revision: 3396
Modified:
mgmt/trunk/cumin/python/cumin/charts.py
Log:
Fix the way stddev is charted.
Modified: mgmt/trunk/cumin/python/cumin/charts.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/charts.py 2009-05-28 14:14:44 UTC (rev 3395)
+++ mgmt/trunk/cumin/python/cumin/charts.py 2009-05-28 14:42:22 UTC (rev 3396)
@@ -197,7 +197,7 @@
if dev:
cr.set_source_rgba(0, 0, 0, 0.66)
- half_dev = int(dev/2)
+ half_dev = int(((float(dev) / float(self.y_max)) * self.height) / 2)
cr.move_to(x - dot_size, y - half_dev)
cr.line_to(x + dot_size, y - half_dev)
15 years, 7 months
rhmessaging commits: r3395 - mgmt/trunk/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2009-05-28 10:14:44 -0400 (Thu, 28 May 2009)
New Revision: 3395
Modified:
mgmt/trunk/cumin/python/cumin/widgets.py
Log:
Minor cleanup: process() doesn't take an *args.
Modified: mgmt/trunk/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.py 2009-05-28 14:11:05 UTC (rev 3394)
+++ mgmt/trunk/cumin/python/cumin/widgets.py 2009-05-28 14:14:44 UTC (rev 3395)
@@ -55,7 +55,7 @@
self.add_child(self.actions)
def do_process(self, session, *args):
- self.actions.process(session, *args)
+ self.actions.process(session)
super(CuminMainView, self).do_process(session, *args)
15 years, 7 months
rhmessaging commits: r3394 - mgmt/trunk/cumin/python/cumin/messaging.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2009-05-28 10:11:05 -0400 (Thu, 28 May 2009)
New Revision: 3394
Modified:
mgmt/trunk/cumin/python/cumin/messaging/exchange.py
Log:
Fixing exception when viewing an exchange. Changing ExchangeStats from TabbedModeSet to a Widget since it has no sub-tabs.
Modified: mgmt/trunk/cumin/python/cumin/messaging/exchange.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/exchange.py 2009-05-27 21:43:33 UTC (rev 3393)
+++ mgmt/trunk/cumin/python/cumin/messaging/exchange.py 2009-05-28 14:11:05 UTC (rev 3394)
@@ -499,7 +499,7 @@
title = self.app.model.broker.get_object_title(session, broker)
return "Add Exchange to %s" % title
-class ExchangeStats(TabbedModeSet):
+class ExchangeStats(Widget):
def __init__(self, app, name):
super(ExchangeStats, self).__init__(app, name)
15 years, 7 months
rhmessaging commits: r3393 - in mgmt/trunk/cumin/python/cumin: grid and 1 other directories.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2009-05-27 17:43:33 -0400 (Wed, 27 May 2009)
New Revision: 3393
Modified:
mgmt/trunk/cumin/python/cumin/charts.py
mgmt/trunk/cumin/python/cumin/grid/collector.py
mgmt/trunk/cumin/python/cumin/grid/pool.py
mgmt/trunk/cumin/python/cumin/messaging/queue.py
mgmt/trunk/cumin/python/cumin/model.py
mgmt/trunk/cumin/python/cumin/stat.py
Log:
Default all charts to fullpageable.
Add data points and stddev to charts.
Modified: mgmt/trunk/cumin/python/cumin/charts.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/charts.py 2009-05-27 18:24:23 UTC (rev 3392)
+++ mgmt/trunk/cumin/python/cumin/charts.py 2009-05-27 21:43:33 UTC (rev 3393)
@@ -154,7 +154,7 @@
tnow = time()
- for dt, value in samples:
+ for dt, value, dev in samples:
if value is None:
continue
@@ -170,8 +170,48 @@
cr.stroke()
+ def plot_ticks(self, samples, color=(0, 0, 0)):
+ cr = Context(self.surface)
+ cr.set_line_width(1.5)
+
+ tnow = time()
+ dot_size = max(int(self.height / 100), 2)
+ half_dot = int(dot_size / 2)
+
+ for dt, value, dev in samples:
+ if value is None:
+ continue
+
+ t = secs(dt)
+
+ # prevent line from drawing off right side of grid
+ if tnow - t < 0:
+ t = tnow
+
+ cr.set_source_rgba(color[0], color[1], color[2], 0.66)
+ x = self.width - ((tnow - t) / float(self.x_max)) * self.width
+ y = self.height - (value / float(self.y_max)) * self.height
+ cr.move_to(x, y)
+ cr.rectangle(x - half_dot, y - half_dot, dot_size, dot_size)
+ cr.fill()
+
+ if dev:
+ cr.set_source_rgba(0, 0, 0, 0.66)
+ half_dev = int(dev/2)
+ cr.move_to(x - dot_size, y - half_dev)
+ cr.line_to(x + dot_size, y - half_dev)
+
+ cr.move_to(x, y - half_dev)
+ cr.line_to(x, y + half_dev)
+
+ cr.move_to(x - dot_size, y + half_dev)
+ cr.line_to(x + dot_size, y + half_dev)
+
+ cr.stroke()
+
def plot_legend(self, titles, colors):
cr = Context(self.surface)
+ cr.set_line_width(1.5)
for i, item in enumerate(zip(titles, colors)):
title, color = item
@@ -183,8 +223,16 @@
cr.stroke()
cr.set_source_rgb(*color)
- cr.rectangle(8, y, 8, -8)
- cr.fill()
+ if title == "Standard Deviation":
+ cr.move_to(8, y-8)
+ cr.line_to(16, y-8)
+ cr.move_to(12, y-8)
+ cr.line_to(12, y)
+ cr.move_to(8, y)
+ cr.line_to(16, y)
+ else:
+ cr.rectangle(8, y, 8, -8)
+ cr.fill()
cr.stroke()
cr.move_to(20, y)
Modified: mgmt/trunk/cumin/python/cumin/grid/collector.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/collector.py 2009-05-27 18:24:23 UTC (rev 3392)
+++ mgmt/trunk/cumin/python/cumin/grid/collector.py 2009-05-27 21:43:33 UTC (rev 3393)
@@ -115,12 +115,10 @@
chart = self.JobStackedChart(app, "jobs")
chart.stats = ("RunningJobs", "IdleJobs")
- chart.fullpageable = True
self.add_child(chart)
chart = self.SlotStackedChart(app, "slots")
chart.stats = ("HostsClaimed", "HostsUnclaimed", "HostsOwner")
- chart.fullpageable = True
self.add_child(chart)
def render_title(self, session):
Modified: mgmt/trunk/cumin/python/cumin/grid/pool.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/pool.py 2009-05-27 18:24:23 UTC (rev 3392)
+++ mgmt/trunk/cumin/python/cumin/grid/pool.py 2009-05-27 21:43:33 UTC (rev 3393)
@@ -322,13 +322,11 @@
self.add_child(slot_map)
chart = self.JobStackedChart(app, "jobs")
- chart.fullpageable = True
chart.duration.param.default = "3600"
chart.stats = ("RunningJobs", "IdleJobs")
self.add_child(chart)
chart = self.SlotStackedChart(app, "slots")
- chart.fullpageable = True
chart.duration.param.default = "3600"
chart.stats = ("HostsClaimed", "HostsUnclaimed", "HostsOwner")
self.add_child(chart)
Modified: mgmt/trunk/cumin/python/cumin/messaging/queue.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/queue.py 2009-05-27 18:24:23 UTC (rev 3392)
+++ mgmt/trunk/cumin/python/cumin/messaging/queue.py 2009-05-27 21:43:33 UTC (rev 3393)
@@ -835,16 +835,13 @@
self.add_child(StatSet(app, "io", "io"))
chart = self.EnqueueDequeueRateChart(app, "enqdeq")
- chart.fullpageable = True
self.add_child(chart)
chart = self.DepthChart(app, "depth")
- chart.fullpageable = True
self.add_child(chart)
chart = StatValueChart(app, "consumers")
chart.stats = ("consumerCount",)
- chart.fullpageable = True
self.add_child(chart)
def render_title(self, session):
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2009-05-27 18:24:23 UTC (rev 3392)
+++ mgmt/trunk/cumin/python/cumin/model.py 2009-05-27 21:43:33 UTC (rev 3393)
@@ -389,7 +389,7 @@
def avg_samples(self, object, secs, interval):
conn = self.get_connection()
- when = "(qmf_update_time >= now() - interval '%i seconds')" % secs
+ when = "(qmf_update_time >= now() - interval '%i seconds')" % int(secs * 1.5)
where = "%s and %s" % (object.stats.clause, when)
table_name = self.cumin_class.mint_stats_class.q.tableName
@@ -399,11 +399,12 @@
cursor = conn.cursor()
sql = """select max(qmf_update_time) as interval_end,
- cast(avg(%s) as integer) as value
+ cast(avg(%s) as integer) as value,
+ stddev(%s) as dev
from %s
where %s
group by floor(extract(epoch from qmf_update_time) / %i)
- order by interval_end desc;""" % (field_name,
+ order by interval_end desc;""" % (field_name, field_name,
table_name,
where,
interval)
Modified: mgmt/trunk/cumin/python/cumin/stat.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/stat.py 2009-05-27 18:24:23 UTC (rev 3392)
+++ mgmt/trunk/cumin/python/cumin/stat.py 2009-05-27 21:43:33 UTC (rev 3393)
@@ -104,7 +104,7 @@
self.duration = JSDurationSwitch(app, "duration")
self.add_child(self.duration)
- self.fullpageable = False
+ self.fullpageable = True
def get_args(self, session):
return self.frame.get_args(session)
@@ -434,7 +434,7 @@
rate = calc_rate(sample[1], prev[1],
secs(sample[0]), secs(prev[0]))
- ns.insert(0, (sample[0], rate))
+ ns.insert(0, (sample[0], rate, None))
prev = sample
@@ -481,18 +481,28 @@
chart.plot_x_axis(x_intervals, x_step)
chart.plot_y_axis(y_intervals, y_step)
- colors = ((1,0,0), (0,0,1), (0,1,0))
+ colors = ((1,0,0), (0,0,1), (0,1,0), (0,0,0))
for stat, color in zip(stats, colors):
chart.plot_values(samples[stat], color=color)
+ for stat, color in zip(stats, colors):
+ chart.plot_ticks(samples[stat], color=color)
+
chart.plot_frame()
- if self.mode.get(session) == "rate":
+ if mode == "rate":
titles = ["%s / sec" % x.title for x in stats]
else:
titles = [x.title for x in stats]
+ stds = [x[2] for x in samples[stat] if x[2] is not None and int(x[2]) is not 0 for stat in stats]
+ if len(stds):
+ clrs = list(colors)
+ clrs[len(titles)] = (0,0,0)
+ colors = tuple(clrs)
+ titles.append("Standard Deviation")
+
chart.plot_legend(titles, colors)
self.cache_it(session, chart, recent)
15 years, 7 months
rhmessaging commits: r3392 - in mgmt/trunk/cumin: python/cumin/grid and 2 other directories.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2009-05-27 14:24:23 -0400 (Wed, 27 May 2009)
New Revision: 3392
Modified:
mgmt/trunk/cumin/python/cumin/grid/collector.py
mgmt/trunk/cumin/python/cumin/grid/pool.py
mgmt/trunk/cumin/python/cumin/messaging/queue.py
mgmt/trunk/cumin/python/cumin/model.py
mgmt/trunk/cumin/python/cumin/stat.py
mgmt/trunk/cumin/python/cumin/stat.strings
mgmt/trunk/cumin/resources/app.js
Log:
1st cut at averaging samples for Charts.
Consolidate stacked charts with line charts and simplify javascript.
Make some queue charts fullpageable.
Modified: mgmt/trunk/cumin/python/cumin/grid/collector.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/collector.py 2009-05-21 13:04:17 UTC (rev 3391)
+++ mgmt/trunk/cumin/python/cumin/grid/collector.py 2009-05-27 18:24:23 UTC (rev 3392)
@@ -115,10 +115,12 @@
chart = self.JobStackedChart(app, "jobs")
chart.stats = ("RunningJobs", "IdleJobs")
+ chart.fullpageable = True
self.add_child(chart)
chart = self.SlotStackedChart(app, "slots")
chart.stats = ("HostsClaimed", "HostsUnclaimed", "HostsOwner")
+ chart.fullpageable = True
self.add_child(chart)
def render_title(self, session):
Modified: mgmt/trunk/cumin/python/cumin/grid/pool.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/pool.py 2009-05-21 13:04:17 UTC (rev 3391)
+++ mgmt/trunk/cumin/python/cumin/grid/pool.py 2009-05-27 18:24:23 UTC (rev 3392)
@@ -322,11 +322,13 @@
self.add_child(slot_map)
chart = self.JobStackedChart(app, "jobs")
+ chart.fullpageable = True
chart.duration.param.default = "3600"
chart.stats = ("RunningJobs", "IdleJobs")
self.add_child(chart)
chart = self.SlotStackedChart(app, "slots")
+ chart.fullpageable = True
chart.duration.param.default = "3600"
chart.stats = ("HostsClaimed", "HostsUnclaimed", "HostsOwner")
self.add_child(chart)
Modified: mgmt/trunk/cumin/python/cumin/messaging/queue.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/queue.py 2009-05-21 13:04:17 UTC (rev 3391)
+++ mgmt/trunk/cumin/python/cumin/messaging/queue.py 2009-05-27 18:24:23 UTC (rev 3392)
@@ -835,13 +835,16 @@
self.add_child(StatSet(app, "io", "io"))
chart = self.EnqueueDequeueRateChart(app, "enqdeq")
+ chart.fullpageable = True
self.add_child(chart)
chart = self.DepthChart(app, "depth")
+ chart.fullpageable = True
self.add_child(chart)
chart = StatValueChart(app, "consumers")
chart.stats = ("consumerCount",)
+ chart.fullpageable = True
self.add_child(chart)
def render_title(self, session):
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2009-05-21 13:04:17 UTC (rev 3391)
+++ mgmt/trunk/cumin/python/cumin/model.py 2009-05-27 18:24:23 UTC (rev 3392)
@@ -2,6 +2,8 @@
from datetime import datetime, timedelta
from mint import Mint, MintConfig
from struct import unpack, calcsize
+from sqlobject import sqlhub
+from sqlobject.sqlbuilder import Select
from types import *
from wooly import *
from wooly.parameters import *
@@ -370,7 +372,49 @@
if stats.count():
return stats[0].qmfUpdateTime
- def samples(self, object, secs):
+ def get_connection(self):
+ return sqlhub.getConnection().getConnection()
+
+ def get_db_name(self):
+ name = self.name
+ nname = list()
+ for c in name:
+ if c.isupper():
+ if len(nname):
+ nname.append("_")
+ c = c.lower()
+ nname.append(c)
+ return "".join(nname)
+
+ def avg_samples(self, object, secs, interval):
+ conn = self.get_connection()
+
+ when = "(qmf_update_time >= now() - interval '%i seconds')" % secs
+ where = "%s and %s" % (object.stats.clause, when)
+
+ table_name = self.cumin_class.mint_stats_class.q.tableName
+ field_name = self.get_db_name()
+
+ if conn:
+ cursor = conn.cursor()
+
+ sql = """select max(qmf_update_time) as interval_end,
+ cast(avg(%s) as integer) as value
+ from %s
+ where %s
+ group by floor(extract(epoch from qmf_update_time) / %i)
+ order by interval_end desc;""" % (field_name,
+ table_name,
+ where,
+ interval)
+
+ cursor.execute(sql)
+ return cursor.fetchall()
+
+ def samples(self, object, secs, interval, method):
+ if method == "avg":
+ return self.avg_samples(object, secs, interval)
+
stats = object.stats
now = datetime.now()
Modified: mgmt/trunk/cumin/python/cumin/stat.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/stat.py 2009-05-21 13:04:17 UTC (rev 3391)
+++ mgmt/trunk/cumin/python/cumin/stat.py 2009-05-27 18:24:23 UTC (rev 3392)
@@ -104,6 +104,8 @@
self.duration = JSDurationSwitch(app, "duration")
self.add_child(self.duration)
+ self.fullpageable = False
+
def get_args(self, session):
return self.frame.get_args(session)
@@ -129,6 +131,9 @@
def get_chart_name(self, session):
return "stats.png"
+ def render_fullpageable(self, session, object):
+ return self.fullpageable and " fullpageable" or ""
+
def render_title(self, session, object):
cls = self.app.model.get_class_by_object(object)
return getattr(cls, self.stats[0]).title
@@ -343,6 +348,22 @@
self.duration.default = 600
self.add_parameter(self.duration)
+ self.interval = IntegerParameter(app, "interval")
+ self.interval.default = -1
+ self.add_parameter(self.interval)
+
+ self.method = Parameter(app, "method")
+ self.method.default = "avg"
+ self.add_parameter(self.method)
+
+ self.container_width = IntegerParameter(app, "width")
+ self.container_width.default = 360
+ self.add_parameter(self.container_width)
+
+ self.container_height = IntegerParameter(app, "height")
+ self.container_height.default = 100
+ self.add_parameter(self.container_height)
+
self.cache = ImageCache()
def get_content_type(self, session):
@@ -370,6 +391,14 @@
writer = self.cache.create_cache_file(filename, recent)
chart.write(writer)
+ def get_interval(self, session, duration, width):
+ interval = self.interval.get(session)
+ if interval != -1:
+ return interval
+ else:
+ max_samples = int(width * 1.5)
+ return max(int(duration / max_samples), 1)
+
def do_render(self, session, object):
cls = self.class_.get(session)
stats = [getattr(cls, x) for x in self.stats.get(session)]
@@ -382,16 +411,21 @@
if cached_png:
return cached_png
- chart = TimeSeriesChart(360, 100)
+ width = self.container_width.get(session)
+ height = self.container_height.get(session)
+ chart = TimeSeriesChart(width, height)
samples = dict()
values = dict()
+ mode = self.mode.get(session)
duration = self.duration.get(session)
+ interval = self.get_interval(session, duration, width)
- if self.mode.get(session) == "rate":
+ if mode == "rate":
+ method = None # don't do averaging
for stat in stats:
- os = stat.samples(object, duration)
+ os = stat.samples(object, duration, interval, method)
ns = list()
prev = None
@@ -406,8 +440,9 @@
samples[stat] = ns
else:
+ method = self.method.get(session)
for stat in stats:
- samples[stat] = stat.samples(object, duration)
+ samples[stat] = stat.samples(object, duration, interval, method)
for stat in stats:
values[stat] = [x[1] for x in samples[stat]]
@@ -467,17 +502,6 @@
return writer.to_string()
class StatStackedPage(StatChartPage):
- def __init__(self, app, name):
- super(StatStackedPage, self).__init__(app, name)
-
- self.container_width = IntegerParameter(app, "width")
- self.container_width.default = 360
- self.add_parameter(self.container_width)
-
- self.container_height = IntegerParameter(app, "height")
- self.container_height.default = 100
- self.add_parameter(self.container_height)
-
def do_render(self, session, object):
cls = self.class_.get(session)
stats = [getattr(cls, x) for x in self.stats.get(session)]
@@ -492,11 +516,13 @@
legend_height = len(stats) * 16 + 16
- chart = StackedValueChart(self.container_width.get(session),
- self.container_height.get(session),
- legend_height)
+ width = self.container_width.get(session)
+ height = self.container_height.get(session)
+ chart = StackedValueChart(width, height, legend_height)
duration = self.duration.get(session)
+ method = self.method.get(session)
+ interval = self.get_interval(session, duration, width)
max_value = 1
min_value = 999999
@@ -506,11 +532,11 @@
collapsed = dict()
values = dict()
for stat in stats:
- samples[stat] = stat.samples(object, duration)
+ samples[stat] = stat.samples(object, duration, interval, method)
# we sometimes get multiple samples for the same qmf_update_time
for sample in samples[stat]:
collapsed[sample[0]] = sample[1]
-
+
for t in collapsed:
if not t in points:
points[t] = list()
@@ -561,3 +587,11 @@
writer = Writer()
chart.write(writer)
return writer.to_string()
+
+if __name__ == "__main__":
+ import sys
+
+ try:
+ pass
+ except:
+ sys.exit(1)
Modified: mgmt/trunk/cumin/python/cumin/stat.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/stat.strings 2009-05-21 13:04:17 UTC (rev 3391)
+++ mgmt/trunk/cumin/python/cumin/stat.strings 2009-05-27 18:24:23 UTC (rev 3392)
@@ -164,30 +164,20 @@
[StatValueChart.html]
-<div class="StatValueChart" id="{id}">
+<div>
+<div class="StatValueChart{fullpageable}" id="{id}">
<h2>{title}</h2>
<div class="duration">{duration}</div>
<img id="{id}" src="{href}" height="{height}" width="{width}" alt="stats" />
<div class="loading" style="display:none;"><span>Loading...</span></div>
-</div>
+</div></div>
<script type="text/javascript">
//<![CDATA[
(function() {
- wooly.addPageUpdateListener(
- function () {
- if (document.images["{id}"].className == "Loading")
- return;
- cumin.updateChart("{id}");
- });
- var oImg = document.images['{id}'];
- $(oImg).addEvent('load', function () {
- var loading = $("{id}").getElement(".loading");
- loading.setStyle('display', 'none');
- loading.setStyle('visibility', 'visible');
- loading.loading = false
- });
+ wooly.addPageUpdateListener(function () {if (document.images["{id}"].className == "Loading") return; cumin.updateChart("{id}");});
+ cumin.setupChart('{id}', {width});
}())
//]]>
</script>
@@ -197,63 +187,3 @@
<span class="swatch" style="background-color: {stat_color}"> </span>
<span class="ph" statname="{stat_name}" statmode="{mode}">{stat_value}</span>
</li>
-
-[StatStackedChart.javascript]
-function stackedNotify(full, width, height, id) {
- var oImg = document.images[id];
- if (oImg) {
- var src = oImg.src;
- var branch = wooly.session.branch(src);
- branch.width = Math.max(width - 100, 360);
- branch.height = Math.max(height - 100, 100);
- src = branch.marshal();
-
- src = cumin.refreshTime(src);
- oImg.className = "Loading";
- oImg.width = width;
- oImg.height = height;
- oImg.style.visibility = "hidden";
- oImg.src = src;
- }
-}
-
-[StatStackedChart.html]
-<div class="StatValueChart fullpageable" id="{id}">
- <h2>{title}</h2>
-
- <div class="duration">{duration}</div>
-
- <img id="{id}" src="{href}" alt="Stacked Value Chart" />
- <div class="loading" style="display:none;"><span>Loading...</span></div>
-</div>
-<script type="text/javascript">
-//<![CDATA[
-(function() {
- wooly.addPageUpdateListener(
- function () {
- if (document.images["{id}"].className == "Loading")
- return;
- cumin.updateChart("{id}");
- });
-
- $('{id}').onfullpage = function (width, height) { stackedNotify(true, width, height, '{id}'); };
- $('{id}').onrestore = function () { stackedNotify(false, {width}, 100, '{id}'); };
- var oImg = document.images['{id}'];
- $(oImg).addEvent('load', function () {
- this.style.visibility = "visible";
- this.removeAttribute("width");
- this.removeAttribute("height");
- this.className = "";
- });
- $(oImg).addEvent('mousedown', function(event){
- event.stop();
- });
- $(oImg).addEvent('load', function () {
- var loading = $("{id}").getElement(".loading");
- loading.setStyle('display', 'none');
- loading.setStyle('visibility', 'visible');
- loading.loading = false
- });
-}())
-//]]>
-</script>
Modified: mgmt/trunk/cumin/resources/app.js
===================================================================
--- mgmt/trunk/cumin/resources/app.js 2009-05-21 13:04:17 UTC (rev 3391)
+++ mgmt/trunk/cumin/resources/app.js 2009-05-27 18:24:23 UTC (rev 3392)
@@ -23,16 +23,9 @@
this.runObjectListeners = runObjectListeners;
this.refreshTime = function(src) {
- var sep = src.lastIndexOf(";");
- var time = new Date().getTime();
-
- if (isNaN(parseInt(src.substring(sep + 1)))) {
- src = src + ";" + time;
- } else {
- src = src.substring(0, sep) + ";" + time;
- }
-
- return src;
+ var branch = wooly.session.branch(src);
+ branch.ts = new Date().getTime();
+ return branch.marshal()
}
this.updateChart = function(id) {
@@ -94,6 +87,44 @@
}
}
+ this.setupChart = function (id, width) {
+ var chart = $(id);
+ chart.onfullpage = function (width, height) { cumin.chartNotify(true, width, height, id); };
+ chart.onrestore = function () { cumin.chartNotify(false, width, 100, id); };
+ var oImg = document.images[id];
+ $(oImg).addEvent('load', function () {
+ this.style.visibility = "visible";
+ this.removeAttribute("width");
+ this.removeAttribute("height");
+ this.className = "";
+ var loading = chart.getElement(".loading");
+ loading.setStyle('display', 'none');
+ loading.setStyle('visibility', 'visible');
+ loading.loading = false
+ });
+ $(oImg).addEvent('mousedown', function(event){
+ event.stop();
+ });
+ }
+
+ this.chartNotify = function (full, width, height, id) {
+ var oImg = document.images[id];
+ if (oImg) {
+ var src = oImg.src;
+ var branch = wooly.session.branch(src);
+ branch.width = Math.max(width - 100, 360);
+ branch.height = Math.max(height - 100, 100);
+ src = branch.marshal();
+
+ src = cumin.refreshTime(src);
+ oImg.className = "Loading";
+ oImg.width = width;
+ oImg.height = height;
+ oImg.style.visibility = "hidden";
+ oImg.src = src;
+ }
+ }
+
this.makeFullPageable = function (element) {
if (element.getElement(".fullpageTitle"))
return; // already fullpaged
15 years, 7 months
rhmessaging commits: r3391 - mgmt/trunk/cumin/resources.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2009-05-21 09:04:17 -0400 (Thu, 21 May 2009)
New Revision: 3391
Modified:
mgmt/trunk/cumin/resources/app.js
Log:
Fixup javascript for mootools
Modified: mgmt/trunk/cumin/resources/app.js
===================================================================
--- mgmt/trunk/cumin/resources/app.js 2009-05-21 12:43:28 UTC (rev 3390)
+++ mgmt/trunk/cumin/resources/app.js 2009-05-21 13:04:17 UTC (rev 3391)
@@ -37,12 +37,11 @@
this.updateChart = function(id) {
var chart = $(id);
+ var img = chart.getElementsByTagName("img")[0]
- var img = chart.elem("img")
- var src = img.getattr("src");
+ var src = img.src;
src = cumin.refreshTime(src);
-
- img.setattr("src", src);
+ img.src = src;
}
this.clickTableCheckbox = function (check, name) {
15 years, 7 months