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
005d12c5
Commit
005d12c5
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
036bdd8e
Changes
3
Expand all
Hide 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 @
005d12c5
...
...
@@ -2,7 +2,7 @@
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.unistd
cimport
pid_t
,
execlp
,
fork
,
sleep
...
...
@@ -14,6 +14,8 @@ from stdlib.fmt cimport sprintf
from
stdlib.string
cimport
string
from
stdlib.dirent
cimport
DIR
,
struct_dirent
,
opendir
,
readdir
,
closedir
from
posix.stdlib
cimport
realpath
from
posix.unistd
cimport
readlink
...
...
@@ -40,9 +42,8 @@ cdef cypclass Node activable:
void
format_node
(
self
):
self
.
formatted
=
sprintf
(
"""
\
{
"%s": {
"stat": %s
}
"path": "%s",
"stat": %s
},
"""
,
self
.
path
,
...
...
@@ -128,7 +129,6 @@ cdef cypclass DirNode(Node):
cdef
enum
:
BUFSIZE
=
64
*
1024
cdef
cypclass
FileNode
(
Node
):
string
md5_data
string
sha1_data
...
...
@@ -194,14 +194,13 @@ cdef cypclass FileNode(Node):
else
:
self
.
formatted
=
sprintf
(
"""
\
{
"%s": {
"stat": %s,
"digests": {
"md5": "%s",
"sha1": "%s",
"sha256": "%s",
"sha512": "%s"
}
"path": "%s",
"stat": %s,
"hash": {
"md5": "%s",
"sha1": "%s",
"sha256": "%s",
"sha512": "%s"
}
},
"""
,
...
...
@@ -235,10 +234,9 @@ cdef cypclass SymlinkNode(Node):
else
:
self
.
formatted
=
sprintf
(
"""
\
{
"%s": {
"stat": %s,
"target": "%s"
}
"path": "%s",
"stat": %s,
"target": "%s"
},
"""
,
self
.
path
,
...
...
@@ -250,21 +248,25 @@ cdef cypclass SymlinkNode(Node):
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
# 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
char
*
program_name
=
"fluentbit"
cdef
char
*
arg1
=
"-e"
cdef
char
*
arg2
=
"
/etc
/fluentbit_wendelin.so"
cdef
char
*
arg2
=
"
flb
/fluentbit_wendelin.so"
cdef
char
*
arg3
=
"-c"
cdef
char
*
arg4
=
"
/etc
/flb.conf"
cdef
char
*
arg4
=
"
flb
/flb.conf"
cdef
pid_t
child_pid
=
-
1
# DEBUG
child_pid
=
fork
()
# DEBUG
cdef
int
err
cdef
char
ip_address
[
100
]
cdef
FILE
*
address_path
=
fopen
(
"/sys/class/net/ens3/address"
,
"r"
)
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
)
else
:
# PARENT
...
...
@@ -290,11 +292,20 @@ cdef int start(string path) nogil:
if
p_stat
is
not
NULL
:
p_dev
=
p_stat
.
st_data
.
st_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
:
return
-
1
fprintf
(
stderr
,
"test 002
\
n
"
)
# DEBUG
fflush
(
stderr
)
# DEBUG
active_node
=
activate
(
consume
node
)
active_node
.
build_node
(
NULL
,
consume
dev_whitelist
,
consume
ignore_paths
)
...
...
@@ -310,7 +321,10 @@ cdef int start(string path) nogil:
printf
(
"WRITE_NOTE STAGE
\
n
\
n
"
)
# DEBUG
fscanf
(
address_path
,
"%s"
,
ip_address
)
fclose
(
address_path
)
fprintf
(
result
,
'[
\
n
'
)
fprintf
(
result
,
'"%s",
\
n
'
,
ip_address
)
node
.
write_node
(
result
)
fprintf
(
result
,
' {}
\
n
]
\
n
'
)
fprintf
(
result
,
'fluentbit_end
\
n
'
)
...
...
@@ -319,12 +333,10 @@ cdef int start(string path) nogil:
#""" # DEBUG
del
scheduler
fprintf
(
stderr
,
"WAITING [error version]
\
n
\
n
"
)
printf
(
"WAITING...
\
n
\
n
"
)
fprintf
(
stderr
,
"WAITING for fluent-bit to end
\
n
\
n
"
)
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.)
fprintf
(
stderr
,
"WAITING ENDS [error version]
\
n
\
n
"
)
printf
(
"WAITING ENDS NOW!
\
n
\
n
"
)
fprintf
(
stderr
,
"WAITING ENDS
\
n
\
n
"
)
return
0
...
...
scan-filesystem/cython/stable.main.pyx
0 → 100644
View file @
005d12c5
This diff is collapsed.
Click to expand it.
scan-filesystem/cython/test.main.pyx
0 → 100644
View file @
005d12c5
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