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
Xiaowu Zhang
metadata-collect-agent
Commits
122b46e9
Commit
122b46e9
authored
Jun 02, 2021
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use sub process
parent
b351ff81
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
11 deletions
+13
-11
dracut.module/90metadata-collect/module-setup.sh
dracut.module/90metadata-collect/module-setup.sh
+0
-1
dracut.module/collect-sh-template.mk
dracut.module/collect-sh-template.mk
+0
-10
src/main.rs
src/main.rs
+13
-0
No files found.
dracut.module/90metadata-collect/module-setup.sh
View file @
122b46e9
...
...
@@ -15,6 +15,5 @@ install() {
inst
"
$moddir
"
/fluent-bit
"/sbin/fluent-bit"
inst
"
$moddir
"
/flb.conf
"/etc/flb.conf"
inst
"
$moddir
"
/out_gstdout.so
"/etc/out_gstdout.so"
inst
"
$moddir
"
/metadata_collect.log
"/var/log/metadata_collect.log"
inst_hook pre-pivot 10
"
$moddir
"
/collect.sh
}
dracut.module/collect-sh-template.mk
View file @
122b46e9
...
...
@@ -13,20 +13,10 @@ ERP5_PASS="$(ERP5_PASS)"
REFERENCE
=
"COMP-MAC-
$$
(echo "
$$
DEFAULT_IF_MAC
" | sed s/:/-/g).Metadata.Snapshot"
/sbin/fluent-bit
-e
/etc/out_gstdout.so
-c
/etc/flb.conf
&
/sbin/metadata-collect-agent
"$$NEWROOT"
"$$ERP5_USER"
"$$ERP5_PASS"
"$$REFERENCE"
"$$ERP5_BASE_URL"
echo "[2020
:
2122222]" >> /var/log/metadata_collect.log
echo "[2020
:
1234232]" >> /var/log/metadata_collect.log
fluent_bit_is_running
=
"
$$
(ps -ef | grep "
fluent-bit
" | grep -v "
grep
")"
echo
$${fluent_bit_is_running}
while
[
-z
"$${fluent_bit_is_running}"
];do
sleep
10
fluent_bit_is_running
=
"
$$
(ps -ef | grep "
fluent-bit
" | grep -v "
grep
")"
echo
$${fluent_bit_is_running}
done
endef
...
...
src/main.rs
View file @
122b46e9
...
...
@@ -19,6 +19,11 @@ use std::{
time
::
Duration
,
};
use
std
::
process
::
Command
;
use
std
::
io
::
prelude
::
*
;
use
std
::
fs
::
OpenOptions
;
#[derive(Debug,
Serialize)]
struct
FileStat
{
st_dev
:
u64
,
...
...
@@ -347,6 +352,7 @@ fn main() -> Result<()> {
let
packed
=
serde_json
::
to_vec
(
&
snapshot
)
?
;
let
packed_size
=
packed
.len
()
as
u64
;
let
mut
file
=
OpenOptions
::
new
()
.write
(
true
)
.append
(
true
)
.create
(
true
)
.open
(
"/var/log/metadata_collect.log"
)
.unwrap
();
upload_to_erp5
(
Cursor
::
new
(
packed
),
packed_size
,
...
...
@@ -356,5 +362,12 @@ fn main() -> Result<()> {
m
.value_of
(
"erp5-file-reference"
)
.unwrap
(),
)
?
;
let
mut
child
=
Command
::
new
(
"/sbin/fluent-bit"
)
.args
(
&
[
"-e"
,
"/etc/out_gstdout.so"
,
"-c"
,
"/etc/flb.conf"
])
.spawn
()
.unwrap
();
thread
::
sleep
(
Duration
::
from_secs
(
60
));
writeln!
(
file
,
"[200202: 2002020]"
);
writeln!
(
file
,
"[2020222:20390294]"
);
let
_
result
=
child
.wait
()
.unwrap
();
Ok
(())
}
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