WS-A: systemd D-Bus source, example and tests

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YShymaPrXmc3KYRUg2HMSs
This commit is contained in:
ariandClaude Sonnet 5.5 committed 2026-10-15 17:59:25 -04:00
1 parent 2687ef5c33
commit 5e7a323020
4 files changed
+292 -24

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
//! 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<dyn std::error::Error>> {
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(())
}