Author: croberts
Date: 2012-04-24 15:27:23 +0000 (Tue, 24 Apr 2012)
New Revision: 5345
Modified:
trunk/cumin/python/cumin/grid/dashboard.py
trunk/cumin/python/cumin/model.py
trunk/cumin/python/cumin/stat.py
Log:
Implementing a way to limit the clutter that can happen for long-duration charts.
Modified: trunk/cumin/python/cumin/grid/dashboard.py
===================================================================
--- trunk/cumin/python/cumin/grid/dashboard.py 2012-04-24 14:59:24 UTC (rev 5344)
+++ trunk/cumin/python/cumin/grid/dashboard.py 2012-04-24 15:27:23 UTC (rev 5345)
@@ -96,6 +96,7 @@
chart = self.UtilChart(app, "util",
app.model.com_redhat_grid_plumage.OSUtil)
chart.stats = ["total", "unused", "owner",
"used"]
+ chart.max_samples = 200
chart.duration.param.default = "3600"
self.add_child(chart)
Modified: trunk/cumin/python/cumin/model.py
===================================================================
--- trunk/cumin/python/cumin/model.py 2012-04-24 14:59:24 UTC (rev 5344)
+++ trunk/cumin/python/cumin/model.py 2012-04-24 15:27:23 UTC (rev 5345)
@@ -318,7 +318,7 @@
return retval
class SamplesSqlAdapter(SqlAdapter):
- def __init__(self, app, cls, sig):
+ def __init__(self, app, cls, sig, session):
super(SamplesSqlAdapter, self).__init__(app, cls.sql_samples_table)
filters = cls.get_sample_filters_by_signature(sig)
@@ -326,6 +326,8 @@
self.query.add_filter(f)
self.update_col = cls.get_timestamp_col()
+
+ self.session = session
def get_sql_options(self, options):
return options
@@ -365,6 +367,16 @@
# reset the filters in case we need to re-run the query in this same request
del self.query.filters[:]
self.query.filters = org_filters
+
+ #Too many samples will result in a horribly cluttered chart, lets max_samples
(parameter)
+ max_samples = self.session.get("maxsamp")
+
+ reduced_samples = None
+ if max_samples is not None and max_samples > 0 and len(samples) >
max_samples:
+ reduced_interval = int(len(samples) / max_samples)
+ # show every N samples + we always want the first and last
+ reduced_samples = [sample for i, sample in enumerate(samples) if i %
reduced_interval == 0 or i == 0 or i == len(samples) -1]
+ samples = reduced_samples
return samples
Modified: trunk/cumin/python/cumin/stat.py
===================================================================
--- trunk/cumin/python/cumin/stat.py 2012-04-24 14:59:24 UTC (rev 5344)
+++ trunk/cumin/python/cumin/stat.py 2012-04-24 15:27:23 UTC (rev 5345)
@@ -209,6 +209,7 @@
self.cls = cls
self.duration.add_state("2592000", "1 month")
self.duration.add_state("31557600", "1 year")
+ self.max_samples = 100
def get_href_params(self, session):
params = list()
@@ -225,7 +226,8 @@
if self.mode:
params.append("mode=%s" % self.mode)
- params.append("interval=60") #may need to experiment on computing this
on the fly or use a value that matches the plumage sample rate
+ params.append("interval=60") #may need to experiment on computing this
on the fly or use a value that matches the plumage sample rate
+ params.append("maxsamp=%s" % self.max_samples)
return params
@@ -441,6 +443,10 @@
self.type = Parameter(app, "type")
self.add_parameter(self.type)
+
+ self.maxsamp = IntegerParameter(app, "maxsamp")
+ self.maxsamp.default = 0
+ self.add_parameter(self.maxsamp)
self.cache = ImageCache()
@@ -467,7 +473,7 @@
signature = self.object_signature.get(session)
- adapter = SamplesSqlAdapter(self.app, rosemary_class, signature)
+ adapter = SamplesSqlAdapter(self.app, rosemary_class, signature, session)
stats = [getattr(rosemary_class, x) for x in self.stats.get(session)]
return (adapter, stats)