Commit e16602ea authored by Kolbjørn Barmen's avatar Kolbjørn Barmen

Bare rydde litt i formattering av shell-script

parent 3d9b1df1
Pipeline #17298 passed with stages
in 56 seconds
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
# pick interface with default route # pick interface with default route
IF=`ip route get 158.38.62.1 | perl -ne 'print $1 if / dev (\w+) /'` IF=`ip route get 158.38.62.1 | perl -ne 'print $1 if / dev (\w+) /'`
if test "$IF" != ""; then if test "$IF" != ""
tomidnight=$((`date --date 'tomorrow 00:00' +%s`-`date +%s` - 1)) then
tomidnight=$((`date --date 'tomorrow 00:00' +%s`-`date +%s` - 1))
/usr/sbin/tcpdump -i $IF -G $tomidnight -W 1 -w ${logpath}/icmp-%F-%T.pcap icmp 2> ${logpath}/icmp.log /usr/sbin/tcpdump -i $IF -G $tomidnight -W 1 -w ${logpath}/icmp-%F-%T.pcap icmp 2> ${logpath}/icmp.log
fi fi
...@@ -7,19 +7,19 @@ set -e ...@@ -7,19 +7,19 @@ set -e
log="${logpath}"/"${date}"/"traceroute_$1" log="${logpath}"/"${date}"/"traceroute_$1"
pidfile=${pidfile:-/run/mp-rude.pids} pidfile=${pidfile:-/run/mp-rude.pids}
if [ -f "${pidfile}" ] ; then if [ -f "${pidfile}" ]
then
echo "ERROR: ${pidfile} already exists!" echo "ERROR: ${pidfile} already exists!"
exit 1 exit 1
fi fi
#Start traceroute #Start traceroute
for i in $(cat ${traceconf}) ; do for i in $(cat ${traceconf})
do
${trace} ${i} 23:59 > /dev/null 2>&1 & ${trace} ${i} 23:59 > /dev/null 2>&1 &
echo "$!" >> "${pidfile}" echo "$!" >> "${pidfile}"
done done
# start tcpdump og icmp # start tcpdump og icmp
$bin/start-icmp $bin/start-icmp
...@@ -7,20 +7,23 @@ set -e ...@@ -7,20 +7,23 @@ set -e
pidfile=${pidfile:-/run/mp-rude.pids} pidfile=${pidfile:-/run/mp-rude.pids}
if [ ! -e "${pidfile}" ] if [ ! -e "${pidfile}" ]
then then
echo "Pid file does not exist: ${pidfile}" echo "Pid file does not exist: ${pidfile}"
exit exit
fi fi
if test $1. != . ; then if test $1. != .
sleep $1 # wait a few seconds closer to midnight then
sleep $1 # wait a few seconds closer to midnight
fi fi
for pid in $(cat "${pidfile}"); do for pid in $(cat "${pidfile}")
if [ -d /proc/"${pid}" ] ; then do
grep -q trace.sh /proc/"${pid}"/cmdline && kill ${pid} if [ -d /proc/"${pid}" ]
fi then
done grep -q trace.sh /proc/"${pid}"/cmdline && kill ${pid}
fi
done
rm -f "${pidfile}" rm -f "${pidfile}"
......
...@@ -9,20 +9,23 @@ pidfile=${pidfile:-/run/mp-rude.pids} ...@@ -9,20 +9,23 @@ pidfile=${pidfile:-/run/mp-rude.pids}
mkdir -p "${logpath}"/"${date}" mkdir -p "${logpath}"/"${date}"
log="${logpath}"/"${date}"/"traceroute_$1" log="${logpath}"/"${date}"/"traceroute_$1"
if test $2. -ne . ; then if test $2. -ne .
then
end=$(date --date "$2" +%s) end=$(date --date "$2" +%s)
else else
end=$(date --date "2099-12-31" +%s) end=$(date --date "2099-12-31" +%s)
fi fi
# ( flock -n 9 || ( echo "=== could not start traceroute - locked $log.lock ===" ; exit 1 ) # ( flock -n 9 || ( echo "=== could not start traceroute - locked $log.lock ===" ; exit 1 )
# > $log.log # > $log.log
while test $(date +%s) -lt ${end} ; do while test $(date +%s) -lt ${end}
do
date "+%s starttime %T" | gzip -c >> ${log}.gz date "+%s starttime %T" | gzip -c >> ${log}.gz
traceroute -q 6 -n $1 2> /dev/null | gzip -c >> ${log}.gz traceroute -q 6 -n $1 2> /dev/null | gzip -c >> ${log}.gz
sleep 60 sleep 60
done done
#) 9> $log.lock & #) 9> $log.lock &
#echo "$!" >> ${pidfile} #echo "$!" >> ${pidfile}
......
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