summaryrefslogtreecommitdiffstats
path: root/retiolum/scripts/adv_graphgen/tinc_stats/Log2JSON.py
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2014-01-14 01:05:59 +0100
committermakefu <github@syntax-fehler.de>2014-01-14 01:05:59 +0100
commit849fc0a0542ca985acd3edf1071ff49fe77492b6 (patch)
tree32e031009f45b72e3e281bb3205b2c0bc8b95cfb /retiolum/scripts/adv_graphgen/tinc_stats/Log2JSON.py
parentebf0f1c48a4c771cb3caf4126064d89d14272c40 (diff)
tinc_stats: Log2JSON is now working under py3k and py2
Diffstat (limited to 'retiolum/scripts/adv_graphgen/tinc_stats/Log2JSON.py')
-rwxr-xr-xretiolum/scripts/adv_graphgen/tinc_stats/Log2JSON.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/retiolum/scripts/adv_graphgen/tinc_stats/Log2JSON.py b/retiolum/scripts/adv_graphgen/tinc_stats/Log2JSON.py
index adc869fb..a81e2bef 100755
--- a/retiolum/scripts/adv_graphgen/tinc_stats/Log2JSON.py
+++ b/retiolum/scripts/adv_graphgen/tinc_stats/Log2JSON.py
@@ -41,11 +41,6 @@ def debug(func):
return with_debug
-def get_tinc_log_file():
- # TODO parse logfile from somewhere
- return os.environ.get("LOG_FILE","/var/log/everything.log")
-
-
def parse_tinc_stats():
import subprocess
from time import sleep
@@ -89,13 +84,16 @@ def get_tinc_block(log_file):
def parse_new_input(tinc_bin):
nodes = {}
- pnodes = subprocess.Popen([tinc_bin,"-n",TINC_NETWORK,"dump","reachable","nodes"], stdout=subprocess.PIPE).communicate()[0]
+ pnodes = subprocess.Popen(
+ [tinc_bin,"-n",TINC_NETWORK,"dump","reachable","nodes"],
+ stdout=subprocess.PIPE).communicate()[0].decode()
#pnodes = subprocess.check_output(["tincctl","-n",TINC_NETWORK,"dump","reachable","nodes"])
for line in pnodes.split('\n'):
if not line: continue
l = line.split()
nodes[l[0]]= { 'external-ip': l[2], 'external-port' : l[4] }
- psubnets = subprocess.check_output([tinc_bin,"-n",TINC_NETWORK,"dump","subnets"])
+ psubnets = subprocess.check_output(
+ [tinc_bin,"-n",TINC_NETWORK,"dump","subnets"]).decode()
for line in psubnets.split('\n'):
if not line: continue
l = line.split()
@@ -105,12 +103,13 @@ def parse_new_input(tinc_bin):
nodes[l[2]]['internal-ip'].append(l[0].split('#')[0])
except KeyError:
pass # node does not exist (presumably)
- pedges = subprocess.check_output([tinc_bin,"-n",TINC_NETWORK,"dump","edges"])
+ pedges = subprocess.check_output(
+ [tinc_bin,"-n",TINC_NETWORK,"dump","edges"]).decode()
for line in pedges.split('\n'):
if not line: continue
l = line.split()
try:
- if not nodes[l[0]].has_key('to') :
+ if not 'to' in nodes[l[0]] :
nodes[l[0]]['to'] = []
nodes[l[0]]['to'].append(
{'name':l[2],'addr':l[4],'port':l[6],'weight' : l[10] })