Author: justi9
Date: 2007-10-29 17:57:49 -0400 (Mon, 29 Oct 2007)
New Revision: 1183
Added:
mgmt/lib/python/
mgmt/misc/mint-test.py
Modified:
mgmt/cumin/python/cumin/demo.py
mgmt/cumin/python/cumin/model.py
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/queue.strings
Log:
In a temporarily useless fashion, connects queue statistics to real
data.
Modified: mgmt/cumin/python/cumin/demo.py
===================================================================
--- mgmt/cumin/python/cumin/demo.py 2007-10-29 15:03:14 UTC (rev 1182)
+++ mgmt/cumin/python/cumin/demo.py 2007-10-29 21:57:49 UTC (rev 1183)
@@ -187,6 +187,10 @@
mobject.unlock()
def frob_measure(self, measure):
+ # XXX if the class_ is set, we are using real data
+ if measure.class_:
+ return
+
if measure.type == "int":
if random() < 0.5:
if random() < 0.66:
Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py 2007-10-29 15:03:14 UTC (rev 1182)
+++ mgmt/cumin/python/cumin/model.py 2007-10-29 21:57:49 UTC (rev 1183)
@@ -1,5 +1,6 @@
from wooly import *
from wooly.model import *
+from schema import *
class CuminModel(Model):
def __init__(self):
@@ -309,13 +310,14 @@
writer.write("</realm>")
class Measurement(object):
- def __init__(self, name, type):
+ def __init__(self, name, type, class_=None):
self.name = name
self.type = type
self.categories = ()
self.title = None
self.__value = None
self.values = list()
+ self.class_ = class_
self.highlow = False
self.__high = None
@@ -343,7 +345,11 @@
self.__low = value
def get_value(self):
- return self.__value
+ if self.class_:
+ stats = self.class_.select()[1]
+ return getattr(stats, self.name, None)
+ else:
+ return self.__value
def get_high(self):
return self.__high
@@ -371,45 +377,45 @@
# General
- measure = Measurement("msgDepth", "int")
+ measure = Measurement("msgDepth", "int", MgmtQueueStats)
measure.title = "Message depth"
measure.categories = ("message", "general")
measure.highlow = True
self.measurements.append(measure)
- measure = Measurement("msgTotalEnqueues", "int")
+ measure = Measurement("msgTotalEnqueues", "int",
MgmtQueueStats)
measure.title = "Messages enqueued"
measure.categories = ("message", "general")
self.measurements.append(measure)
- measure = Measurement("msgTotalDequeues", "int")
+ measure = Measurement("msgTotalDequeues", "int",
MgmtQueueStats)
measure.title = "Messages dequeued"
measure.categories = ("message", "general")
self.measurements.append(measure)
- measure = Measurement("byteDepth", "int")
+ measure = Measurement("byteDepth", "int", MgmtQueueStats)
measure.title = "Byte depth"
measure.categories = ("byte", "general")
measure.highlow = True
self.measurements.append(measure)
- measure = Measurement("byteTotalEnqueues", "int")
+ measure = Measurement("byteTotalEnqueues", "int",
MgmtQueueStats)
measure.title = "Bytes enqueued"
measure.categories = ("byte", "general")
self.measurements.append(measure)
- measure = Measurement("byteTotalDequeues", "int")
+ measure = Measurement("byteTotalDequeues", "int",
MgmtQueueStats)
measure.title = "Bytes dequeued"
measure.categories = ("byte", "general")
self.measurements.append(measure)
- measure = Measurement("consumers", "int")
+ measure = Measurement("consumers", "int", MgmtQueueStats)
measure.title = "Consumers"
measure.categories = ("general")
measure.highlow = True
self.measurements.append(measure)
- measure = Measurement("unackedMessages", "int")
+ measure = Measurement("unackedMessages", "int",
MgmtQueueStats)
measure.title = "Unacknowledged messages"
measure.categories = ("general")
self.measurements.append(measure)
@@ -421,7 +427,7 @@
#measure.categories = ("disk")
#self.measurements.append(measure)
- measure = Measurement("diskPages", "int")
+ measure = Measurement("diskPages", "int", MgmtQueueStats)
measure.title = "Disk pages"
measure.categories = ("general")
self.measurements.append(measure)
@@ -433,63 +439,63 @@
# Transactional
- measure = Measurement("msgTxEnqueues", "int")
+ measure = Measurement("msgTxEnqueues", "int",
MgmtQueueStats)
measure.title = "Messages enqueued"
measure.categories = ("message", "transactional")
self.measurements.append(measure)
- measure = Measurement("msgTxDequeues", "int")
+ measure = Measurement("msgTxDequeues", "int",
MgmtQueueStats)
measure.title = "Messages dequeued"
measure.categories = ("message", "transactional")
self.measurements.append(measure)
- measure = Measurement("byteTxEnqueues", "int")
+ measure = Measurement("byteTxEnqueues", "int",
MgmtQueueStats)
measure.title = "Bytes enqueued"
measure.categories = ("byte", "transactional")
self.measurements.append(measure)
- measure = Measurement("byteTxDequeues", "int")
+ measure = Measurement("byteTxDequeues", "int",
MgmtQueueStats)
measure.title = "Bytes dequeued"
measure.categories = ("byte", "transactional")
self.measurements.append(measure)
- measure = Measurement("enqueueTxStarts", "int")
+ measure = Measurement("enqueueTxStarts", "int",
MgmtQueueStats)
measure.title = "Enq. trans. started"
measure.categories = ("transaction")
self.measurements.append(measure)
- measure = Measurement("enqueueTxCommits", "int")
+ measure = Measurement("enqueueTxCommits", "int",
MgmtQueueStats)
measure.title = "Enq. trans. committed"
measure.categories = ("transaction")
self.measurements.append(measure)
- measure = Measurement("enqueueTxRejects", "int")
+ measure = Measurement("enqueueTxRejects", "int",
MgmtQueueStats)
measure.title = "Enq. trans. rejected"
measure.categories = ("transaction")
self.measurements.append(measure)
- measure = Measurement("enqueueTxCount", "int")
+ measure = Measurement("enqueueTxCount", "int",
MgmtQueueStats)
measure.title = "Enq. trans. pending"
measure.categories = ("transaction")
measure.highlow = True
self.measurements.append(measure)
- measure = Measurement("dequeueTxStarts", "int")
+ measure = Measurement("dequeueTxStarts", "int",
MgmtQueueStats)
measure.title = "Deq. trans. started"
measure.categories = ("transaction")
self.measurements.append(measure)
- measure = Measurement("dequeueTxCommits", "int")
+ measure = Measurement("dequeueTxCommits", "int",
MgmtQueueStats)
measure.title = "Deq. trans. committed"
measure.categories = ("transaction")
self.measurements.append(measure)
- measure = Measurement("dequeueTxRejects", "int")
+ measure = Measurement("dequeueTxRejects", "int",
MgmtQueueStats)
measure.title = "Deq. trans. rejected"
measure.categories = ("transaction")
self.measurements.append(measure)
- measure = Measurement("dequeueTxCount", "int")
+ measure = Measurement("dequeueTxCount", "int",
MgmtQueueStats)
measure.title = "Deq. trans. pending"
measure.categories = ("transaction")
measure.highlow = True
@@ -497,22 +503,22 @@
# Persistent
- measure = Measurement("msgPersistEnqueues", "int")
+ measure = Measurement("msgPersistEnqueues", "int",
MgmtQueueStats)
measure.title = "Messages enqueued"
measure.categories = ("message", "persistent")
self.measurements.append(measure)
- measure = Measurement("msgPersistDequeues", "int")
+ measure = Measurement("msgPersistDequeues", "int",
MgmtQueueStats)
measure.title = "Messages dequeued"
measure.categories = ("message", "persistent")
self.measurements.append(measure)
- measure = Measurement("bytePersistEnqueues", "int")
+ measure = Measurement("bytePersistEnqueues", "int",
MgmtQueueStats)
measure.title = "Bytes enqueued"
measure.categories = ("byte", "persistent")
self.measurements.append(measure)
- measure = Measurement("bytePersistDequeues", "int")
+ measure = Measurement("bytePersistDequeues", "int",
MgmtQueueStats)
measure.title = "Bytes dequeued"
measure.categories = ("byte", "persistent")
self.measurements.append(measure)
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-10-29 15:03:14 UTC (rev 1182)
+++ mgmt/cumin/python/cumin/queue.py 2007-10-29 21:57:49 UTC (rev 1183)
@@ -9,6 +9,8 @@
from parameters import *
from util import *
+from schema import *
+
strings = StringCatalog(__file__)
class QueueXmlPage(Page):
@@ -353,6 +355,10 @@
self.add_tab(self.StatisticsCurrent(app, "current"))
self.add_tab(self.StatisticsHistory(app, "history"))
+ def render_something(self, session, queue):
+ statses = MgmtQueueStats.select()
+ stats = statses[0]
+
def render_title(self, session, queue):
return "Statistics"
Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings 2007-10-29 15:03:14 UTC (rev 1182)
+++ mgmt/cumin/python/cumin/queue.strings 2007-10-29 21:57:49 UTC (rev 1183)
@@ -185,6 +185,7 @@
</script>
[QueueStatistics.html]
+<p>{something}</p>
<ul class="radiotabs tabs">{tabs}</ul>
<div class="radiotabs mode">{mode}</div>
Added: mgmt/misc/mint-test.py
===================================================================
--- mgmt/misc/mint-test.py (rev 0)
+++ mgmt/misc/mint-test.py 2007-10-29 21:57:49 UTC (rev 1183)
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+from qpid.management import ManagedBroker
+from time import sleep
+from schema import *
+from datetime import *
+from sqlobject import *
+
+conn = connectionForURI("postgresql://jross@localhost/mint")
+sqlhub.processConnection = conn
+
+def configElement(broker, oid, list, timestamps):
+ if oid == 4:
+ print list
+
+ queue = MgmtQueue()
+ d = dict(list)
+ queue.set(**d)
+ recOn = datetime.fromtimestamp(timestamps[0]/1000000000)
+ createdOn = datetime.fromtimestamp(timestamps[1]/1000000000)
+ queue.set(recTime=recOn,creationTime=createdOn)
+ print queue.id
+ print " -> " + d["name"]
+
+def instElement(broker, oid, list, timestamps):
+ if oid == 4:
+ print list
+ d = dict(list)
+ queues = MgmtQueue.selectBy(name=d["name"])[:1]
+ del d["name"]
+ queue = queues[0]
+ d["mgmtQueue"] = queue.id
+ recOn = datetime.fromtimestamp(timestamps[0]/1000000000)
+ queueStats = MgmtQueueStats()
+ queueStats.set(recTime=recOn)
+ queueStats.set(**d)
+ if (timestamps[2] != 0):
+ deletedOn = datetime.fromtimestamp(timestamps[2]/1000000000)
+ queue.set(deletionTime=deletedOn)
+ print queue.id
+# print " -> " + d["name"]
+
+
+target1 = ManagedBroker (host="dhcp83-108.boston.redhat.com", port=10001)
+target1.configListener("172.16.83.108:10001", configElement)
+target1.instrumentationListener ("172.16.83.108:10001", instElement)
+
+target1.start ()
+
+while 1:
+ sleep (1)
+
+