fix: disk stats show LUKS data partition, not 29GB root
Some checks failed
Container Orchestration Tests / unit-tests (push) Has been cancelled
Container Orchestration Tests / smoke-tests (push) Has been cancelled
Build Archipelago ISO (dev) / build-iso (push) Has been cancelled

system.stats (Home page) and monitoring collector both used df /
which shows the small 29GB root partition. Now prefers
/var/lib/archipelago (the LUKS encrypted data partition) when it
exists — showing the actual 1.8TB storage users care about.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-31 00:29:58 +01:00
parent 77a46fae8d
commit 588ce53833
2 changed files with 11 additions and 3 deletions

View File

@@ -54,7 +54,10 @@ impl RpcHandler {
let load = read_loadavg().await.unwrap_or((0.0, 0.0, 0.0));
let cpu = read_cpu_usage().await.unwrap_or(0.0);
let (mem_used, mem_total) = read_meminfo().await.unwrap_or((0, 0));
let (disk_used, disk_total) = read_disk_usage().await.unwrap_or((0, 0));
// Prefer encrypted data partition if it exists
let data_path = std::path::Path::new("/var/lib/archipelago");
let df_target = if data_path.exists() { "/var/lib/archipelago" } else { "/" };
let (disk_used, disk_total) = read_disk_usage_path(df_target).await.unwrap_or((0, 0));
Ok(serde_json::json!({
"uptime_secs": uptime as u64,

View File

@@ -113,10 +113,15 @@ fn parse_kb(val: &str) -> Result<u64> {
.context("parse meminfo kB value")
}
/// Read disk used/total via `df` for the root filesystem.
/// Read disk used/total via `df`, preferring the encrypted data partition.
async fn read_disk_usage() -> Result<(u64, u64)> {
let target = if std::path::Path::new("/var/lib/archipelago").exists() {
"/var/lib/archipelago"
} else {
"/"
};
let output = tokio::process::Command::new("df")
.args(["--block-size=1", "--output=used,size", "/"])
.args(["--block-size=1", "--output=used,size", target])
.output()
.await
.context("Failed to run df")?;