diff options
Diffstat (limited to 'retiolum/scripts/adv_graphgen/parse_tinc_stats.py')
-rwxr-xr-x | retiolum/scripts/adv_graphgen/parse_tinc_stats.py | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/retiolum/scripts/adv_graphgen/parse_tinc_stats.py b/retiolum/scripts/adv_graphgen/parse_tinc_stats.py index c676ad20..a255a918 100755 --- a/retiolum/scripts/adv_graphgen/parse_tinc_stats.py +++ b/retiolum/scripts/adv_graphgen/parse_tinc_stats.py @@ -3,12 +3,16 @@ from BackwardsReader import BackwardsReader import sys,json try: - import statsd -except: - print >>sys.stderr,'!! no statsd installed, try `pip install statsd`' - timer = statsd.Timer("graph.detail") - timer.start() - gauge = statsd.Gauge('graph.detail') + from time import time + import socket + host = "localhost" + port = 2003 + g_path = "retiolum" + begin = time() + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.connect((host,port)) +except Exception as e: + print >>sys.stderr, "Cannot connect to graphite: " + str(e) supernodes= [ "kaah","supernode","euer","pa_sharepoint","oxberg" ] """ TODO: Refactoring needed to pull the edges out of the node structures again, @@ -44,8 +48,12 @@ def write_stat_node(nodes): ''' num_conns = 0 num_nodes = len(nodes) - try: gauge.send('num_nodes',num_nodes) - except: pass + try: + msg = '%s.num_nodes %d %d\n' %(g_path,num_nodes,begin) + s.send(msg) + #print >>sys.stderr, msg + except Exception as e: print sys.stderr,e + #except: pass for k,v in nodes.iteritems(): num_conns+= len(v['to']) node_text = " stats_node [label=\"Statistics\\l" @@ -193,5 +201,11 @@ try: except Exception,e: sys.stderr.write("Cannot dump graph: %s" % str(e)) write_digraph(nodes) -try: timer.stop("execution_time") -except: pass + +try: + end = time() + msg = '%s.graph.detail_build_time %d %d\n' % (g_path,((end-begin)*1000),end) + s.send(msg) + print >>sys.stderr,msg + s.close() +except Exception as e: print >>sys.stderr, e |