Author: justi9
Date: 2010-05-17 17:54:31 -0400 (Mon, 17 May 2010)
New Revision: 3975
Modified:
mgmt/newdata/mint/python/mint/session.py
mgmt/newdata/mint/python/mint/update.py
Log:
Improve stat reporting; fix agent reference
Modified: mgmt/newdata/mint/python/mint/session.py
===================================================================
--- mgmt/newdata/mint/python/mint/session.py 2010-05-17 18:25:44 UTC (rev 3974)
+++ mgmt/newdata/mint/python/mint/session.py 2010-05-17 21:54:31 UTC (rev 3975)
@@ -112,10 +112,8 @@
self.model.app.update_thread.enqueue(up)
def objectStats(self, broker, obj):
- print "objectStats!", broker, obj
+ agent = self.model.get_agent(obj._agent)
- agent = self.get_agent(obj._agent)
-
if self.model.app.update_thread.isAlive():
up = ObjectAddSample(self.model, agent, obj)
self.model.app.update_thread.enqueue(up)
Modified: mgmt/newdata/mint/python/mint/update.py
===================================================================
--- mgmt/newdata/mint/python/mint/update.py 2010-05-17 18:25:44 UTC (rev 3974)
+++ mgmt/newdata/mint/python/mint/update.py 2010-05-17 21:54:31 UTC (rev 3975)
@@ -11,16 +11,15 @@
def __init__(self, app):
super(UpdateThread, self).__init__(app)
+ self.updates = ConcurrentQueue()
+
+ self.stats = UpdateStats(self.app)
self.conn = None
- self.stats = None
- self.updates = ConcurrentQueue()
-
self.halt_on_error = True
def init(self):
self.conn = self.app.database.get_connection()
- self.stats = UpdateStats()
def enqueue(self, update):
update.thread = self
@@ -54,12 +53,12 @@
class UpdateStats(object):
names = ("Enqueued", "Dequeued", "Updated",
"Deleted", "Dropped")
headings = ("%8s " * 5) % names
- rates_fmt = "%8.1f " * 5
+ rates_fmt = ("%8.1f " * 5)
then = None
now = None
- def __init__(self):
+ def __init__(self, app):
self.enqueued = 0
self.dequeued = 0
@@ -89,17 +88,20 @@
if not self.then:
return
- values = (self.now.enqueued - self.then.enqueued,
+ values = [self.now.enqueued - self.then.enqueued,
self.now.dequeued - self.then.dequeued,
self.now.updated - self.then.updated,
self.now.deleted - self.then.deleted,
- self.now.dropped - self.then.dropped)
+ self.now.dropped - self.then.dropped]
+ # XXX
+ values[2] += self.now.samples_updated - self.then.samples_updated
+ values[4] += self.now.samples_dropped - self.then.samples_dropped
+
secs = self.now.time - self.then.time
+ rates = map(lambda x: x / secs, values)
- rates = tuple(map(lambda x: x / secs, values))
-
- print self.rates_fmt % rates
+ print self.rates_fmt % tuple(rates)
class Update(object):
def __init__(self, model):
@@ -374,7 +376,7 @@
cursor.close()
stats.samples_updated += 1
-
+
def process_samples(self, obj, update_columns, insert_columns):
for stat, value in self.object.getStatistics():
try:
Show replies by date