def test_stats(self): D = self.db('db - stats', 'FileStorage:::::db-stats') D.open() connection, root = D.connect() D.start_transaction() for i in range(0, 10): root['key%i' % i] = 'data%i' % i D.commit() D.close() D.open() connection, root = D.connect() D.start_transaction() for i in range(0, 10): _ = root['key%i' % i] D.commit() D.update_stats() with STATS: stats_snapshot = STATS.snapshot() import pprint pprint.pprint(stats_snapshot) db_key = 'Database (db - stats)' IN(db_key, stats_snapshot) for e in ['Caches', 'Connections', 'Loads', 'Stores']: IN(e, stats_snapshot[db_key]) LEQ(stats_snapshot[db_key]['Caches'], 1) LEQ(stats_snapshot[db_key]['Connections'], 1)
def snapshot_stats(self): with STATS: snapshot = STATS.snapshot() return hlib.api.Reply(200, snapshot = snapshot)
def index(self): with STATS: snapshot = STATS.snapshot() return self.generate('monitor.mako', params = {'stats': snapshot})