[rhmessaging-commits] rhmessaging commits: r4343 - mgmt/newdata/cumin/python/cumin.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Fri Sep 24 21:09:29 EDT 2010
Author: eallen
Date: 2010-09-24 21:09:29 -0400 (Fri, 24 Sep 2010)
New Revision: 4343
Modified:
mgmt/newdata/cumin/python/cumin/stat.py
Log:
Prevent flash charts from being flooded with too much data and crashing.
Modified: mgmt/newdata/cumin/python/cumin/stat.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/stat.py 2010-09-24 21:53:27 UTC (rev 4342)
+++ mgmt/newdata/cumin/python/cumin/stat.py 2010-09-25 01:09:29 UTC (rev 4343)
@@ -751,6 +751,8 @@
interval = self.page.get_interval(session, duration, width)
+ msg = "Chart parameters: duration: %s end_secends_ago: %s interval: %s" % (str(duration), str(end_seconds_ago), str(interval))
+ log.debug(msg)
# get the most recent samples
samples = self.fetch_samples(adapter, duration, interval,
self.fix_method(method, mode),
@@ -767,6 +769,8 @@
max_of_axiis = max(max_value, axis_for_vals)
# the most recent value(s) changed the y-axis range
if axis_max != max_of_axiis:
+ msg = "Y-Axis changed. New chart parameters: time_span: %s end_secends_ago: %s interval: %s" % (str(time_span), str(end_seconds_ago), str(interval))
+ log.debug(msg)
samples = self.fetch_samples(adapter, time_span, interval,
self.fix_method(method, mode),
mode, False, stats,
@@ -775,6 +779,9 @@
else:
append = True
+ for sample, stat in zip(samples, stats):
+ log.debug("samples in %s: %d" % (stat.name, len(samples[sample])))
+
# create the chart dict
chart = self.get_chart(session, adapter, stats, samples, time_span, max_value, min_value, append, end_seconds_ago)
#print "**********\n"+chart.create()
@@ -1023,7 +1030,7 @@
def get_vals(self, session, samples, stat, text, duration, end_secs):
tnow = time()
points = self.points.get(session)
- vals = list()
+ values = list()
if points:
vals = [{"x":int(duration -(tnow - secs(dt)) + end_secs),
@@ -1033,8 +1040,18 @@
for dt, value, stacked_value in reversed(points[stat])
if value is not None]
- return vals
+ log.debug("number of points before culling: %d" % len(vals))
+ # allow only 1 value that has a -x
+ first_positive = 0
+ for i in range(len(vals)):
+ if vals[i]['x'] >= 0:
+ first_positive = i
+ break
+ values = [vals[i] for i in range(len(vals)) if i >= first_positive - 1]
+ log.debug("number of points after culling: %d" % len(values))
+ return values
+
class Points(Attribute):
def get_default(self, session):
return dict()
More information about the rhmessaging-commits
mailing list