...
 
Commits (11)
......@@ -13,3 +13,14 @@ rude-list.conf lists of rude/traceroute destinations
mp-list.txt list of nodes
roll out rude/crude to /usr/local/bin with debian packages.
For distribuert utrulling av config
1. legg ut rude-list.conf til /etc/mp-rude
2. cd /etc/mp-rude
2. /usr/bin/rude-config-maker -target=`hostname -f` rude-list.conf
som lager rude.conf og trace.conf
Normalt skal det hele restartes ved midnatt, men
man kan restarte rude manuelt, men da vil man faa hull i maaleserien
MAILTO=oak@uninett.no
0 0 * * * root /usr/sbin/service mp-rude restart
59 23 * * * root /etc/mp-rude/stop.sh 50
0 0 * * * root /etc/mp-rude/start.sh
0 0 * * * root /usr/sbin/service mp-rude restart 2>&1 > /tmp/mp-rude/restart-`date +%u`.log
59 23 * * * root /etc/mp-rude/stop.sh 50 2>&1 > /tmp/mp-rude/stop-`date +%u`.log
0 0 * * * root /etc/mp-rude/start.sh 2>&1 > /tmp/mp-rude/start-`date +%u`.log
......@@ -19,23 +19,23 @@ PIPE=/tmp/mp-rude/crude.pipe
do_start() {
log_begin_msg "Starting rude/crude..."
HOST=$(hostname)
DATE=$(date +%Y-%m-%d)
DATE=$(date +%Y-%m-%d-%T)
LOG=/tmp/mp-rude/$HOST-$DATE.crude
if test ! -p $PIPE ; then
mkfifo $PIPE
fi
start-stop-daemon --start --background --pidfile /var/run/mp-rude.pid -m --exec $RUDE -- -P 50 -s /etc/mp-rude/rude.conf
start-stop-daemon --start --background --pidfile /var/run/mp-crude.pid -m --exec $CRUDE -- -P 50 -k -l $PIPE
start-stop-daemon --start --background --pidfile /var/run/mp-crude-zip.pid -m --exec /etc/mp-rude/mp-rude-zip -- $PIPE $LOG.gz
start-stop-daemon --start --background --pidfile /run/mp-rude.pid -m --exec $RUDE -- -P 50 -s /etc/mp-rude/rude.conf
start-stop-daemon --start --background --pidfile /run/mp-crude.pid -m --exec $CRUDE -- -P 50 -k -l $PIPE
start-stop-daemon --start --background --pidfile /run/mp-crude-zip.pid -m --exec /etc/mp-rude/mp-rude-zip -- $PIPE $LOG.gz
log_end_msg $?
}
do_stop() {
log_begin_msg "Stopping rude/crude..."
start-stop-daemon --stop --pidfile /var/run/mp-rude.pid
start-stop-daemon --stop --pidfile /var/run/mp-crude.pid --signal INT
start-stop-daemon --stop --pidfile /var/run/mp-crude-zip.pid --signal INT
start-stop-daemon --stop --pidfile /run/mp-rude.pid
start-stop-daemon --stop --pidfile /run/mp-crude.pid --signal INT
start-stop-daemon --stop --pidfile /run/mp-crude-zip.pid --signal INT
sleep 1
fuser -k $PIPE # kill all processes using pipe
log_end_msg $?
......
#!/bin/bash
mp-rude=/usr/local/mp-rude
cd $mp-rude/etc
$mp-rude/tools/rude-config-maker -target $(hostname -f) rude-list.conf > rude.conf
#! /bin/sh
set -e
mp_rude="/usr/local/mp-rude"
"${mp_rude}"/tools/rude-config-maker -target $(hostname -f) rude-list.conf > "${mp_rude}"/etc/rude.conf
#!/bin/bash
#! /bin/sh
cat $1 | /bin/gzip > $2
#!/bin/bash
#! /bin/sh
source /etc/mp-rude/start.conf
set -e
log=$logpath/$date/traceroute_$1
. /etc/mp-rude/start.conf
log="${logpath}"/"${date}"/"traceroute_$1"
if [ -f "${logpath}"/pids ] ; then
echo "ERROR: ${logpath}/pids already exists!"
exit 1
fi
#Start traceroute
for i in `cat $traceconf` ; do
$trace $i 23:59 2> /dev/null > /dev/null &
echo "$!" >> $logpath/pids
for i in $(cat ${traceconf}) ; do
${trace} ${i} 23:59 > /dev/null 2>&1 &
echo "$!" >> "${logpath}"/pids
done
#!/bin/bash
#! /bin/sh
source /etc/mp-rude/start.conf
set -e
if [ ! -e $logpath/pids ]
. /etc/mp-rude/start.conf
if [ ! -e "${logpath}"/pids ]
then
echo "Pid file does not exist: $logpath/pids"
echo "Pid file does not exist: ${logpath}/pids"
exit
fi
......@@ -14,5 +16,4 @@ fi
for i in $(cat $logpath/pids); do kill $i; done
rm $logpath/pids
rm -f "${logpath}"/pids
#!/bin/bash
#! /bin/sh
source /etc/mp-rude/start.conf
. /etc/mp-rude/start.conf
mkdir -p $logpath/$date
log=$logpath/$date/traceroute_$1
mkdir -p "${logpath}"/"${date}"
log="${logpath}"/"${date}"/traceroute_$1
if test $2. -ne . ; then
if [ $2. -ne . ] ; then
end=$(date --date "$2" +%s)
else
end=$(date --date "2099-12-31" +%s)
......@@ -15,8 +15,8 @@ fi
# > $log.log
while test $(date +%s) -lt $end ; do
date "+%s starttime %T" | gzip -c >> $log.gz
traceroute -q 6 -n $1 2> /dev/null | gzip -c >> $log.gz
date "+%s starttime %T" | gzip -c >> "${log}".gz
traceroute -q 6 -n $1 2> /dev/null | gzip -c >> "${log}".gz
sleep 60
done
#) 9> $log.lock &
......
......@@ -6,7 +6,7 @@ After=network.target
ExecStart=/etc/init.d/mp-rude start
ExecStop=/etc/init.d/mp-rude stop
ExecReload=/etc/init.d/mp-rude reload
PIDFile=/var/run/mp-rude.pid
PIDFile=/run/mp-rude.pid
RemainAfterExit=no
Restart=always
Type=forking
......
alesund-mp.hials.no
alta-mp.hifm.no
bergen-mp.uib.no
drammen-mp.hibu.no
forde-mp.hisf.no
fredrikstad-mp.hiof.no
gjovik-mp.hig.no
grimstad-mp.uia.no
halden-mp.hiof.no
hamar-mp.hihm.no
harstad-mp.hih.no
haugesund-mp.hsh.no
kalvskinnet-mp.hist.no
kristiansand-mp.uia.no
kunnskapsv-mp.hioa.no
lillehammer-mp.hil.no
molde-mp.himolde.no
narvik-mp.hin.no
nesna-mp.hinesna.no
ntnu-mp.ntnu.no
nyalesund-mp.uninett.no
oslo-mp.uio.no
pil32-mp.hioa.no
porsgrunn-mp.hit.no
sogndal-mp.hisf.no
stavanger-mp.uis.no
steinkjer-mp.hint.no
stord-mp.hsh.no
svalbard-mp.unis.no
tromso-mp.uit.no
volda-mp.hivolda.no
ntnu-mp.ntnu.no
tromso-mp.uit.no
bergen-mp.uib.no
oslo-mp.uio.no
alesund-mp.hials.no bergen-mp.uib.no ntnu-mp.ntnu.no
alta-mp.hifm.no tromso-mp.uit.no ntnu-mp.ntnu.no
bergen-mp.uib.no ntnu-mp.ntnu.no oslo-mp.uio.no tromso-mp.uit.no
bo-mp.hit.no oslo-mp.uio.no bergen-mp.uib.no
drammen-mp.hibu.no oslo-mp.uio.no bergen-mp.uib.no
forde-mp.hisf.no bergen-mp.uib.no ntnu-mp.ntnu.no
fredrikstad-mp.hiof.no oslo-mp.uio.no bergen-mp.uib.no
gjovik-mp.hig.no oslo-mp.uio.no bergen-mp.uib.no
grimstad-mp.uia.no oslo-mp.uio.no bergen-mp.uib.no
halden-mp.hiof.no oslo-mp.uio.no bergen-mp.uib.no
hamar-mp.hihm.no oslo-mp.uio.no ntnu-mp.ntnu.no
harstad-mp.hih.no tromso-mp.uit.no ntnu-mp.ntnu.no
haugesund-mp.hsh.no bergen-mp.uib.no stavanger-mp.uis.no
kalvskinnet-mp.hist.no ntnu-mp.ntnu.no bergen-mp.uib.no
kristiansand-mp.uia.no oslo-mp.uio.no bergen-mp.uib.no
kunnskapsv-mp.hioa.no oslo-mp.uio.no bergen-mp.uib.no
lillehammer-mp.hil.no oslo-mp.uio.no ntnu-mp.ntnu.no
molde-mp.himolde.no bergen-mp.uib.no ntnu-mp.ntnu.no
narvik-mp.hin.no tromso-mp.uit.no ntnu-mp.ntnu.no
nesna-mp.hinesna.no tromso-mp.uit.no ntnu-mp.ntnu.no
ntnu-mp.ntnu.no oslo-mp.uio.no bergen-mp.uib.no tromso-mp.uit.no
nyalesund-mp.uninett.no tromso-mp.uit.no ntnu-mp.ntnu.no
oslo-mp.uio.no bergen-mp.uib.no tromso-mp.uit.no ntnu-mp.ntnu.no
pil32-mp.hioa.no oslo-mp.uio.no bergen-mp.uib.no
porsgrunn-mp.hit.no oslo-mp.uio.no bergen-mp.uib.no
sogndal-mp.hisf.no oslo-mp.uio.no bergen-mp.uib.no
stavanger-mp.uis.no bergen-mp.uib.no oslo-mp.uio.no
steinkjer-mp.hint.no ntnu-mp.ntnu.no bergen-mp.uib.no
stord-mp.hsh.no bergen-mp.uib.no stavanger-mp.uis.no
svalbard-mp.unis.no tromso-mp.uit.no ntnu-mp.ntnu.no
teknobyen-mp.uninett.no ntnu-mp.ntnu.no bergen-mp.uib.no
tromso-mp.uit.no oslo-mp.uio.no bergen-mp.uib.no ntnu-mp.ntnu.no
# volda-mp.hivolda.no ntnu-mp.ntnu.no bergen-mp.uib.no
auckland brasilia trondheim nte zurich
sydney
brasilia trondheim nte
merit
stockholm
copenhagen
zurich
trondheim brasilia auckland nte zurich
nte
#!/bin/bash
mplist=$1
reglist=$2
regnames=`cat $regnames`
function path_lth {
echo `traceroute -n -q 3 $1| wc -l || echo 99`
}
for mp in `cat $mplist`; do
reg1l=99
reg2l=99
for reg in $regnames ; do
if test $reg != $mp ; then
lth=$( path_lth $reg )
if test $lth -lt $reg1l; then
reg1l=$lth
reg1=$reg
elif test $lth -lt $reg2l; then
reg2l=$lth
reg2=$reg
fi
fi
done
echo $mp $reg1 $reg2
done
#!/bin/bash
mps="$1"
cmd="$2"
user="$2"
cmd="$3"
for mp in `cat $mps` ; do
for mp in `cut -f 1 $mps | grep -v \#` ; do
echo henter $mp
# ssh -q root@$mp sysctl net.core.rmem_default
ssh -q root@$mp "$cmd"
ssh -q -o ConnectTimeout=3 $user@$mp "$cmd"
done
#!/bin/bash
cmd="$1"
for mp in bo-mp.hit.no stord-mp.hsh.no forde-mp.hisf.no harstad-mp.hih.no volda-mp.hivolda.no haugesund-mp.hsh.no tromso-mp.uit.no molde-mp.himolde.no alesund-mp.hials.no fredrikstad-mp.hiof.no svalbard-mp.unis.no porsgrunn-mp.hit.no alta-mp.hifm.no hamar-mp.hihm.no narvik-mp.hin.no pil32-mp.hioa.no ntnu-mp.ntnu.no kristiansand-mp.uia.no sogndal-mp.hisf.no stavanger-mp.uis.no bergen-mp.uib.no grimstad-mp.uia.no lillehammer-mp.hil.no oslo-mp.uio.no halden-mp.hiof.no nesna-mp.hinesna.no nyalesund-mp.uninett.no kunnskapsv-mp.hioa.no drammen-mp.hibu.no steinkjer-mp.hint.no gjovik-mp.hig.no ; do
echo henter $mp
# ssh -q root@$mp sysctl net.core.rmem_default
ssh -q root@$mp "$cmd"
done
File mode changed from 100644 to 100755
......@@ -2,10 +2,10 @@
hlist=$1
cmd="$2"
for mp in `cat mp-list.txt`; do
for mp in `cat $hlist`; do
echo $mp
eval $cmd
# start-stop-daemon --start --background --pidfile /var/run/mp-crude.pid -m --exec /usr/local/bin/crude -- -P 50 -k -l - | gzip >/tmp/mp-rude/$HOST-$DATE.crude.gz
# start-stop-daemon --start --background --pidfile /run/mp-crude.pid -m --exec /usr/local/bin/crude -- -P 50 -k -l - | gzip >/tmp/mp-rude/$HOST-$DATE.crude.gz
# rsync -prv etc/ root@$mp:/etc/
# rsync -prv tmp/$mp/ root@$mp:/etc/mp-rude/
# rsync -prv etc/init.d/mp-rude root@$mp:/etc/init.d/
......
#! /bin/sh
# Lister ut alle maskiner som er m?lep?ler
KINDURL="https://kind.uninett.no/openapi/utstyr_mp.json"
curl -s "${KINDURL}" | jq -M '.[] | .navn' | cut -d\" -f2
......@@ -3,10 +3,18 @@
# format : src dst1 dst2 ...
my $target;
my $list='mp-list.txt';
use Getopt::Long;
@opts=( 'target=s' => \$target);
GetOptions(@opts) || die "usage: $0 [ -target <target host> ] config-file\n";
@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(<>){
......@@ -49,18 +57,33 @@ foreach $peer ( sort(keys %peers)){
}
}
$ip=gethostbyname($dst);
if ($ip && $gotit ){
printf $out "0 %d ON 300%d %s:10001 CONSTANT 100 64\n", $flow_no, $flow_no, inet_ntoa($ip);
printf $out "86390000 %d OFF\n", $flow_no; # varer en dag -10 sek
@$tracetarget{$src} = () if ! $tracetarget{$src};
push (@{$tracetarget{$src}}, inet_ntoa($ip) );
$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;
......
#! /bin/sh
set -e
kind='https://kind.uninett.no/openapi/utstyr_mp.json'
mp=$(curl -s "$kind" | jq -M '.[] | .navn' | cut -d\" -f2)
ssh='ssh -o ConnectTimeout=3'
cmd='cd /var/lib/mp-rude/ ; du -h *-$(date +%Y-%m-%d).crude.gz'
clear
printf "%-40s %-6s %s\n====================================================\n" HOSTNAME SIZE FILE
while true ; do
printf "\x1b[3;1f"
for host in $mp ; do
printf "%-40s %-6s %s\n" $host $($ssh $host 'cd /var/lib/mp-rude/ ; du -h *-$(date +%Y-%m-%d).crude.gz' || echo FAILED)
done
done