summaryrefslogtreecommitdiffstats
path: root/retiolum/scripts/adv_graphgen/tinc_stats/Log2JSON.py
diff options
context:
space:
mode:
Diffstat (limited to 'retiolum/scripts/adv_graphgen/tinc_stats/Log2JSON.py')
-rwxr-xr-xretiolum/scripts/adv_graphgen/tinc_stats/Log2JSON.py42
1 files changed, 1 insertions, 41 deletions
diff --git a/retiolum/scripts/adv_graphgen/tinc_stats/Log2JSON.py b/retiolum/scripts/adv_graphgen/tinc_stats/Log2JSON.py
index 644cbc63..adc869fb 100755
--- a/retiolum/scripts/adv_graphgen/tinc_stats/Log2JSON.py
+++ b/retiolum/scripts/adv_graphgen/tinc_stats/Log2JSON.py
@@ -57,12 +57,6 @@ def parse_tinc_stats():
elif which("tincctl"):
return parse_new_input("tincctl")
#old tinc
- elif which("tincd"):
- # TODO refactor me
- subprocess.call(["pkill","-SIGUSR2", "tincd"])
- sleep(1)
- return parse_input(get_tinc_block(get_tinc_log_file()))
- #no tinc
else:
raise Exception("no tinc executable found!")
@@ -124,43 +118,9 @@ def parse_new_input(tinc_bin):
pass #node does not exist
return nodes
-#@debug
-def parse_input(log_data):
- nodes={}
- for line in log_data:
- if BEGIN_NODES in line :
- nodes={}
- for line in log_data:
- if END_NODES in line :
- break
- l = line.replace('\n','').split() #TODO unhack me
- nodes[l[0]]= { 'external-ip': l[2], 'external-port' : l[4] }
- if BEGIN_SUBNET in line :
- for line in log_data:
- if END_SUBNET in line :
- break
- l = line.replace('\n','').split()
- if not nodes[l[2]].get('internal-ip',False):
- nodes[l[2]]['internal-ip'] = []
- nodes[l[2]]['internal-ip'].append(l[0].split('#')[0])
- if BEGIN_EDGES in line :
- edges = {}
- for line in log_data:
- if END_EDGES in line :
- break
- l = line.replace('\n','').split()
- if not nodes[l[0]].has_key('to') :
- nodes[l[0]]['to'] = []
- nodes[l[0]]['to'].append(
- {'name':l[2],'addr':l[4],'port':l[6],'weight' : l[10] })
- return nodes
-
-
if __name__ == '__main__':
- # TODO refactor me
from sys import argv
if len(argv) > 1:
usage()
else:
- print json.dumps(parse_tinc_stats())
-
+ print (json.dumps(parse_tinc_stats()))