Commit 6076d8a1 authored by Olav Kvittem's avatar Olav Kvittem
Browse files

bugs, analyze realtime, auto-config

parent 30020562
......@@ -3,7 +3,6 @@ Priority: extra
Section: uninett
Architecture: all
Depends: rude, crude, traceroute, perl-base, cron, libstatistics-linefit-perl, libjson-xs-perl, libdatetime-perl
Maintainer: kolbjorn.barmen@uninett.no
Maintainer:olav.kvittem@uninett.no
Version: {VERSION}
Provides: microdep
......
#! /bin/sh
echo microdep 'ALL=(ALL) NOPASSWD: /usr/local/sbin/get-icmp.sh' > /etc/sudoers.d/microdep.sudo
echo microdep 'ALL=(ALL) NOPASSWD: /usr/local/sbin/get-icmp.sh' > /etc/sudoers.d/microdep
cp /home/microdep/microdep/bin/get-icmp.sh /usr/local/sbin/
find /home/microdep -user root -exec chown microdep.microdep \{} \;
find /home/microdep -not -user microdep -exec chown microdep.microdep \{} \;
sudo microdep /home/microdep/microdep/bin/update-config
if test -e /usr/bin/crude -a ! -e /home/microdep/microdep/bin/crude ; then
sudo -u microdep ln -s /usr/bin/rude /home/microdep/microdep/bin/
sudo -u microdep ln -s /usr/bin/crude /home/microdep/microdep/bin/
fi
crontab -u /home/microdep/microdep/etc/crontab
mkdir -p /var/log/mp-rude
chown microdep.microdep /var/log/mp-rude
sudo -u microdep /home/microdep/microdep/bin/update-config
crontab -u microdep /home/microdep/microdep/etc/crontab.cfg
File mode changed from 100644 to 100755
#! /bin/sh
if test -d /home/microdep/bin ; then
if test -l /home/microdep/bin/rude ; then
rm /home/microdep/bin/rude
rm /home/microdep/bin/crude
fi
fi
crontab -u microdep -r
rm /etc/sudoers.d/microdep
Scripts to run rude/crude, traceroute and collect results
#Set up client
#Manual set up client
##on client
~~~~~
......@@ -10,18 +10,27 @@ Scripts to run rude/crude, traceroute and collect results
apt install libpcap-dev
git clone https://scm.uninett.no/rude/rude.git
compile and link up in dragonlab/bin
compile and link up in microdep/bin :
ln -s ~/rude/rude/rude .
ln -s ~/rude/crude/crude .
add to /etc/sudoers.d/dragonlab
$USER ALL=(ALL) NOPASSWD: /usr/sbin/tcpdump
add to /etc/sudoers.d/microdep
$USER ALL=(ALL) NOPASSWD: /usr/local/sbin/get-icmp
~~~~~
## Edit ~/microdep/etc/local.cfg :
#node_name=<node name> # default full domainame
#config_url=https://drift.uninett.no/microdep/dragonlab-rude.conf
## make initial config
### Start polling when ready :
crontab dragonlab/etc/crontab.cfg
crontab microdep/etc/crontab.cfg
##on server
##--------------------------------------------------------------------------------
##on server when running with central push :
rsync -rvt dragonlab user@host:
......
......@@ -12,6 +12,17 @@ T=$(env TZ=Europe/Oslo date +%T)
Tm=$(env TZ=Europe/Oslo date +%H:%M)
mkdir -p $logpath/$date
logdir=$logpath/$date
PIPE=$logdir/crude.pipe
PIPE2=$logdir/crude.pipe
if test ! -p $PIPE ; then
mkfifo $PIPE
fi
if test ! -p $PIPE2 ; then
mkfifo $PIPE2
fi
if test $Tm = "00:00" -o $stop = yes; then
pkill -u $USER -f $crude || echo crude kill failed
......@@ -22,28 +33,35 @@ if test $Tm = "00:00" -o $stop = yes; then
pkill -u $USER -f $vmstat || echo vmstat kill failed
sleep 3 # allow previous days proceses to die
fi
if ! pgrep -u $USER -f $crude >/dev/null; then
$crude -k -p $crude_port | gzip -c > $logpath/$date/crude-$T.gz 2> /dev/null&
fi
if ! pgrep -u $USER -f $rude >/dev/null; then
$rude -s $rudecfg > /dev/null 2> /dev/null &
fi
# crude outputs to a pipe that is read my tee to qstream-gap-ana
if ! pgrep -u $USER -f $crude >/dev/null; then
$crude -k -p $crude_port >> $PIPE &
fi
if ! pgrep -u $USER -f $root/bin/crude-zip >/dev/null; then
$root/bin/crude-zip $PIPE $PIPE2 $logpath/$date/crude-$T.gz &
fi
if ! pgrep -u $USER -f $crude >/dev/null; then
$root/bin/crude-ana "$index" $PIPE $event_dir/${index}-events-`date +%a`.log &
fi
if ! pgrep -u $USER -f $trace >/dev/null; then
$HOME/microdep/bin/start-trace.sh
$HOME/microdep/bin/start-trace.sh
fi
if ! pgrep -u $USER -f $tcptrace >/dev/null; then
$HOME/microdep/bin/start-tcptrace.sh
$HOME/microdep/bin/start-tcptrace.sh
fi
if ! pgrep -u $USER -f $vmstat >/dev/null; then
$vmstat 2> /dev/null > /dev/null&
$vmstat 2> /dev/null > /dev/null &
fi
if ! pgrep -u root -f '/usr/sbin/tcpdump.* icmp' >/dev/null; then
$HOME/microdep/bin/start-tcpdump.sh
$HOME/microdep/bin/start-icmp.sh &
fi
#! /bin/sh
set -e
INDEX=$1
PIPE=$2
LOG=$3
. $HOME/microdep/etc/start.cfg
if test -f "$LOG"; then
find "$LOG" -maxdepth 1 -mtime +5 -name '*.log' -type f -delete
fi
cat $PIPE | $root/bin/qstream-gap-ana \
-index $INDEX -json $LOG -minloss 5 -head -win 50 -jitter 60 -
exit 0
#! /bin/sh
set -e
cat "${1}" | tee "${3}" | gzip >> "${2}"
......@@ -6,5 +6,5 @@ IF=`ip route get 158.38.62.1 | perl -ne 'print $1 if / dev (\w+) /'`
if test "$IF" != ""
then
tomidnight=$((`date --date 'tomorrow 00:00' +%s`-`date +%s` - 1))
/usr/sbin/tcpdump -i $IF -G $tomidnight -W 1 -w - icmp
/usr/sbin/tcpdump -i $IF -G $tomidnight -W 1 -w - icmp &
fi
......@@ -4,6 +4,7 @@
my $target;
my $list='mp-list.txt';
my $default_port=10001;
use Getopt::Long;
@opts=( 'target=s' => \$target, 'list=s' => \$list);
......@@ -17,6 +18,9 @@ while(<LIST>){
$dns{$name}=$dns;
$port{$name}=$port;
}
if ($target && ! $port{$target} ){
$port{$target} = $default_port;
}
use Socket;
while(<>){
......@@ -28,19 +32,6 @@ 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 $rude; # fd to write config
......@@ -87,7 +78,8 @@ foreach $peer ( sort(keys %peers)){
}
if ($gotit){
if ($ip ){
printf $rude "0 %d ON 300%d %s:%s CONSTANT 100 64\n", $flow_no, $flow_no,$ip,$port{$dst};
printf $rude "0 %d ON 300%d %s:%s CONSTANT 100 64\n", $flow_no, $flow_no, $ip,
$port{$dst} || $default_port;;
printf $rude "90010000 %d OFF\n", $flow_no; # varer en dag +10 sek skuddr
@$tracetarget{$src} = () if ! $tracetarget{$src};
push (@{$tracetarget{$src}}, $ip );
......@@ -102,13 +94,14 @@ foreach $peer ( sort(keys %peers)){
close RUDE;
close $rude;
foreach $name ( keys %port){
if ( (! $target) || ( $target eq $name ) ){
$outdir=$name;
if ( -d $outdir ){
open ( $start, ">$outdir/start.cfg") || die "Could not open ${outdir}/start.cfg : $!" ;
printf $start "crude_port=%s\n", $port{$name};
printf $start "%s", $startcfg;
open ( $start, ">$outdir/parms.cfg") || die "Could not open ${outdir}/parms.cfg : $!" ;
printf $start "crude_port=%s\n", $port{$name} ;
# printf $start "%s", $startcfg;
close $start;
}
}
......
#!/bin/bash
source $HOME/microdep/etc/start.cfg
. $HOME/microdep/etc/start.cfg
dato=`date +%F-%T`
......
......@@ -2,21 +2,23 @@
# pick up changed config either in /etc or on web address
. $HOME/microdep/microdep/etc/start.cfg
. $HOME/microdep/etc/start.cfg
if test -s /etc/mp-rude/rude-list.conf ; then # distributed by puppet
if test /etc/mp-rude/rude-list.conf -nt $root/etc/rude.conf ; then
$root/bin/rude-config-maker -target $node $root/etc/rude-list.conf
if test ! -s $root/etc/rude.conf -o /etc/mp-rude/rude-list.conf -nt $root/etc/rude.conf; then
cd $root/etc
$root/bin/rude-config-maker -target "$node_name" /etc/mp-rude/rude-list.conf
fi
else # get config from server
tmp=/tmp/rude-list.conf$$
curl -z $root/etc/rude-list.conf -o $tmp http://drift.uninett.no/microdep/rude-list.conf
curl -z $root/etc/rude-list.conf -o $tmp "$config_url"
if test -s $tmp ; then
cp $tmp $root/etc/rude-list.conf
$root/bin/rude-config-maker -target $node $root/etc/rude-list.conf
cd $root/etc
cp $tmp $root/etc/rude-list.conf
$root/bin/rude-config-maker -target "$node_name" $root/etc/rude-list.conf
fi
if test -f $tmp
if test -f $tmp; then
rm $tmp
fi
fi
......
......@@ -4,11 +4,13 @@ set -e
rm -f *.deb
apt-get update
apt-get -y upgrade
if [ -f /.dockerenv ]; then
apt-get update
apt-get -y upgrade
fi
package="microdep"
version="0.1"
version="0.4"
target="${package}_${version}_all"
......
#/bin/bash
crude_port=10001
tcptrace_bin="/usr/sbin/tcptraceroute"
index="uninett"
root="$HOME/microdep"
logpath="$root/data"
event_dir="/var/log/mp-rude"
rudecfg="$root/etc/rude.cfg"
dump="$root/bin/starttcpdump.sh"
trace="$root/bin/trace.sh"
tcptrace="$root/bin/tcptrace.sh"
tcptrace_bin="/usr/sbin/tcptraceroute"
trace6="$root/bin/trace6.sh"
vmstat="$root/bin/vmstat.sh"
ntp="$root/bin/ntp-jitter.sh"
......@@ -14,6 +17,16 @@ crude="$root/bin/crude"
rude="$root/bin/rude"
date=`env TZ=Europe/Oslo date +%Y-%m-%d`
if test -f $root/etc/parms.cfg; then
. $root/etc/parms.cfg
fi
if test -f $root/etc/local.cfg; then
source $root/etc/local.cfg
. $root/etc/local.cfg
fi
if test ! -s "$node_name"; then
node_name=$(hostname -f)
fi
if test ! -s "$config_url"; then
config_url='http://drift.uninett.no/microdep/dragonlab-rude.conf'
fi
\ No newline at end of file
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