Commit 634aa5fc authored by Olav Kvittem's avatar Olav Kvittem

auto-start from cron now checks every minute if services are running

kills jobs and midnight 00:00 CET
traceroute and tcptraceroute separated
tools for syncing out to systems
parent 5acb5347
Scripts to run rude/crude, traceroute and collect results
#Set up client
##on client
~~~~~
apt-get install build-essential git automake autoconf
apt install ntp
apt install traceroute tcptraceroute
apt install libpcap-dev
git clone -b realtime git@scm.uninett.no:rude/rude.git
~~~~~
crontab dragonlab/etc/crontab.cfg
##on server
Enter node in config files
* /dynga/dragonlab/script/mp-names.txt
* /dynga/dragonlab/script/rude-list.con
make config files for rude/crude and traceroute
~~~~~
cd ~/microdep
mkdir tmp
cd tmp
# get password-free code out there
rsync /dynga/dragonlab/script/authorized_keys oak@104.196.241.36:.ssh
../server/script/rude-config-maker --list /dynga/dragonlab/script/mp-names.txt/dynga/dragonlab/script/rude-list.conf
../server/script/rude-config-updater --list /dynga/dragonlab/script/mp-names.txt | sh -x
~~~~~
#!/bin/bash
pid=`pidof rude`
cpid=`pidof crude`
if test .$pid = . -o .$cpid = . ; then
$HOME/dragonlab/bin/stop.sh
$HOME/dragonlab/bin/start.sh
fi
#!/bin/bash
#!/bin/bash
source $HOME/dragonlab/etc/start.cfg
tracetargets=`cat $HOME/dragonlab/etc/trace.cfg`
if [ -e $logpath/pids ]
then
echo "Pid file already exists: $logpath/pids"
fi
if [ ! -d $logpath/$date ]
then
mkdir -p $logpath/$date
fi
# $vmstat 2> /dev/null > /dev/null&
# echo "$!" > $logpath/pids
#Start crude
# $crude -k | gzip -c > $logpath/$date/crude-`date +%T`.gz 2> /dev/null&
# $crude -k -6 -p10002 | gzip -c > $logpath/$date/crude_v6.gz 2> /dev/null&
# pidof $crude >> $logpath/pids
#Start tcpdump
#ok sudo $dump $logpath/$date/dump.pcap&
#Start rude
# $rude -s $rudecfg > /dev/null 2> /dev/null &
# echo "$!" >> $logpath/pids
#Start traceroute
for i in $tracetargets; do
$trace $i 2> /dev/null > /dev/null&
echo "$!" >> $logpath/pids
done
for i in $tracetargets; do
$tcptrace $i 2> /dev/null > /dev/null&
echo "$!" >> $logpath/pids
done
for i in $tracetargets6; do
$trace6 $i 2> /dev/null > /dev/null&
echo "$!" >> $logpath/pids
done
#Start ntp jitter
$ntp 2>/dev/null >/dev/null&
echo "$!" >> $logpath/pids
......@@ -16,8 +16,10 @@ fi
$vmstat 2> /dev/null > /dev/null&
echo "$!" > $logpath/pids
T=`date +%T`
#Start crude
$crude -k | gzip -c > $logpath/$date/crude.gz 2> /dev/null&
$crude -k | gzip -c > $logpath/$date/crude-$T.gz 2> /dev/null&
# $crude -k -6 -p10002 | gzip -c > $logpath/$date/crude_v6.gz 2> /dev/null&
pidof $crude >> $logpath/pids
......@@ -28,21 +30,5 @@ pidof $crude >> $logpath/pids
$rude -s $rudecfg > /dev/null 2> /dev/null &
echo "$!" >> $logpath/pids
#Start traceroute
for i in $tracetargets; do
$trace $i 2> /dev/null > /dev/null&
echo "$!" >> $logpath/pids
done
for i in $tracetargets; do
$tcptrace $i 2> /dev/null > /dev/null&
echo "$!" >> $logpath/pids
done
for i in $tracetargets6; do
$trace6 $i 2> /dev/null > /dev/null&
echo "$!" >> $logpath/pids
done
#Start ntp jitter
$ntp 2>/dev/null >/dev/null&
echo "$!" >> $logpath/pids
$HOME/dragonlab/bin/start-trace.sh
#!/bin/bash
#!/bin/bash -x
source $HOME/dragonlab/etc/start.cfg
......@@ -6,6 +6,6 @@ source $HOME/dragonlab/etc/start.cfg
while true; do
date +%s | gzip -c >> $logpath/$date/tcptraceroute_$1.gz
tcptraceroute -q 6 -n $1 2> /dev/null | gzip -c >> $logpath/$date/tcptraceroute_$1.gz
$tcptrace_bin -q 6 -n $1 2> /dev/null | gzip -c >> $logpath/$date/tcptraceroute_$1.gz
sleep 120
done
#!/bin/bash
# kill processes trace.sh which are from yesterday - time field with alpha-text
ps -ef | perl -ane 'printf "kill %s # %s %s %s\n", $F[1], $F[7],$F[8],$F[9] if /trace.sh/ && $F[4] =~ /^[A-Z]/' | sh -x
ps -ef | perl -ane 'printf "kill %s # %s %s %s\n", $F[1], $F[7],$F[8],$F[9] if /trace.sh/ && $F[4] =~ /^[A-Za-z]/' | sh -x
tracetargets="130.216.5.112 200.133.192.133 109.105.112.50 109.105.110.98 130.59.31.3 128.39.65.26 178.164.4.2 89.45.232.192"
#tracetargets="130.216.5.112 178.164.4.2 130.59.31.3 200.133.192.133" # auckland nte switch
#tracetargets6="2001:da8:217:1:2e0:81ff:fe31:cb34 2001:df0:0:2023:225:90ff:fe19:96ba" # china auckland
#tracetargets6="2001:df0:0:2023:225:90ff:fe19:96ba" # auckland
crude_port=10001
tcptrace_bin="/usr/sbin/tcptraceroute"
logpath="$HOME/dragonlab/data"
rudecfg="$HOME/dragonlab/etc/rude.cfg"
dump="$HOME/dragonlab/bin/starttcpdump.sh"
......@@ -14,3 +13,6 @@ crude="$HOME/dragonlab/bin/crude"
rude="$HOME/dragonlab/bin/rude"
date=`env TZ=Europe/Oslo date +%Y%m%d`
if test -f $HOME/dragonlab/etc/local.cfg; then
source $HOME/dragonlab/etc/local.cfg
fi
......@@ -13,10 +13,10 @@ GetOptions(@opts) || die "usage: $0 [ -target <target host> ] [-list <mp-list.tx
open LIST, "<$list" || die "Could not open $list : $!\n";
while(<LIST>){
next if /^\s*#/; # comment line
next if /^\s*#|^\s*$/; # comment line
($name, $uid, $dns, $ip)=split;
next if $target&& $target ne $name;
printf "ssh %s@%s %s\n",${uid},${ip}, $cmd;
printf "env NAVN=%s LANG=C LC_ALL=C ssh %s@%s %s # %s\n", $name, ${uid},${ip}, $cmd;
}
......@@ -13,7 +13,7 @@ GetOptions(@opts) || die "usage: $0 [ -target <target host> ] [-list <mp-list.tx
open LIST, "<$list" || die "Could not open $list : $!\n";
while(<LIST>){
next if /^\s*#/; # comment line
next if /^\s*#|^\s*$/; # comment line
($name, $uid, $dns, $ip)=split;
next if $target&& $target ne $name;
......
......@@ -11,14 +11,16 @@ GetOptions(@opts) || die "usage: $0 [ -target <target host> ] [-list <mp-list.tx
open LIST, "<$list" || die "Could not open $list : $!\n";
while(<LIST>){
($name, $uid, $dns, $ip)=split;
next if /\s*#/; # comment
($name, $uid, $dns, $ip, $port)=split;
$ip{$name}=$ip;
$dns{$name}=$dns;
$port{$name}=$port;
}
use Socket;
while(<>){
next if /s*#/; # comment
next if /\s*#/; # comment
($src, @dst)=split;
foreach $dst(@dst){
$peers{$src, $dst}++;
......@@ -26,8 +28,23 @@ while(<>){
}
}
$startcfg='
logpath="$HOME/dragonlab/data"
rudecfg="$HOME/dragonlab/etc/rude.cfg"
dump="$HOME/dragonlab/bin/starttcpdump.sh"
trace="$HOME/dragonlab/bin/trace.sh"
tcptrace="$HOME/dragonlab/bin/tcptrace.sh"
trace6="$HOME/dragonlab/bin/trace6.sh"
vmstat="$HOME/dragonlab/bin/vmstat.sh"
ntp="$HOME/dragonlab/bin/ntp-jitter.sh"
crude="$HOME/dragonlab/bin/crude"
rude="$HOME/dragonlab/bin/rude"
date=`env TZ=Europe/Oslo date +%Y%m%d`
';
my $flow_no=1;
my $out; # fd to write config
my $rude; # fd to write config
my $start; # fd to write config
my $outdir;
my $gotit=0;
......@@ -48,12 +65,12 @@ foreach $peer ( sort(keys %peers)){
if ($psrc ne $src){
if ( $gotit){
if ( $psrc){
close $out;
close $rude;
$flow_no=1;
}
mkdir "$outdir" if ! -d $outdir;
open $out, ">$outdir/rude.cfg" || die "Could not open ${outdir}/rude.cfg : $!";
print $out "START NOW\n";
open $rude, ">$outdir/rude.cfg" || die "Could not open ${outdir}/rude.cfg : $!";
print $rude "START NOW\n";
}
}
......@@ -70,8 +87,8 @@ foreach $peer ( sort(keys %peers)){
}
if ($gotit){
if ($ip ){
printf $out "0 %d ON 300%d %s:10001 CONSTANT 100 64\n", $flow_no, $flow_no,$ip;
printf $out "86390000 %d OFF\n", $flow_no; # varer en dag -10 sek
printf $rude "0 %d ON 300%d %s:%s CONSTANT 100 64\n", $flow_no, $flow_no,$ip,$port{$dst};
printf $rude "90010000 %d OFF\n", $flow_no; # varer en dag +10 sek skuddr
@$tracetarget{$src} = () if ! $tracetarget{$src};
push (@{$tracetarget{$src}}, $ip );
} else {
......@@ -83,7 +100,18 @@ foreach $peer ( sort(keys %peers)){
}
close RUDE;
close $out;
close $rude;
foreach $name ( keys %port){
if ( (! $target) || ( $target eq $name ) ){
$outdir=$name;
open ( $start, ">$outdir/start.cfg") || die "Could not open ${outdir}/start.cfg : $!" ;
printf $start "crude_port=%s\n", $port{$name};
printf $start "%s", $startcfg;
close $start;
}
}
foreach $src ( keys %tracetarget ){
next if $target and $src ne $target;
......@@ -98,3 +126,4 @@ foreach $src ( keys %tracetarget ){
close TRACE;
}
......@@ -12,8 +12,8 @@ GetOptions(@opts) || die "usage: $0 [ -target <target host> ] [-list <mp-list.tx
open LIST, "<$list" || die "Could not open $list : $!\n";
while(<LIST>){
next if /^\s*#/; # comment line
($name, $uid, $dns, $ip)=split;
next if /^\s*#|^\s*$/; # comment line
($name, $uid, $dns, $ip, $port)=split;
next if $target&& $target ne $name;
printf "rsync -rvt $name/ %s@%s:dragonlab/etc/\n",${uid},${ip};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment