//! Dump systemd state from the live system bus as JSON. //! Usage: cargo run --example systemd_dump [unit-name] use skyg_linux_tracker::config::Config; use skyg_linux_tracker::sources::systemd::DbusSystemd; use skyg_linux_tracker::sources::SystemdSource; use tokio_util::sync::CancellationToken; #[tokio::main] async fn main() -> Result<(), Box> { let unit = std::env::args() .nth(1) .unwrap_or_else(|| "dbus.service".to_string()); let src = DbusSystemd::new(&Config::default(), CancellationToken::new()); 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(()) }