Skip to content

Commit

Permalink
scope(daemon) implement listing processes
Browse files Browse the repository at this point in the history
The list is generated via the procfs crate. The following information is
being transmitted via grpc: pid, ppid, comm, state, cmdline

Signed-off-by: Mr-Kanister <[email protected]>
  • Loading branch information
Mr-Kanister committed Nov 17, 2024
1 parent a585dfc commit 74b695e
Show file tree
Hide file tree
Showing 10 changed files with 269 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# SPDX-FileCopyrightText: 2024 Robin Seidl <[email protected]>
# SPDX-FileCopyrightText: 2024 The AMOS Projects
#
# SPDX-License-Identifier: MIT
Expand Down Expand Up @@ -47,4 +48,4 @@ target
sbom.json

.codebuddy/

build
3 changes: 3 additions & 0 deletions rust/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: 2024 Benedikt Zinn <[email protected]>
# SPDX-FileCopyrightText: 2024 Felix Hilgers <[email protected]>
# SPDX-FileCopyrightText: 2024 Luca Bretting <[email protected]>
# SPDX-FileCopyrightText: 2024 Robin Seidl <[email protected]>
#
# SPDX-License-Identifier: MIT

Expand All @@ -13,3 +14,5 @@ target/

# These are backup files generated by rustfmt
**/*.rs.bk

ziofa.json
201 changes: 201 additions & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: 2024 Benedikt Zinn <[email protected]>
# SPDX-FileCopyrightText: 2024 Felix Hilgers <[email protected]>
# SPDX-FileCopyrightText: 2024 Luca Bretting <[email protected]>
# SPDX-FileCopyrightText: 2024 Robin Seidl <[email protected]>
#
# SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -46,6 +47,7 @@ backend-daemon = { path = "./backend/daemon" }
backend-ebpf = { path = "./backend/ebpf" }
tracing = { version = "0.1.40" }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
procfs = "0.17.0"

[profile.dev]
panic = "abort"
Expand Down
1 change: 1 addition & 0 deletions rust/backend/daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ thiserror = { workspace = true }
backend-common = { workspace = true, features = ["user"] }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
procfs = {workspace = true}

[build-dependencies]
cargo_metadata = { workspace = true }
Expand Down
15 changes: 15 additions & 0 deletions rust/backend/daemon/src/bin/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: 2024 Benedikt Zinn <[email protected]>
// SPDX-FileCopyrightText: 2024 Robin Seidl <[email protected]>
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -39,5 +40,19 @@ async fn main() {
println!("Error trying to set configuration");
println!("{:?}", e);
}
};

let processes = client.list_processes(()).await.and_then(|op| {
Ok(op.into_inner())
});
match processes {
Err(e) => println!("Error getting the process list: {:?}", e),
Ok(pl) => {
println!("Processes:");
println!("pid | ppid | comm | state | cmdline");
for p in pl.processes {
println!("{} | {} | {} | {} | {}", p.pid, p.ppid, p.comm, p.state, p.cmdline)
}
},
}
}
2 changes: 2 additions & 0 deletions rust/backend/daemon/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: 2024 Benedikt Zinn <[email protected]>
// SPDX-FileCopyrightText: 2024 Robin Seidl <[email protected]>
//
// SPDX-License-Identifier: MIT

Expand All @@ -10,6 +11,7 @@ pub mod counter;
mod ebpf_utils;
mod helpers;
mod server;
mod procfs_utils;

#[tokio::main]
async fn main() {
Expand Down
Loading

0 comments on commit 74b695e

Please sign in to comment.