Author: eallen
Date: 2008-10-10 09:12:22 -0400 (Fri, 10 Oct 2008)
New Revision: 2615
Modified:
mgmt/trunk/cumin/python/cumin/model.py
mgmt/trunk/cumin/python/cumin/pool.py
mgmt/trunk/cumin/python/cumin/pool.strings
Log:
Static version of Pool stats
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2008-10-10 12:49:25 UTC (rev 2614)
+++ mgmt/trunk/cumin/python/cumin/model.py 2008-10-10 13:12:22 UTC (rev 2615)
@@ -1565,6 +1565,21 @@
prop.title = "Collector ID"
prop.summary = True
+ stat = CuminStat(self, "Running")
+ stat.title = "Running Jobs"
+
+ stat = CuminStat(self, "Completed")
+ stat.title = "Completed Jobs"
+
+ stat = CuminStat(self, "Idle")
+ stat.title = "Idle Jobs"
+
+ stat = CuminStat(self, "Held")
+ stat.title = "Held Jobs"
+
+ stat = CuminStat(self, "Jobs")
+ stat.title = "Total Jobs"
+
def get_title(self, session):
return "Pool"
@@ -1651,13 +1666,13 @@
stat = CuminStat(self, "Held")
stat.title = "Held Jobs"
+ stat = CuminStat(self, "Jobs")
+ stat.title = "Total Jobs"
+
action = self.Hold(self, "hold")
action.title = "Hold"
action.summary = True
- stat = CuminStat(self, "Jobs")
- stat.title = "Total Jobs"
-
action = self.Release(self, "release")
action.title = "Release"
action.summary = True
Modified: mgmt/trunk/cumin/python/cumin/pool.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/pool.py 2008-10-10 12:49:25 UTC (rev 2614)
+++ mgmt/trunk/cumin/python/cumin/pool.py 2008-10-10 13:12:22 UTC (rev 2615)
@@ -230,6 +230,9 @@
self.__tabs = TabbedModeSet(app, "tabs")
self.add_child(self.__tabs)
+ stats = PoolStats(app, "stats")
+ self.__tabs.add_tab(stats)
+
jobs = JobsAndGroupsTab(app, "jobs")
self.__tabs.add_tab(jobs)
@@ -263,6 +266,59 @@
class LimitsTab(LimitsSet):
pass
+class PoolStats(Widget):
+ def __init__(self, app, name):
+ super(PoolStats, self).__init__(app, name)
+
+ stats = PoolStatSet(app, "general", "general")
+ self.add_child(stats)
+
+ def render_title(self, session):
+ return "Statistics"
+
+class PoolStatSet(StatSet):
+ def __init__(self, app, name, category):
+ super(PoolStatSet, self).__init__(app, name, category)
+
+ self.jobs = Attribute(app, "jobs")
+ self.add_attribute(self.jobs)
+
+ def process(self, session):
+ value = Job.select().count()
+ self.jobs.set(session, value)
+ super(PoolStatSet, self).process(session)
+
+ def render_rate_text(self, session, args):
+ return "Percentage"
+
+ def render_item_name(self, session, args):
+ stat = args[0]
+ return stat.name
+
+ def render_item_value(self, session, args):
+ stat = args[0]
+ if stat.name == "Jobs":
+ return self.jobs.get(session)
+ else:
+ state = stat.name
+ value = self.get_value(state)
+ return value
+
+ def get_value(self, state):
+ where = "job_status = %i" % JobStatusInfo.get_status_int(state)
+ return Job.select(where).count()
+
+ def render_item_rate(self, session, stat):
+ jobs = self.jobs.get(session)
+ state = stat[0].name
+ if state == "Jobs":
+ value = jobs
+ else:
+ value = self.get_value(state)
+ percent = (value*1.0) / (jobs*1.0) * 100.0
+ return jobs and "%2.1f" % percent or "-"
+
+
class PoolStatus(CuminStatus):
def render_status(self, session, pool):
return "Active"
Modified: mgmt/trunk/cumin/python/cumin/pool.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/pool.strings 2008-10-10 12:49:25 UTC (rev 2614)
+++ mgmt/trunk/cumin/python/cumin/pool.strings 2008-10-10 13:12:22 UTC (rev 2615)
@@ -14,3 +14,9 @@
<div>{status}</div>
</div>
+
+[PoolStats.html]
+ <h2>General</h2>
+ <div style="width:50%;">
+ {general}
+ </div>