Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
metadata-collect-agent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
metadata-collect-agent
Commits
8eb14c23
Commit
8eb14c23
authored
Sep 24, 2021
by
Ophélie Gagnard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send a better data structure to Wendelin. Send a string which is json-compliant again.
parent
3ef89618
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
730 additions
and
27 deletions
+730
-27
scan-filesystem/cython/main.pyx
scan-filesystem/cython/main.pyx
+39
-27
scan-filesystem/cython/stable.main.pyx
scan-filesystem/cython/stable.main.pyx
+339
-0
scan-filesystem/cython/test.main.pyx
scan-filesystem/cython/test.main.pyx
+352
-0
No files found.
scan-filesystem/cython/main.pyx
View file @
8eb14c23
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
from
libcythonplus.list
cimport
cyplist
from
libcythonplus.list
cimport
cyplist
from
libc.stdio
cimport
fprintf
,
fopen
,
fclose
,
fread
,
fwrite
,
FILE
,
stdout
,
stderr
,
printf
,
ferror
from
libc.stdio
cimport
fprintf
,
fopen
,
fclose
,
fread
,
fwrite
,
FILE
,
stdout
,
stderr
,
printf
,
ferror
,
fscanf
,
fflush
from
runtime.runtime
cimport
SequentialMailBox
,
BatchMailBox
,
NullResult
,
Scheduler
from
runtime.runtime
cimport
SequentialMailBox
,
BatchMailBox
,
NullResult
,
Scheduler
from
runtime.unistd
cimport
pid_t
,
execlp
,
fork
,
sleep
from
runtime.unistd
cimport
pid_t
,
execlp
,
fork
,
sleep
...
@@ -14,6 +14,8 @@ from stdlib.fmt cimport sprintf
...
@@ -14,6 +14,8 @@ from stdlib.fmt cimport sprintf
from
stdlib.string
cimport
string
from
stdlib.string
cimport
string
from
stdlib.dirent
cimport
DIR
,
struct_dirent
,
opendir
,
readdir
,
closedir
from
stdlib.dirent
cimport
DIR
,
struct_dirent
,
opendir
,
readdir
,
closedir
from
posix.stdlib
cimport
realpath
from
posix.unistd
cimport
readlink
from
posix.unistd
cimport
readlink
...
@@ -40,9 +42,8 @@ cdef cypclass Node activable:
...
@@ -40,9 +42,8 @@ cdef cypclass Node activable:
void
format_node
(
self
):
void
format_node
(
self
):
self
.
formatted
=
sprintf
(
"""
\
self
.
formatted
=
sprintf
(
"""
\
{
{
"
%s": {
"
path": "%s",
"stat": %s
"stat": %s
}
},
},
"""
,
"""
,
self
.
path
,
self
.
path
,
...
@@ -128,7 +129,6 @@ cdef cypclass DirNode(Node):
...
@@ -128,7 +129,6 @@ cdef cypclass DirNode(Node):
cdef
enum
:
cdef
enum
:
BUFSIZE
=
64
*
1024
BUFSIZE
=
64
*
1024
cdef
cypclass
FileNode
(
Node
):
cdef
cypclass
FileNode
(
Node
):
string
md5_data
string
md5_data
string
sha1_data
string
sha1_data
...
@@ -194,15 +194,14 @@ cdef cypclass FileNode(Node):
...
@@ -194,15 +194,14 @@ cdef cypclass FileNode(Node):
else
:
else
:
self
.
formatted
=
sprintf
(
"""
\
self
.
formatted
=
sprintf
(
"""
\
{
{
"
%s": {
"
path": "%s",
"stat": %s,
"stat": %s,
"digests
": {
"hash
": {
"md5": "%s",
"md5": "%s",
"sha1": "%s",
"sha1": "%s",
"sha256": "%s",
"sha256": "%s",
"sha512": "%s"
"sha512": "%s"
}
}
}
},
},
"""
,
"""
,
self
.
path
,
self
.
path
,
...
@@ -235,10 +234,9 @@ cdef cypclass SymlinkNode(Node):
...
@@ -235,10 +234,9 @@ cdef cypclass SymlinkNode(Node):
else
:
else
:
self
.
formatted
=
sprintf
(
"""
\
self
.
formatted
=
sprintf
(
"""
\
{
{
"
%s": {
"
path": "%s",
"stat": %s,
"stat": %s,
"target": "%s"
"target": "%s"
}
},
},
"""
,
"""
,
self
.
path
,
self
.
path
,
...
@@ -250,21 +248,25 @@ cdef cypclass SymlinkNode(Node):
...
@@ -250,21 +248,25 @@ cdef cypclass SymlinkNode(Node):
fwrite
(
self
.
formatted
.
data
(),
1
,
self
.
formatted
.
size
(),
stream
)
fwrite
(
self
.
formatted
.
data
(),
1
,
self
.
formatted
.
size
(),
stream
)
cdef
int
start
(
string
path
)
nogil
:
cdef
int
start
(
const
char
*
path
)
nogil
:
printf
(
"TEST TEST TEST TEST TEST
\
n
\
n
"
)
# DEBUG
printf
(
"TEST TEST TEST TEST TEST
\
n
\
n
"
)
# DEBUG
# TODO replace 4096 by PATH_MAX (yet it will not be perfect)
cdef
char
resolved_path
[
4096
]
cdef
pid_t
wait_error
=
-
1
# DEBUG
cdef
pid_t
wait_error
=
-
1
# DEBUG
cdef
char
*
program_name
=
"fluentbit"
cdef
char
*
program_name
=
"fluentbit"
cdef
char
*
arg1
=
"-e"
cdef
char
*
arg1
=
"-e"
cdef
char
*
arg2
=
"
/etc
/fluentbit_wendelin.so"
cdef
char
*
arg2
=
"
flb
/fluentbit_wendelin.so"
cdef
char
*
arg3
=
"-c"
cdef
char
*
arg3
=
"-c"
cdef
char
*
arg4
=
"
/etc
/flb.conf"
cdef
char
*
arg4
=
"
flb
/flb.conf"
cdef
pid_t
child_pid
=
-
1
# DEBUG
cdef
pid_t
child_pid
=
-
1
# DEBUG
child_pid
=
fork
()
# DEBUG
child_pid
=
fork
()
# DEBUG
cdef
int
err
cdef
int
err
cdef
char
ip_address
[
100
]
cdef
FILE
*
address_path
=
fopen
(
"/sys/class/net/ens3/address"
,
"r"
)
if
child_pid
==
0
:
# CHILD
if
child_pid
==
0
:
# CHILD
err
=
execlp
(
"
/sbin
/fluent-bit"
,
program_name
,
arg1
,
arg2
,
arg3
,
arg4
,
0
)
err
=
execlp
(
"
flb
/fluent-bit"
,
program_name
,
arg1
,
arg2
,
arg3
,
arg4
,
0
)
fprintf
(
stderr
,
"ERROR with execlp() in CHILD: %d
\
n
"
,
err
)
fprintf
(
stderr
,
"ERROR with execlp() in CHILD: %d
\
n
"
,
err
)
else
:
# PARENT
else
:
# PARENT
...
@@ -291,10 +293,19 @@ cdef int start(string path) nogil:
...
@@ -291,10 +293,19 @@ cdef int start(string path) nogil:
p_dev
=
p_stat
.
st_data
.
st_dev
p_dev
=
p_stat
.
st_data
.
st_dev
dev_whitelist
.
append
(
p_dev
)
dev_whitelist
.
append
(
p_dev
)
node
=
make_node
(
path
,
path
)
fprintf
(
stderr
,
"test 001
\
n
"
)
# DEBUG
fflush
(
stderr
)
# DEBUG
realpath
(
path
,
resolved_path
)
fprintf
(
stderr
,
resolved_path
)
# DEBUG
fprintf
(
stderr
,
"
\
n
"
)
# DEBUG
fflush
(
stderr
)
# DEBUG
node
=
make_node
(
resolved_path
,
resolved_path
)
if
node
is
NULL
:
if
node
is
NULL
:
return
-
1
return
-
1
fprintf
(
stderr
,
"test 002
\
n
"
)
# DEBUG
fflush
(
stderr
)
# DEBUG
active_node
=
activate
(
consume
node
)
active_node
=
activate
(
consume
node
)
active_node
.
build_node
(
NULL
,
consume
dev_whitelist
,
consume
ignore_paths
)
active_node
.
build_node
(
NULL
,
consume
dev_whitelist
,
consume
ignore_paths
)
...
@@ -310,7 +321,10 @@ cdef int start(string path) nogil:
...
@@ -310,7 +321,10 @@ cdef int start(string path) nogil:
printf
(
"WRITE_NOTE STAGE
\
n
\
n
"
)
# DEBUG
printf
(
"WRITE_NOTE STAGE
\
n
\
n
"
)
# DEBUG
fscanf
(
address_path
,
"%s"
,
ip_address
)
fclose
(
address_path
)
fprintf
(
result
,
'[
\
n
'
)
fprintf
(
result
,
'[
\
n
'
)
fprintf
(
result
,
'"%s",
\
n
'
,
ip_address
)
node
.
write_node
(
result
)
node
.
write_node
(
result
)
fprintf
(
result
,
' {}
\
n
]
\
n
'
)
fprintf
(
result
,
' {}
\
n
]
\
n
'
)
fprintf
(
result
,
'fluentbit_end
\
n
'
)
fprintf
(
result
,
'fluentbit_end
\
n
'
)
...
@@ -319,12 +333,10 @@ cdef int start(string path) nogil:
...
@@ -319,12 +333,10 @@ cdef int start(string path) nogil:
#""" # DEBUG
#""" # DEBUG
del
scheduler
del
scheduler
fprintf
(
stderr
,
"WAITING [error version]
\
n
\
n
"
)
fprintf
(
stderr
,
"WAITING for fluent-bit to end
\
n
\
n
"
)
printf
(
"WAITING...
\
n
\
n
"
)
wait_error
=
wait
(
NULL
)
# TODO improve this call (error handling, etc.)
wait_error
=
wait
(
NULL
)
# TODO improve this call (error handling, etc.)
#wait_error = waitpid(child_pid, NULL, 1) # TODO improve this call (error handling, etc.)
#wait_error = waitpid(child_pid, NULL, 1) # TODO improve this call (error handling, etc.)
fprintf
(
stderr
,
"WAITING ENDS [error version]
\
n
\
n
"
)
fprintf
(
stderr
,
"WAITING ENDS
\
n
\
n
"
)
printf
(
"WAITING ENDS NOW!
\
n
\
n
"
)
return
0
return
0
...
...
scan-filesystem/cython/stable.main.pyx
0 → 100644
View file @
8eb14c23
This diff is collapsed.
Click to expand it.
scan-filesystem/cython/test.main.pyx
0 → 100644
View file @
8eb14c23
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment