Fixes a type error (nodes is no dict any longer, error was: AttributeError: 'list' object has no attribute 'items')
parent
3b8308722f
commit
d9bc7eb9a1
18
lib/rrddb.py
18
lib/rrddb.py
|
@ -28,15 +28,15 @@ class RRD(object):
|
||||||
os.mkdir(self.imagePath)
|
os.mkdir(self.imagePath)
|
||||||
|
|
||||||
def update_database(self, nodes):
|
def update_database(self, nodes):
|
||||||
online_nodes = dict(filter(
|
node_count = 0
|
||||||
lambda d: d[1]['flags']['online'], nodes.items()))
|
client_count = 0
|
||||||
client_count = sum(map(
|
for node in nodes:
|
||||||
lambda d: d['statistics']['clients'], online_nodes.values()))
|
if node['flags']['online']:
|
||||||
|
node_count += 1
|
||||||
self.globalDb.update(len(online_nodes), client_count)
|
client_count += node['statistics']['clients']
|
||||||
for node_id, node in online_nodes.items():
|
rrd = NodeRRD(os.path.join(self.dbPath, node['nodeinfo']['node_id'] + '.rrd'), node)
|
||||||
rrd = NodeRRD(os.path.join(self.dbPath, node_id + '.rrd'), node)
|
rrd.update()
|
||||||
rrd.update()
|
self.globalDb.update(node_count, client_count)
|
||||||
|
|
||||||
def update_images(self):
|
def update_images(self):
|
||||||
self.globalDb.graph(os.path.join(self.imagePath, "globalGraph.png"),
|
self.globalDb.graph(os.path.join(self.imagePath, "globalGraph.png"),
|
||||||
|
|
Loading…
Reference in New Issue