Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YShymaPrXmc3KYRUg2HMSs
22 lines
743 B
Rust
22 lines
743 B
Rust
//! Dump systemd state from the live system bus as JSON.
|
|
//! Usage: cargo run --example systemd_dump [unit-name]
|
|
|
|
use skyg_linux_tracker::sources::systemd::DbusSystemd;
|
|
use skyg_linux_tracker::sources::SystemdSource;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
let unit = std::env::args()
|
|
.nth(1)
|
|
.unwrap_or_else(|| "dbus.service".to_string());
|
|
let src = DbusSystemd::default();
|
|
let out = serde_json::json!({
|
|
"units": src.list_units(None).await?,
|
|
"failed": src.list_units(Some("failed")).await?,
|
|
"timers": src.list_timers().await?,
|
|
"status": src.unit_status(&unit).await?,
|
|
});
|
|
println!("{}", serde_json::to_string_pretty(&out)?);
|
|
Ok(())
|
|
}
|