Author: justi9
Date: 2007-11-21 12:32:03 -0500 (Wed, 21 Nov 2007)
New Revision: 1352
Modified:
mgmt/cumin/python/cumin/client.py
mgmt/cumin/python/cumin/exchange.py
mgmt/cumin/python/cumin/model.py
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/widgets.py
Log:
Restores charts. They now use the new model data.
In order to do this, refactored the stats ui metadata.
Modified: mgmt/cumin/python/cumin/client.py
===================================================================
--- mgmt/cumin/python/cumin/client.py 2007-11-21 16:08:04 UTC (rev 1351)
+++ mgmt/cumin/python/cumin/client.py 2007-11-21 17:32:03 UTC (rev 1352)
@@ -143,11 +143,11 @@
return "History"
def render_produced_chart_url(self, session, client):
- return "client.png?id=%i;m=msgsProduced;m=bytesProduced" \
+ return "client.png?id=%i;s=msgsProduced;s=bytesProduced" \
% client.id
def render_consumed_chart_url(self, session, client):
- return "client.png?id=%i;m=msgsConsumed;m=bytesConsumed" \
+ return "client.png?id=%i;s=msgsConsumed;s=bytesConsumed" \
% client.id
class ClientSessionSet(ItemSet):
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2007-11-21 16:08:04 UTC (rev 1351)
+++ mgmt/cumin/python/cumin/exchange.py 2007-11-21 17:32:03 UTC (rev 1352)
@@ -356,13 +356,13 @@
return "History"
def render_received_chart_url(self, session, queue):
- return "exchange.png?id=%i;m=msgReceives;m=byteReceives" %
queue.id
+ return "exchange.png?id=%i;s=msgReceives;s=byteReceives" %
queue.id
def render_dropped_chart_url(self, session, queue):
- return "exchange.png?id=%i;m=msgDrops;byteDrops" % queue.id
+ return "exchange.png?id=%i;s=msgDrops;s=byteDrops" % queue.id
def render_routed_chart_url(self, session, queue):
- return "exchange.png?id=%i;m=msgRoutes;m=byteRoutes" \
+ return "exchange.png?id=%i;s=msgRoutes;s=byteRoutes" \
% queue.id
class ExchangeProducerSet(ItemSet):
Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py 2007-11-21 16:08:04 UTC (rev 1351)
+++ mgmt/cumin/python/cumin/model.py 2007-11-21 17:32:03 UTC (rev 1352)
@@ -8,7 +8,7 @@
def __init__(self):
self.classes = dict()
- self.queue = CuminQueue()
+ self.queue = CuminQueue(self)
self.add_class(self.queue)
def add_class(self, cls):
@@ -18,11 +18,15 @@
return self.classes[mint_object.__class__]
class CuminClass(object):
- def __init__(self, mint_class):
+ def __init__(self, model, mint_class):
+ self.model = model
self.mint_class = mint_class
+ self.mint_stats_class = None
self.stats = list()
+ self.model.add_class(self)
+
def add_stat(self, stat):
self.stats.append(stat)
@@ -40,18 +44,34 @@
stat.write_xml(object, writer)
class CuminStat(object):
- def __init__(self, name, unit, title=None, categories=()):
+ def __init__(self, cls, name, type):
+ self.model = cls.model
+ self.cumin_class = cls
self.name = name
- self.unit = unit
+ self.type = type
+ self.unit = None
self.title = None
- self.categories = categories
+ self.categories = ()
self.link_cb = None
self.highlow = False
+ self.cumin_class.add_stat(self)
+
def value(self, object):
return nvl(getattr(object.stats, self.name), -1)
+ def values(self, object, limit=None):
+ cls = self.cumin_class.mint_stats_class
+ stats = cls.select(orderBy="-id")[:limit]
+ values = list()
+
+ for stat in stats:
+ value = getattr(stat, self.name)
+ values.append(value)
+
+ return values
+
def rate(self, object):
if object.stats:
curr = getattr(object.stats, self.name)
@@ -75,186 +95,160 @@
self.rate(object) or 0))
class CuminQueue(CuminClass):
- def __init__(self):
- super(CuminQueue, self).__init__(mint.Queue)
+ def __init__(self, model):
+ super(CuminQueue, self).__init__(model, mint.Queue)
- stat = CuminStat("consumers", "int")
+ self.mint_stats_class = mint.QueueStats
+
+ stat = CuminStat(self, "consumers", "int")
stat.title = "Consumers"
stat.unit = "consumer"
stat.categories = ("general")
stat.highlow = True
- self.add_stat(stat)
- stat = CuminStat("bindings", "int")
+ stat = CuminStat(self, "bindings", "int")
stat.title = "Bindings"
stat.unit = "binding"
stat.categories = ("general")
stat.highlow = True
- self.add_stat(stat)
- stat = CuminStat("msgDepth", "int")
+ stat = CuminStat(self, "msgDepth", "int")
stat.title = "Message Depth"
stat.unit = "message"
stat.categories = ("message", "general")
stat.highlow = True
- self.add_stat(stat)
- stat = CuminStat("msgTotalEnqueues", "int")
+ stat = CuminStat(self, "msgTotalEnqueues", "int")
stat.title = "Msgs. Enqueued"
stat.unit = "message"
stat.categories = ("message", "general")
- self.add_stat(stat)
- stat = CuminStat("msgTotalDequeues", "int")
+ stat = CuminStat(self, "msgTotalDequeues", "int")
stat.title = "Msgs. Dequeued"
stat.unit = "message"
stat.categories = ("message", "general")
- self.add_stat(stat)
- stat = CuminStat("byteDepth", "int")
+ stat = CuminStat(self, "byteDepth", "int")
stat.title = "Byte Depth"
stat.unit = "byte"
stat.categories = ("byte", "general")
stat.highlow = True
- self.add_stat(stat)
- stat = CuminStat("byteTotalEnqueues", "int")
+ stat = CuminStat(self, "byteTotalEnqueues", "int")
stat.title = "Bytes Enqueued"
stat.unit = "byte"
stat.categories = ("byte", "general")
- self.add_stat(stat)
- stat = CuminStat("byteTotalDequeues", "int")
+ stat = CuminStat(self, "byteTotalDequeues", "int")
stat.title = "Bytes Dequeued"
stat.unit = "byte"
stat.categories = ("byte", "general")
- self.add_stat(stat)
- stat = CuminStat("unackedMessages", "int")
+ stat = CuminStat(self, "unackedMessages", "int")
stat.title = "Msgs. Unacked"
stat.unit = "message"
stat.categories = ("general")
- self.add_stat(stat)
# Disk
- #stat = CuminStat("diskPageSize", "int")
+ #stat = CuminStat(self, "diskPageSize", "int")
#stat.title = "Page size"
#stat.categories = ("disk")
- #self.add_stat(stat)
- stat = CuminStat("diskPages", "int")
+ stat = CuminStat(self, "diskPages", "int")
stat.title = "Disk Pages"
stat.unit = "page"
stat.categories = ("general")
- self.add_stat(stat)
- #stat = CuminStat("diskAvailableSize", "int")
+ #stat = CuminStat(self, "diskAvailableSize", "int")
#stat.title = "Available size"
#stat.categories = ("disk")
- #self.add_stat(stat)
# Transactional
- stat = CuminStat("msgTxnEnqueues", "int")
+ stat = CuminStat(self, "msgTxnEnqueues", "int")
stat.title = "Msgs. Enqueued"
stat.unit = "message"
stat.categories = ("message", "transactional")
- self.add_stat(stat)
- stat = CuminStat("msgTxnDequeues", "int")
+ stat = CuminStat(self, "msgTxnDequeues", "int")
stat.title = "Msgs. Dequeued"
stat.unit = "message"
stat.categories = ("message", "transactional")
- self.add_stat(stat)
- stat = CuminStat("byteTxnEnqueues", "int")
+ stat = CuminStat(self, "byteTxnEnqueues", "int")
stat.title = "Bytes Enqueued"
stat.unit = "byte"
stat.categories = ("byte", "transactional")
- self.add_stat(stat)
- stat = CuminStat("byteTxnDequeues", "int")
+ stat = CuminStat(self, "byteTxnDequeues", "int")
stat.title = "Bytes Dequeued"
stat.unit = "byte"
stat.categories = ("byte", "transactional")
- self.add_stat(stat)
- stat = CuminStat("enqueueTxnStarts", "int")
+ stat = CuminStat(self, "enqueueTxnStarts", "int")
stat.title = "Enq. Trans. Started"
stat.unit = "transaction"
stat.categories = ("transaction")
- self.add_stat(stat)
- stat = CuminStat("enqueueTxnCommits", "int")
+ stat = CuminStat(self, "enqueueTxnCommits", "int")
stat.title = "Enq. Trans. Committed"
stat.unit = "transaction"
stat.categories = ("transaction")
- self.add_stat(stat)
- stat = CuminStat("enqueueTxnRejects", "int")
+ stat = CuminStat(self, "enqueueTxnRejects", "int")
stat.title = "Enq. Trans. Rejected"
stat.unit = "transaction"
stat.categories = ("transaction")
- self.add_stat(stat)
- stat = CuminStat("enqueueTxnCount", "int")
+ stat = CuminStat(self, "enqueueTxnCount", "int")
stat.title = "Enq. Trans. Pending"
stat.unit = "transaction"
stat.categories = ("transaction")
stat.highlow = True
- self.add_stat(stat)
- stat = CuminStat("dequeueTxnStarts", "int")
+ stat = CuminStat(self, "dequeueTxnStarts", "int")
stat.title = "Deq. Trans. Started"
stat.unit = "transaction"
stat.categories = ("transaction")
- self.add_stat(stat)
- stat = CuminStat("dequeueTxnCommits", "int")
+ stat = CuminStat(self, "dequeueTxnCommits", "int")
stat.title = "Deq. Trans. Committed"
stat.unit = "transaction"
stat.categories = ("transaction")
- self.add_stat(stat)
- stat = CuminStat("dequeueTxnRejects", "int")
+ stat = CuminStat(self, "dequeueTxnRejects", "int")
stat.title = "Deq. Trans. Rejected"
stat.unit = "transaction"
stat.categories = ("transaction")
- self.add_stat(stat)
- stat = CuminStat("dequeueTxnCount", "int")
+ stat = CuminStat(self, "dequeueTxnCount", "int")
stat.title = "Deq. Trans. Pending"
stat.unit = "transaction"
stat.categories = ("transaction")
stat.highlow = True
- self.add_stat(stat)
# Persistent
- stat = CuminStat("msgPersistEnqueues", "int")
+ stat = CuminStat(self, "msgPersistEnqueues", "int")
stat.title = "Msgs. Enqueued"
stat.unit = "message"
stat.categories = ("message", "persistent")
- self.add_stat(stat)
- stat = CuminStat("msgPersistDequeues", "int")
+ stat = CuminStat(self, "msgPersistDequeues", "int")
stat.title = "Msgs. Dequeued"
stat.unit = "message"
stat.categories = ("message", "persistent")
- self.add_stat(stat)
- stat = CuminStat("bytePersistEnqueues", "int")
+ stat = CuminStat(self, "bytePersistEnqueues", "int")
stat.title = "Bytes Enqueued"
stat.unit = "byte"
stat.categories = ("byte", "persistent")
- self.add_stat(stat)
- stat = CuminStat("bytePersistDequeues", "int")
+ stat = CuminStat(self, "bytePersistDequeues", "int")
stat.title = "Bytes Dequeued"
stat.unit = "byte"
stat.categories = ("byte", "persistent")
- self.add_stat(stat)
def write_xml(self, queue, writer):
writer.write("<queue id=\"%i\">" % queue.id)
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-11-21 16:08:04 UTC (rev 1351)
+++ mgmt/cumin/python/cumin/queue.py 2007-11-21 17:32:03 UTC (rev 1352)
@@ -474,13 +474,13 @@
return "History"
def render_depth_chart_url(self, session, queue):
- return "queue.png?id=%i;m=msgDepth;m=byteDepth" % queue.id
+ return "queue.png?id=%i;s=msgDepth;s=byteDepth" % queue.id
def render_consumers_chart_url(self, session, queue):
- return "queue.png?id=%i;m=consumers" % queue.id
+ return "queue.png?id=%i;s=consumers" % queue.id
def render_transactions_chart_url(self, session, queue):
- return "queue.png?id=%i;m=enqueueTxnCount;m=dequeueTxnCount" \
+ return "queue.png?id=%i;s=enqueueTxnCount;s=dequeueTxnCount" \
% queue.id
class QueueConsumerSet(ItemSet):
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2007-11-21 16:08:04 UTC (rev 1351)
+++ mgmt/cumin/python/cumin/widgets.py 2007-11-21 17:32:03 UTC (rev 1352)
@@ -158,8 +158,8 @@
self.iparam = Parameter(app, "param")
self.add_parameter(self.iparam)
- self.measurements = ListParameter(app, "m", self.iparam)
- self.add_parameter(self.measurements)
+ self.stats = ListParameter(app, "s", self.iparam)
+ self.add_parameter(self.stats)
def set_object_parameter(self, param):
self.__param = param
@@ -173,16 +173,16 @@
def do_render(self, session, object):
chart = LineChart(600, 120)
- measures = [object.get_measurement(x) \
- for x in self.measurements.get(session)]
+ cls = self.app.cmodel.get_class(object)
+ stats = [cls.get_stat(x) for x in self.stats.get(session)]
values = dict()
- for m in measures:
- values[m] = m.get_values(250)
+ for stat in stats:
+ values[stat] = stat.values(object, 121)
max_value = 0
- for m in measures:
- max_value = max(max(values[m]), max_value)
+ for stat in stats:
+ max_value = max(max(values[stat]), max_value)
max_value = max_value * 1.1
max_value = max_value + (100 - max_value % 100)
chart.set_max_value(int(max_value))
@@ -192,8 +192,8 @@
colors = ((1,0,0), (0,0,1), (0,1,0))
- for m, c in zip(measures, colors):
- chart.plot_values(values[m], color=c)
+ for stat, color in zip(stats, colors):
+ chart.plot_values(values[stat], color=color)
chart.plot_frame()