Implement asset inventory

This commit is contained in:
2026-05-08 23:05:45 +02:00
parent a2c79e56d3
commit b59be25a16
7 changed files with 542 additions and 3 deletions
+19
View File
@@ -23,6 +23,7 @@
mod cli;
mod config_import;
mod inventory;
#[cfg(target_os = "windows")]
mod cm_popup;
@@ -30,6 +31,8 @@ mod cm_popup;
mod service;
#[cfg(target_os = "windows")]
mod unattended_password;
#[cfg(target_os = "windows")]
mod wifi_native;
use cli::{Action, ParsedArgs};
@@ -206,6 +209,22 @@ fn run_server() {
),
}
// Kick off CMDB inventory collection on a background thread before
// start_server boots. PowerShell's first-run cost (a few hundred ms
// to a few seconds) shouldn't delay the rendezvous heartbeat — the
// sysinfo upload loop only fires every TIME_CONN seconds, so the
// inventory will be ready in time for the very first /api/sysinfo
// POST whether collection finishes in 50ms or 5s. We deliberately
// don't retry on failure: a transient PowerShell hiccup leaves the
// INVENTORY global empty, and sync.rs simply omits the `inventory`
// key from the upload. Next agent restart re-tries.
std::thread::spawn(|| {
let inv = inventory::collect_inventory();
if !inv.is_empty() {
*hbb_common::config::INVENTORY.write().unwrap() = inv;
}
});
// `start_server` is `#[tokio::main]` and runs forever. (is_server=true,
// no_server=false). It boots the default IPC server, input service,
// rendezvous mediator, and heartbeat sync.