summaryrefslogtreecommitdiffstats
path: root/retiolum/scripts
diff options
context:
space:
mode:
authorroot <root@monitoring.shack>2012-09-13 23:39:58 +0000
committerroot <root@monitoring.shack>2012-09-13 23:39:58 +0000
commitdb849a18e1659ff28433384d2cdca2989a6d5df0 (patch)
treed600fb3f3e5f0a54b6254c85ee8a3b836ef3d90d /retiolum/scripts
parentd5d39fc3d56b021b642ee6e1d5625524ebbc4d99 (diff)
parent88d4bdc29eb9ce5f62099f2be1488ae927aa09d5 (diff)
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'retiolum/scripts')
-rwxr-xr-xretiolum/scripts/adv_graphgen/all_the_graphs.sh20
-rwxr-xr-xretiolum/scripts/adv_graphgen/anonytize.sh2
-rwxr-xr-xretiolum/scripts/adv_graphgen/parse_tinc_anon.py19
-rwxr-xr-xretiolum/scripts/adv_graphgen/parse_tinc_stats.py28
-rwxr-xr-xretiolum/scripts/adv_graphgen/sanitize.sh2
-rw-r--r--retiolum/scripts/tinc_setup/write_channel.py8
6 files changed, 68 insertions, 11 deletions
diff --git a/retiolum/scripts/adv_graphgen/all_the_graphs.sh b/retiolum/scripts/adv_graphgen/all_the_graphs.sh
index 36b37f03..5533c722 100755
--- a/retiolum/scripts/adv_graphgen/all_the_graphs.sh
+++ b/retiolum/scripts/adv_graphgen/all_the_graphs.sh
@@ -1,5 +1,15 @@
-#!/bin/sh
-echo "`date` begin all graphs" >> /tmp/build_graph
-cd $(dirname $(readlink -f $0))
-(./anonytize.sh /srv/http/pub/graphs/retiolum/ && echo "`date` anonytize done" >> /tmp/build_graph)&
-(./sanitize.sh /srv/http/priv/graphs/retiolum/ && echo "`date` sanitize done" >> /tmp/build_graph)&
+#!/bin/bash
+
+(
+ echo "`date` begin all graphs" >> /tmp/build_graph
+ cd $(dirname $(readlink -f $0))
+ PATH=$PATH:../../../util/bin/
+ export LOG_FILE=/var/log/retiolum.log
+ begin=`timer`
+ export GRAPHITE_HOST="no_omo"
+ (./anonytize.sh /srv/http/pub/graphs/retiolum/ && echo "`date` anonytize done" >> /tmp/build_graph)&
+ (./sanitize.sh /srv/http/priv/graphs/retiolum/ && echo "`date` sanitize done" >> /tmp/build_graph)&
+# wait
+ graphitec "retiolum.graph.buildtime" "$(timer $begin)" >> /tmp/build_graph
+ echo "`date` end all graphs" >> /tmp/build_graph
+)&
diff --git a/retiolum/scripts/adv_graphgen/anonytize.sh b/retiolum/scripts/adv_graphgen/anonytize.sh
index 1ebfe972..d49793cb 100755
--- a/retiolum/scripts/adv_graphgen/anonytize.sh
+++ b/retiolum/scripts/adv_graphgen/anonytize.sh
@@ -5,7 +5,7 @@ GRAPH_SETTER1=dot
GRAPH_SETTER2=circo
GRAPH_SETTER3='neato -Goverlap=prism '
GRAPH_SETTER4=sfdp
-LOG_FILE=/var/log/syslog
+LOG_FILE=${LOG_FILE:-/var/log/syslog}
TYPE=svg
TYPE2=png
OPENER=/bin/true
diff --git a/retiolum/scripts/adv_graphgen/parse_tinc_anon.py b/retiolum/scripts/adv_graphgen/parse_tinc_anon.py
index 3b0383da..e0bea913 100755
--- a/retiolum/scripts/adv_graphgen/parse_tinc_anon.py
+++ b/retiolum/scripts/adv_graphgen/parse_tinc_anon.py
@@ -3,6 +3,19 @@
from BackwardsReader import BackwardsReader
import sys,json
#supernodes= [ "kaah","supernode","euer","pa_sharepoint","oxberg" ]
+try:
+ import socket
+ from time import time
+ import os
+ host = os.environ.get("GRAPHITE_HOST","localhost")
+ port = 2003
+ g_path = os.environ.get("GRAPHITE_PATH","retiolum")
+ begin = time()
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sys.stderr.write("connecting to %s:%d"%(host,port))
+ s.connect((host,port))
+except Exception as e:
+ print >>sys.stderr, "Cannot connect to graphite: " + str(e)
""" TODO: Refactoring needed to pull the edges out of the node structures again,
it should be easier to handle both structures"""
DUMP_FILE = "/krebs/db/availability"
@@ -133,3 +146,9 @@ def decode_input(FILE):
nodes = decode_input(sys.stdin)
nodes = delete_unused_nodes(nodes)
write_digraph(nodes)
+try:
+ end = time()
+ msg = '%s.graph.anon_build_time %d %d\r\n' % (g_path,((end-begin)*1000),end)
+ s.send(msg)
+ s.close()
+except Exception as e: print >>sys.stderr, e
diff --git a/retiolum/scripts/adv_graphgen/parse_tinc_stats.py b/retiolum/scripts/adv_graphgen/parse_tinc_stats.py
index 54dcc4ab..16f4f795 100755
--- a/retiolum/scripts/adv_graphgen/parse_tinc_stats.py
+++ b/retiolum/scripts/adv_graphgen/parse_tinc_stats.py
@@ -2,6 +2,20 @@
# -*- coding: utf8 -*-
from BackwardsReader import BackwardsReader
import sys,json
+try:
+ from time import time
+ import socket
+ import os
+ host = os.environ.get("GRAPHITE_HOST","localhost")
+ port = 2003
+ g_path = os.environ.get("GRAPHITE_PATH","retiolum")
+ begin = time()
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sys.stderr.write("connecting to %s:%d"%(host,port))
+ s.connect((host,port))
+except Exception as e:
+ sys.stderr.write("Cannot connect to graphite: %s\n" % str(e))
+
supernodes= [ "kaah","supernode","euer","pa_sharepoint","oxberg" ]
""" TODO: Refactoring needed to pull the edges out of the node structures again,
it should be easier to handle both structures"""
@@ -36,6 +50,12 @@ def write_stat_node(nodes):
'''
num_conns = 0
num_nodes = len(nodes)
+ try:
+ msg = '%s.num_nodes %d %d\r\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"
@@ -183,3 +203,11 @@ try:
except Exception,e:
sys.stderr.write("Cannot dump graph: %s" % str(e))
write_digraph(nodes)
+
+try:
+ end = time()
+ msg = '%s.graph.detail_build_time %d %d\r\n' % (g_path,((end-begin)*1000),end)
+ s.send(msg)
+ sys.stderr.write(msg)
+ s.close()
+except Exception as e: sys.stderr.write( str(e) + "\n")
diff --git a/retiolum/scripts/adv_graphgen/sanitize.sh b/retiolum/scripts/adv_graphgen/sanitize.sh
index 50f1659f..c46662f3 100755
--- a/retiolum/scripts/adv_graphgen/sanitize.sh
+++ b/retiolum/scripts/adv_graphgen/sanitize.sh
@@ -5,7 +5,7 @@ GRAPH_SETTER1=dot
GRAPH_SETTER2=circo
GRAPH_SETTER3='neato -Goverlap=prism '
GRAPH_SETTER4=sfdp
-LOG_FILE=/var/log/syslog
+LOG_FILE=${LOG_FILE:-/var/log/syslog}
TYPE=svg
TYPE2=png
OPENER=/bin/true
diff --git a/retiolum/scripts/tinc_setup/write_channel.py b/retiolum/scripts/tinc_setup/write_channel.py
index 53a155d9..8299fa8d 100644
--- a/retiolum/scripts/tinc_setup/write_channel.py
+++ b/retiolum/scripts/tinc_setup/write_channel.py
@@ -3,7 +3,7 @@ import random, sys, time, socket
try:
myname=sys.argv[1]
except:
- print "you are made of stupid"
+ print("you are made of stupid")
exit (23)
CHANNEL = '#krebsco'
@@ -12,10 +12,10 @@ FILE="/etc/tinc/retiolum/hosts/"+myname
PORT=6667
NICK= myname+"_"+str(random.randint(23,666))
-print "Connecting..."
+print("Connecting...")
sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.connect((HOST,PORT))
-print NICK
+print(NICK)
sock.send("NICK %s\r\n" % NICK)
sock.send("USER %s %s bla : %s\r\n" %(NICK,HOST,NICK))
sock.send("JOIN %s\r\n" % CHANNEL)
@@ -23,5 +23,5 @@ time.sleep(23)
f = open(FILE,'r')
a = [ sock.send("PRIVMSG %s : %s" % ( CHANNEL,line)) for line in f]
time.sleep(5) #because irc is so lazy
-print "closing socket"
+print("closing socket")
sock.close()