[rhmessaging-commits] rhmessaging commits: r1551 - mgmt/cumin/python/cumin.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Fri Jan 11 11:55:51 EST 2008


Author: justi9
Date: 2008-01-11 11:55:50 -0500 (Fri, 11 Jan 2008)
New Revision: 1551

Modified:
   mgmt/cumin/python/cumin/stat.py
   mgmt/cumin/python/cumin/stat.strings
Log:
Adds variable durations to charts.



Modified: mgmt/cumin/python/cumin/stat.py
===================================================================
--- mgmt/cumin/python/cumin/stat.py	2008-01-11 16:16:31 UTC (rev 1550)
+++ mgmt/cumin/python/cumin/stat.py	2008-01-11 16:55:50 UTC (rev 1551)
@@ -75,6 +75,9 @@
 
         self.stats_tmpl = Template(self, "stat_html")
 
+        self.duration = DurationSwitch(app, "duration")
+        self.add_child(self.duration)
+
     def render_href(self, session, object):
         params = list()
 
@@ -86,6 +89,13 @@
         for stat in self.stats:
             params.append("stat=%s" % stat)
 
+        duration = self.duration.get(session)
+
+        if duration == "h":
+            params.append("duration=%i" % 3600)
+        elif duration == "d":
+            params.append("duration=%i" % 86400)
+
         return "stats.png?" + ";".join(params)
 
     def render_stats(self, session, object):
@@ -123,6 +133,11 @@
         self.mode = Parameter(app, "mode")
         self.add_parameter(self.mode)
 
+        # In seconds
+        self.duration = IntegerParameter(app, "duration")
+        self.duration.default = 600
+        self.add_parameter(self.duration)
+
     def get_object(self, session, object):
         cls = self.class_.get(session).mint_class
         id = self.id.get(session)
@@ -144,8 +159,10 @@
         times = dict()
         values = dict()
 
+        duration = self.duration.get(session)
+
         for stat in stats:
-            samples[stat] = stat.samples(object, 600)
+            samples[stat] = stat.samples(object, duration)
             values[stat] = [x[1] for x in samples[stat]]
 
         max_value = 0
@@ -168,7 +185,7 @@
 
         max_value = max_value + (round - max_value % round)
 
-        chart.set_x_max(600)
+        chart.set_x_max(duration)
         chart.set_y_max(max_value)
 
         chart.plot_x_axis(48)
@@ -184,3 +201,11 @@
         writer = Writer()
         chart.write(writer)
         return writer.to_string()
+
+class DurationSwitch(StateSwitch):
+    def __init__(self, app, name):
+        super(DurationSwitch, self).__init__(app, name)
+
+        self.add_state("m", "10 minutes")
+        self.add_state("h", "1 hour")
+        self.add_state("d", "1 day")

Modified: mgmt/cumin/python/cumin/stat.strings
===================================================================
--- mgmt/cumin/python/cumin/stat.strings	2008-01-11 16:16:31 UTC (rev 1550)
+++ mgmt/cumin/python/cumin/stat.strings	2008-01-11 16:55:50 UTC (rev 1551)
@@ -98,6 +98,8 @@
     <td><img id="{id}" src="{href}" height="140" width="540"/></td>
     <td>
       {stats}
+      <br/>
+      {duration}
     </td>
   </tr>
 </table>
@@ -107,3 +109,4 @@
 
 [StatValueChart.stat_html]
 <span class="swatch" style="background-color: {stat_color}">&nbsp;</span> {stat_value}
+<br/>




More information about the rhmessaging-commits mailing list