fix rrd
parent
2dfd11189d
commit
0d71de7091
|
@ -30,7 +30,7 @@ class NodeRRD(RRD):
|
||||||
return os.path.basename(self.filename).rsplit('.', 2)[0] + ".png"
|
return os.path.basename(self.filename).rsplit('.', 2)[0] + ".png"
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
super().update({'upstate': 1, 'clients': self.node.clients})
|
super().update({'upstate': 1, 'clients': self.node.clientcount})
|
||||||
|
|
||||||
def graph(self, directory, timeframe):
|
def graph(self, directory, timeframe):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -31,8 +31,6 @@ class batman:
|
||||||
output = subprocess.check_output(["batctl","-m",self.mesh_interface,"vd","json","-n"])
|
output = subprocess.check_output(["batctl","-m",self.mesh_interface,"vd","json","-n"])
|
||||||
lines = output.splitlines()
|
lines = output.splitlines()
|
||||||
vds = self.vis_data_helper(lines)
|
vds = self.vis_data_helper(lines)
|
||||||
for vd in vds:
|
|
||||||
vd['legacy'] = True
|
|
||||||
return vds
|
return vds
|
||||||
|
|
||||||
def vis_data_batadv_vis(self):
|
def vis_data_batadv_vis(self):
|
||||||
|
|
|
@ -91,8 +91,6 @@ class NodeDB:
|
||||||
node = Node()
|
node = Node()
|
||||||
node.lastseen = self.time
|
node.lastseen = self.time
|
||||||
node.flags['online'] = True
|
node.flags['online'] = True
|
||||||
if 'legacy' in x:
|
|
||||||
node.flags['legacy'] = True
|
|
||||||
self._nodes.append(node)
|
self._nodes.append(node)
|
||||||
|
|
||||||
node.add_mac(x['of'])
|
node.add_mac(x['of'])
|
||||||
|
@ -110,8 +108,6 @@ class NodeDB:
|
||||||
node = Node()
|
node = Node()
|
||||||
node.lastseen = self.time
|
node.lastseen = self.time
|
||||||
node.flags['online'] = True
|
node.flags['online'] = True
|
||||||
if 'legacy' in x:
|
|
||||||
node.flags['legacy'] = True
|
|
||||||
node.add_mac(x['router'])
|
node.add_mac(x['router'])
|
||||||
self._nodes.append(node)
|
self._nodes.append(node)
|
||||||
|
|
||||||
|
|
18
rrd.py
18
rrd.py
|
@ -28,23 +28,7 @@ class rrd:
|
||||||
|
|
||||||
def update_database(self,db):
|
def update_database(self,db):
|
||||||
nodes = {}
|
nodes = {}
|
||||||
clientCount = 0
|
clientCount = sum(map(lambda d: d.clientcount, db.get_nodes()))
|
||||||
for node in db.get_nodes():
|
|
||||||
if node.flags['online']:
|
|
||||||
if not node.flags['client']:
|
|
||||||
nodes[node.id] = node
|
|
||||||
node.clients = 0;
|
|
||||||
if 'legacy' in node.flags and node.flags['legacy']:
|
|
||||||
clientCount -= 1
|
|
||||||
else:
|
|
||||||
clientCount += 1
|
|
||||||
for link in db.get_links():
|
|
||||||
source = link.source.interface
|
|
||||||
target = link.target.interface
|
|
||||||
if source in nodes and not target in nodes:
|
|
||||||
nodes[source].clients += 1
|
|
||||||
elif target in nodes and not source in nodes:
|
|
||||||
nodes[target].clients += 1
|
|
||||||
|
|
||||||
self.globalDb.update(len(nodes), clientCount)
|
self.globalDb.update(len(nodes), clientCount)
|
||||||
for node in nodes.values():
|
for node in nodes.values():
|
||||||
|
|
Loading…
Reference in New Issue