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
5587749f
Commit
5587749f
authored
Oct 20, 2021
by
Ophélie Gagnard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify the json string to that directories' path and with '/'.
parent
8eb14c23
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
52 deletions
+24
-52
scan-filesystem/cython/main.pyx
scan-filesystem/cython/main.pyx
+23
-34
scan-filesystem/cython/stdlib/stat.pxd
scan-filesystem/cython/stdlib/stat.pxd
+1
-18
No files found.
scan-filesystem/cython/main.pyx
View file @
5587749f
...
...
@@ -40,12 +40,7 @@ cdef cypclass Node activable:
pass
void
format_node
(
self
):
self
.
formatted
=
sprintf
(
"""
\
{
"path": "%s",
"stat": %s
},
"""
,
self
.
formatted
=
sprintf
(
"""{"path": "%s", "stat": %s}
\
n
"""
,
self
.
path
,
self
.
st
.
to_json
(),
)
...
...
@@ -117,6 +112,12 @@ cdef cypclass DirNode(Node):
for
active_child
in
self
.
children
:
active_child
.
build_node
(
NULL
,
dev_whitelist
,
ignore_paths
)
void
format_node
(
self
):
self
.
formatted
=
sprintf
(
"""{"path": "%s/", "stat": %s}
\
n
"""
,
self
.
path
,
self
.
st
.
to_json
(),
)
void
write_node
(
self
,
FILE
*
stream
):
fwrite
(
self
.
formatted
.
data
(),
1
,
self
.
formatted
.
size
(),
stream
)
while
self
.
children
.
__len__
()
>
0
:
...
...
@@ -192,18 +193,7 @@ cdef cypclass FileNode(Node):
if
self
.
error
:
Node
.
format_node
(
self
)
else
:
self
.
formatted
=
sprintf
(
"""
\
{
"path": "%s",
"stat": %s,
"hash": {
"md5": "%s",
"sha1": "%s",
"sha256": "%s",
"sha512": "%s"
}
},
"""
,
self
.
formatted
=
sprintf
(
"""{"path": "%s", "stat": %s, "hash": {"md5": "%s", "sha1": "%s", "sha256": "%s", "sha512": "%s"}}
\
n
"""
,
self
.
path
,
self
.
st
.
to_json
(),
self
.
md5_data
,
...
...
@@ -232,13 +222,7 @@ cdef cypclass SymlinkNode(Node):
if
self
.
error
:
Node
.
format_node
(
self
)
else
:
self
.
formatted
=
sprintf
(
"""
\
{
"path": "%s",
"stat": %s,
"target": "%s"
},
"""
,
self
.
formatted
=
sprintf
(
"""{"path": "%s", "stat": %s, "target": "%s"}
\
n
"""
,
self
.
path
,
self
.
st
.
to_json
(),
self
.
target
,
...
...
@@ -269,7 +253,6 @@ cdef int start(const char *path) nogil:
err
=
execlp
(
"flb/fluent-bit"
,
program_name
,
arg1
,
arg2
,
arg3
,
arg4
,
0
)
fprintf
(
stderr
,
"ERROR with execlp() in CHILD: %d
\
n
"
,
err
)
else
:
# PARENT
printf
(
"WELCOME TO PARENT
\
n
\
n
"
)
# DEBUG
sleep
(
2
)
# TODO error handling ; check if a wait can be made to wait for the child to perform execlp() (instead of the sleep)
...
...
@@ -307,26 +290,32 @@ cdef int start(const char *path) nogil:
fflush
(
stderr
)
# DEBUG
active_node
=
activate
(
consume
node
)
fprintf
(
stderr
,
'test 003
\
n
'
)
# DEBUG
fflush
(
stderr
)
# DEBUG
active_node
.
build_node
(
NULL
,
consume
dev_whitelist
,
consume
ignore_paths
)
fprintf
(
stderr
,
'test 004
\
n
'
)
# DEBUG
fflush
(
stderr
)
# DEBUG
scheduler
.
finish
()
fprintf
(
stderr
,
'test 005
\
n
'
)
# DEBUG
fflush
(
stderr
)
# DEBUG
node
=
consume
active_node
#""" # DEBUG
result
=
fopen
(
'/var/log/metadata_collect.log'
,
'w'
)
if
result
is
NULL
:
fprintf
(
stderr
,
'Error creating the log file.
\
n
'
)
# DEBUG
fflush
(
stderr
)
return
-
1
printf
(
"WRITE_NOTE STAGE
\
n
\
n
"
)
# DEBUG
fprintf
(
stderr
,
'Log opened successfully.
\
n
'
)
# DEBUG
fprintf
(
stderr
,
"WRITE_NOTE STAGE
\
n
\
n
"
)
# DEBUG
fscanf
(
address_path
,
"%s"
,
ip_address
)
fclose
(
address_path
)
fprintf
(
result
,
'[
\
n
'
)
fprintf
(
result
,
'"%s",
\
n
'
,
ip_address
)
fprintf
(
result
,
'{"mac_address": "%s"}
\
n
'
,
ip_address
)
node
.
write_node
(
result
)
fprintf
(
result
,
'
{}
\
n
]
\
n
'
)
fprintf
(
result
,
'
{}
\
n
'
)
fprintf
(
result
,
'fluentbit_end
\
n
'
)
fclose
(
result
)
...
...
@@ -337,7 +326,7 @@ cdef int start(const char *path) nogil:
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
\
n
\
n
"
)
fflush
(
stderr
)
# DEBUG
return
0
...
...
scan-filesystem/cython/stdlib/stat.pxd
View file @
5587749f
...
...
@@ -108,24 +108,7 @@ cdef cypclass Stat:
return
S_ISDIR
(
self
.
st_data
.
st_mode
)
string
to_json
(
self
):
return
sprintf
(
"""{
"st_dev": %lu,
"st_ino": %lu,
"st_mode": %lu,
"st_nlink": %lu,
"st_uid": %d,
"st_gid": %d,
"st_rdev": %lu,
"st_size": %ld,
"st_blksize": %ld,
"st_blocks": %ld,
"st_atime": %ld,
"st_mtime": %ld,
"st_ctime": %ld,
"st_atime_ns": %ld,
"st_mtime_ns": %ld,
"st_ctime_ns": %ld
}"""
,
return
sprintf
(
"""{"st_dev": %lu, "st_ino": %lu, "st_mode": %lu, "st_nlink": %lu, "st_uid": %d, "st_gid": %d, "st_rdev": %lu, "st_size": %ld, "st_blksize": %ld, "st_blocks": %ld, "st_atime": %ld, "st_mtime": %ld, "st_ctime": %ld, "st_atime_ns": %ld, "st_mtime_ns": %ld, "st_ctime_ns": %ld}"""
,
self
.
st_data
.
st_dev
,
self
.
st_data
.
st_ino
,
self
.
st_data
.
st_mode
,
...
...
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