[rhmessaging-commits] rhmessaging commits: r3447 - mgmt/trunk/cumin/python/cumin.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Thu Jun 11 09:55:11 EDT 2009


Author: eallen
Date: 2009-06-11 09:55:11 -0400 (Thu, 11 Jun 2009)
New Revision: 3447

Modified:
   mgmt/trunk/cumin/python/cumin/charts.py
   mgmt/trunk/cumin/python/cumin/stat.py
Log:
Indicate sample interval in charts where we're rolling up values

Modified: mgmt/trunk/cumin/python/cumin/charts.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/charts.py	2009-06-11 13:29:47 UTC (rev 3446)
+++ mgmt/trunk/cumin/python/cumin/charts.py	2009-06-11 13:55:11 UTC (rev 3447)
@@ -137,10 +137,11 @@
         self.surface.write_to_png(writer)
 
 class TimeSeriesChart(object):
-    def __init__(self, width, height):
+    def __init__(self, width, height, interval=0):
         self.width = width - 40
         self.height = height - 20
-        self.surface = ImageSurface(FORMAT_ARGB32, width, height)
+        real_height = height + ((interval > 10) and 12 or 0)
+        self.surface = ImageSurface(FORMAT_ARGB32, width, real_height)
         self.surface.set_device_offset(1.5, 5.5)
         self.x_max = 1
         self.x_min = 0
@@ -253,6 +254,16 @@
 
         cr.stroke()
 
+    def plot_interval(self, interval):
+        if interval > 10:
+            cr = Context(self.surface)
+            cr.set_line_width(0.2)
+            cr.set_source_rgb(0.2, 0.2, 0.2)
+    
+            cr.move_to(2, self.height + 24)
+            cr.show_text("* Samples averaged over %i second interval" % interval)
+            cr.stroke()
+
     def plot_x_axis(self, intervals, step):
         cr = Context(self.surface)
         cr.set_line_width(0.2)

Modified: mgmt/trunk/cumin/python/cumin/stat.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/stat.py	2009-06-11 13:29:47 UTC (rev 3446)
+++ mgmt/trunk/cumin/python/cumin/stat.py	2009-06-11 13:55:11 UTC (rev 3447)
@@ -415,8 +415,12 @@
         if interval != -1:
             return interval
         else:
-            max_samples = int(width * 1.5)
-            return max(int(duration / max_samples), 1)
+            mode = self.mode.get(session)
+            if mode == "rate":
+                return 1
+            else:
+                max_samples = int(width * 1.5)
+                return max(int(duration / max_samples), 1)
 
     def render_samples(self, session, recent):
         c = {(1,0,0): "red", (0,0,1): "blue", (0,1,0): "green"}
@@ -450,17 +454,17 @@
             if cached_png:
                 return cached_png
 
-        width = self.container_width.get(session)
-        height = self.container_height.get(session)
-        chart = TimeSeriesChart(width, height)
-
         samples = dict()
         values = dict()
 
+        width = self.container_width.get(session)
+        height = self.container_height.get(session)
         mode = self.mode.get(session)
         duration = self.duration.get(session)
         interval = self.get_interval(session, duration, width)
 
+        chart = TimeSeriesChart(width, height, interval=interval)
+
         if mode == "rate":
             method = None # don't do averaging
             for stat in stats:
@@ -523,6 +527,7 @@
             chart.plot_ticks(samples[stat], color=color)
 
         chart.plot_frame()
+        chart.plot_interval(interval)
 
         if mode == "rate":
             titles = ["%s / sec" % x.title for x in stats]




More information about the rhmessaging-commits mailing list