Skip to content
Snippets Groups Projects
Commit cd7d47d2 authored by DIEGO MICHELOTTO's avatar DIEGO MICHELOTTO
Browse files

Update connection_logger.sh, Makefile, builddeb.sh

parent ed88916c
No related branches found
No related tags found
No related merge requests found
Pipeline #76158 passed
......@@ -15,7 +15,7 @@
############################################################################
NAME := connection_logger
VERSION := 0.0.6
VERSION := 0.0.7
RELEASE := 1
......
......@@ -16,7 +16,7 @@
# limitations under the License. #
############################################################################
VERSION=0.0.6
VERSION=0.0.7
PREFIX=connection-logger-$VERSION
mkdir -p $PREFIX/etc/connection_logger
......
......@@ -65,36 +65,37 @@ then
fi
while true; do
# Remove died connection logger process
while read line; do
check_pid=$(echo $line | awk '{print $3}')
grep_pid=$(ps axu | grep $check_pid | grep -v grep | awk '{print $2}')
logThis "check pid if $check_pid is $grep_pid" "DEBUG"
if [ -z "$grep_pid" ]
then
if [ -z "$grep_pid" ]; then
sed -i "/$check_pid/d" "$rundir/$db"
logThis "removed $check_pid" "DEBUG"
fi
done < "$rundir/$db"
# kill connection logger of removed router
routers_list=$(ip netns list | grep qrouter | awk '{print $1}' | tr '\n' ' ')
routers_list=$(ip netns list | grep qrouter | awk '{print $1}')
monitored_routers=$(cat "$rundir/$db" | awk '{print $1 "_" $2}')
logThis "monitored router list:" "DEBUG"
logThis "$monitored_routers" "DEBUG"
logThis "$monitored_routers" "DEBUG"
for i in $monitored_routers; do
logThis "check if $i already exist" "DEBUG"
r=$(echo $i | awk -F '_' '{print $1}')
n=$(echo $i | awk -F '_' '{print $2}')
is_present=0
for j in $routers; do
if [ "$r" == "$j" ]
then
is_present=1
for j in $routers_list; do
if [ "$r" == "$j" ]; then
net_present=$(ip netns exec $i ip addr show $n)
if [ -n "$net" ]; then
is_present=1
break
fi
fi
done
......@@ -102,38 +103,34 @@ while true; do
then
logThis "router $r with $n not present any more: kill related process" "INFO"
kill_pid=$(cat "$rundir/$db" | grep "$r $n" | awk '{print $3}')
if [ ! -z "$kill_pid" ]
then
if [ -n "$kill_pid" ]; then
kill $kill_pid
fi
sed -i "/$kill_pid/d" "$rundir/$db"
fi
done
# analyze router, create connection logger process if it is necessary
routers=$(ip netns list | grep qrouter | awk '{print $1}')
logThis "routers list:" "DEBUG"
logThis "$routers" "DEBUG"
for i in $routers; do
logThis "analyze router $i" "DEBUG"
if=$(ip netns exec $i ip link | grep qr- | awk '{print $2}' | tr '@' ' ' | awk '{print $1}')
for j in $if; do
interfaces=$(ip netns exec $i ip link | grep qr- | awk '{print $2}' | tr '@' ' ' | awk '{print $1}')
for j in $interfaces; do
net=$(ip netns exec $i ip addr show $j | grep 'inet ' | awk '{print $2}')
logThis "check if router $i with $net is master" "DEBUG"
if [ ! -z "$net" ]
then
if [ -n "$net" ]; then
pid_router=$(grep "$i $net" "$rundir/$db" | awk '{print $3}')
if [ -z "$pid_router" ]
then
if [ -z "$pid_router" ]; then
process=''
else
process=$(ps aux | grep $pid_router | grep -v grep | awk '{print $11}' | grep conntrack)
fi
logThis "check if $pid_router already exists and it is conntrack process: $process" "DEBUG"
if [ -z "$process" ]
then
if [ -z "$process" ]; then
logThis "router $i is master for $net creating connection logger process" "INFO"
ip netns exec $i conntrack $filter -s $net &
echo "$i $net $!" >> "$rundir/$db"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment