sandbox_rs/monitoring/
mod.rs

1//! Monitoring layer: Process and syscall monitoring
2//!
3//! This module provides real-time monitoring of sandboxed processes,
4//! including resource usage tracking via /proc and syscall tracing via eBPF.
5//!
6//! # Features
7//!
8//! - **/proc-based monitoring**: Track memory, CPU, and process state
9//! - **eBPF syscall tracing**: Event-driven syscall monitoring
10//! - **Performance metrics**: Detect slow operations (>10ms)
11//! - **Resource statistics**: Peak memory, CPU time, thread count
12//! - **Graceful shutdown**: SIGTERM → SIGKILL progression
13//!
14//! # Examples
15//!
16//! ```ignore
17//! use sandbox_rs::monitoring::ProcessMonitor;
18//!
19//! let monitor = ProcessMonitor::new(pid)?;
20//! let stats = monitor.collect_stats()?;
21//! println!("Memory: {}MB", stats.memory_usage_mb);
22//! println!("CPU time: {}ms", stats.cpu_time_ms);
23//! ```
24
25pub mod ebpf;
26pub mod monitor;
27pub use ebpf::EBpfMonitor;
28pub use monitor::{ProcessMonitor, ProcessState, ProcessStats};
29
30#[cfg(test)]
31mod tests;