Commit 5acb5347 authored by Olav Kvittem's avatar Olav Kvittem

generate rude.cfg, trace.cfg and rsync it out

parent fe7f003b
Scripts to run rude/crude, traceroute and collect results
File deleted
File deleted
#!/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
source $HOME/dragonlab/etc/start.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
#!/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
from="158.38.62.70,2001:700:1::62:70,158.38.130.56,2001:700:0:4513::56",no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDP/QWtrDhFDIYjrXasgiy+AOC0hU1Kv2WUqe21Kz6q8XQeZFpfW7i0mpifaXUmLZ3FdDUaIoFhAxOiaGao2b33DLEUeuc63oT7L/utr0hOH3XGgf9mmDw7zL4FbgPqno7K0dE+eawTIHLx6RtcIZ9HLiLEPMYqPAXA2589XUZjt5r5tMs9VHFb6aTp9AJDvkz1a2xmvgmaKNSvK5itpOhOkVeUxLHTa+taCcreYPAsKyatJDPJWHr7Ouj4x+c9WvmZXTvyVtpBcy1P0zmBACDK5ymGkCXdtd0V3TLYpafbAORaRc6sCyJFAw3jtlAPFkZniEz4Eyq7lHgpoXVmoJqt up@iou2
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxTR9FRQzY2inSVjBoMtSD1xLsOMuH9F89xQlfWdDDVAVtSqLmuyJGb7Vz84u5/OCgUhDdscTmDsxyUxW9stNBQH0jUYhnpvT7jS9lwHTnKn8EzlzTM5w/TbTrqsQCz7bxR53K5gtv9azW82cNy58q4IoP9gAcEfpBs/i5tldR4AG7hUBHNCgrCwYrZCCvowfUDruFN4lbIn5196cL+scWAk+kOWe0z+KNmWlSEMpcb3TPyk9Jl8S3F5/WcNfpCN3IXCqmzPOVQfddMKNzrfMtIk7CCd1kmr1R6W6L5oweAoKKGGw3UqlpDmq2t9soV2uMEF8K95G2ahPUyOWfLt4HQ== arneos@cia.uninett.no
START NOW
#5000 2010 ON 3001 203.91.120.141:10001 CONSTANT 100 64
#86390000 2010 OFF
# ytelse1-auckland IPv4
5000 2011 ON 3002 130.216.5.112:10001 CONSTANT 100 64
86390000 2011 OFF
# nte
5000 2012 ON 3003 178.164.4.2:10001 CONSTANT 100 64
86390000 2012 OFF
# switch
5000 2013 ON 3004 130.59.31.3:10001 CONSTANT 100 64
86390000 2013 OFF
#brasilia
5000 2014 ON 3005 200.133.192.133:10001 CONSTANT 100 64
86390000 2014 OFF
#kobenhavn
5000 2017 ON 3007 109.105.112.50:10001 CONSTANT 100 64
86390000 2017 OFF
#stockholm
5000 2018 ON 3008 109.105.110.98:10001 CONSTANT 100 64
86390000 2018 OFF
#!/usr/bin/perl
# make commands to rsync rude config files from host lists
# typically run after rude-config-maker
# format : src dst1 dst2 ...
my $target;
my $cmd;
my $list='mp-list.txt';
use Getopt::Long;
@opts=( 'target=s' => \$target, 'list=s' => \$list, 'cmd=s'=>\$cmd);
GetOptions(@opts) || die "usage: $0 [ -target <target host> ] [-list <mp-list.txt> \n";
open LIST, "<$list" || die "Could not open $list : $!\n";
while(<LIST>){
next if /^\s*#/; # comment line
($name, $uid, $dns, $ip)=split;
next if $target&& $target ne $name;
printf "ssh %s@%s %s\n",${uid},${ip}, $cmd;
}
#!/usr/bin/perl
# make commands to rsync rude config files from host lists
# typically run after rude-config-maker
# format : src dst1 dst2 ...
my $target;
my $fromdir,$todir;
my $list='mp-list.txt';
use Getopt::Long;
@opts=( 'target=s' => \$target, 'list=s' => \$list, 'fromdir=s'=>\$fromdir,'todir=s'=>\$todir);
GetOptions(@opts) || die "usage: $0 [ -target <target host> ] [-list <mp-list.txt> \n";
open LIST, "<$list" || die "Could not open $list : $!\n";
while(<LIST>){
next if /^\s*#/; # comment line
($name, $uid, $dns, $ip)=split;
next if $target&& $target ne $name;
printf "rsync -rvtu $fromdir/ %s@%s:dragonlab/$todir/\n",${uid},${ip};
}
#!/usr/bin/perl
# make commands to rsync rude config files from host lists
# typically run after rude-config-maker
# format : src dst1 dst2 ...
my $target;
my $fromdir,$todir;
my $list='mp-list.txt';
use Getopt::Long;
@opts=( 'target=s' => \$target, 'list=s' => \$list, 'fromdir=s'=>\$fromdir,'todir=s'=>\$todir);
GetOptions(@opts) || die "usage: $0 [ -target <target host> ] [-list <mp-list.txt> \n";
open LIST, "<$list" || die "Could not open $list : $!\n";
while(<LIST>){
next if /^\s*#/; # comment line
($name, $uid, $dns, $ip)=split;
next if $target&& $target ne $name;
printf "rsync -rvtu $fromdir/ %s@%s:dragonlab/$todir/\n",${uid},${ip};
}
#!/usr/bin/perl
# make commands to rsync rude config files from host lists
# typically run after rude-config-maker
# format : src dst1 dst2 ...
my $target;
my $list='mp-list.txt';
use Getopt::Long;
@opts=( 'target=s' => \$target, 'list=s' => \$list);
GetOptions(@opts) || die "usage: $0 [ -target <target host> ] [-list <mp-list.txt> \n";
open LIST, "<$list" || die "Could not open $list : $!\n";
while(<LIST>){
next if /^\s*#/; # comment line
($name, $uid, $dns, $ip)=split;
next if $target&& $target ne $name;
printf "rsync -rvtu / %s@%s:dragonlab/etc/\n",${uid},${ip};
}
#!/usr/bin/perl
# make rude config files from host lists
# format : src dst1 dst2 ...
my $target;
my $list='mp-list.txt';
use Getopt::Long;
@opts=( 'target=s' => \$target, 'list=s' => \$list);
GetOptions(@opts) || die "usage: $0 [ -target <target host> ] [-list <mp-list.txt> config-file\n";
open LIST, "<$list" || die "Could not open $list : $!\n";
while(<LIST>){
($name, $uid, $dns, $ip)=split;
$ip{$name}=$ip;
$dns{$name}=$dns;
}
use Socket;
while(<>){
next if /s*#/; # comment
($src, @dst)=split;
foreach $dst(@dst){
$peers{$src, $dst}++;
$peers{$dst, $src}++;
}
}
my $flow_no=1;
my $out; # fd to write config
my $outdir;
my $gotit=0;
foreach $peer ( sort(keys %peers)){
my ($src, $dst)=split(/$;/,$peer);
if ( $target ){
if ($target eq $src){ # just write config for target to stdout
$gotit=1;
$outdir=".";
} else { # avoid writing for other targets
$gotit=0;
}
} else {
$gotit=1;
$outdir=$src;
}
if ($psrc ne $src){
if ( $gotit){
if ( $psrc){
close $out;
$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";
}
}
$ip=$ip{$dst};
if ( !$ip){
if ( $dns{$dst} ){
$ipn=gethostbyname($dns{$dst});
} else {
$ipn=gethostbyname($dst);
}
if ($ipn){
$ip=inet_ntoa($ipn);
}
}
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
@$tracetarget{$src} = () if ! $tracetarget{$src};
push (@{$tracetarget{$src}}, $ip );
} else {
warn "### Could not find IP for $dst, $ip";
}
}
$psrc=$src;
$flow_no++;
}
close RUDE;
close $out;
foreach $src ( keys %tracetarget ){
next if $target and $src ne $target;
if ( $target){
next if $src ne $target;
$outdir=".";
} else {
$outdir=$src;
}
open TRACE, ">$outdir/trace.cfg" || die "Could not open $outdir/start.cfg : $!" ;
print TRACE join("\n", @{$tracetarget{$src}} );
close TRACE;
}
#!/usr/bin/perl
# make rude config files from host lists
# format : src dst1 dst2 ...
my $target;
my $list='mp-list.txt';
use Getopt::Long;
@opts=( 'target=s' => \$target, 'list=s' => \$list);
GetOptions(@opts) || die "usage: $0 [ -target <target host> ] [-list <mp-list.txt> config-file\n";
open LIST, "<$list" || die "Could not open $list : $!\n";
while(<LIST>){
($name, $uid, $dns, $ip)=split;
$ip{$name}=$ip;
$dns{$name}=$dns;
}
use Socket;
while(<>){
next if /s*#/; # comment
($src, @dst)=split;
foreach $dst(@dst){
$peers{$src, $dst}++;
$peers{$dst, $src}++;
}
}
my $flow_no=1;
my $out; # fd to write config
my $outdir;
my $gotit=0;
foreach $peer ( sort(keys %peers)){
my ($src, $dst)=split(/$;/,$peer);
if ( $target ){
if ($target eq $src){ # just write config for target to stdout
$gotit=1;
$outdir=".";
} else { # avoid writing for other targets
$gotit=0;
}
} else {
$gotit=1;
$outdir=$src;
}
if ($psrc ne $src){
if ( $gotit){
if ( $psrc){
close $out;
$flow_no=1;
}
mkdir "$outdir" if ! -d $outdir;
open $out, ">$outdir/rude.conf" || die "Could not open ${outdir}/rude.conf : $!";
print $out "START NOW\n";
}
}
$ip=$ip{$dst};
if ( !$ip){
if ( $dns{$dst} ){
$ipn=gethostbyname($dns{$dst});
} else {
$ipn=gethostbyname($dst);
}
if ($ipn){
$ip=inet_ntoa($ipn);
}
}
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
@$tracetarget{$src} = () if ! $tracetarget{$src};
push (@{$tracetarget{$src}}, $ip );
} else {
warn "### Could not find IP for $dst, $ip";
}
}
$psrc=$src;
$flow_no++;
}
close RUDE;
close $out;
foreach $src ( keys %tracetarget ){
next if $target and $src ne $target;
if ( $target){
next if $src ne $target;
$outdir=".";
} else {
$outdir=$src;
}
open TRACE, ">$outdir/trace.conf" || die "Could not open $outdir/start.conf : $!" ;
print TRACE join("\n", @{$tracetarget{$src}} );
close TRACE;
}
#!/usr/bin/perl
# make commands to rsync rude config files from host lists
# typically run after rude-config-maker
# format : src dst1 dst2 ...
my $target;
my $list='mp-list.txt';
use Getopt::Long;
@opts=( 'target=s' => \$target, 'list=s' => \$list);
GetOptions(@opts) || die "usage: $0 [ -target <target host> ] [-list <mp-list.txt> \n";
open LIST, "<$list" || die "Could not open $list : $!\n";
while(<LIST>){
next if /^\s*#/; # comment line
($name, $uid, $dns, $ip)=split;
next if $target&& $target ne $name;
printf "rsync -rvt $name/ %s@%s:dragonlab/etc/\n",${uid},${ip};
}
#!/usr/bin/perl
# make rude config files from host lists
# format : src dst1 dst2 ...
my $target;
my $list='mp-list.txt';
use Getopt::Long;
@opts=( 'target=s' => \$target, 'list=s' => \$list);
GetOptions(@opts) || die "usage: $0 [ -target <target host> ] [-list <mp-list.txt> config-file\n";
open LIST, "<$list" || die "Could not open $list : $!\n";
while(<LIST>){
($name, $uid, $dns, $ip)=split;
print "rsync -rvt $name/ $uid@$ip:dragonlab/etc/\n";
}
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