Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
connection_logger
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DIEGO MICHELOTTO
connection_logger
Commits
cd7d47d2
Commit
cd7d47d2
authored
2 years ago
by
DIEGO MICHELOTTO
Browse files
Options
Downloads
Patches
Plain Diff
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
2 years ago
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+1
-1
1 addition, 1 deletion
Makefile
builddeb.sh
+1
-1
1 addition, 1 deletion
builddeb.sh
connection_logger.sh
+21
-24
21 additions, 24 deletions
connection_logger.sh
with
23 additions
and
26 deletions
Makefile
+
1
−
1
View file @
cd7d47d2
...
...
@@ -15,7 +15,7 @@
############################################################################
NAME
:=
connection_logger
VERSION
:=
0.0.
6
VERSION
:=
0.0.
7
RELEASE
:=
1
...
...
This diff is collapsed.
Click to expand it.
builddeb.sh
+
1
−
1
View file @
cd7d47d2
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
connection_logger.sh
+
21
−
24
View file @
cd7d47d2
...
...
@@ -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"
i
f
=
$(
ip netns
exec
$i
ip
link
|
grep
qr- |
awk
'{print $2}'
|
tr
'@'
' '
|
awk
'{print $1}'
)
for
j
in
$i
f
;
do
i
nterfaces
=
$(
ip netns
exec
$i
ip
link
|
grep
qr- |
awk
'{print $2}'
|
tr
'@'
' '
|
awk
'{print $1}'
)
for
j
in
$i
nterfaces
;
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
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment