From 9a294fbb94c0eee1b205c7d2647804a30b2634e8 Mon Sep 17 00:00:00 2001 From: Dorian Date: Tue, 31 Mar 2026 00:29:58 +0100 Subject: [PATCH] fix: disk stats show LUKS data partition, not 29GB root MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- core/archipelago/src/api/rpc/system/handlers.rs | 5 ++++- core/archipelago/src/monitoring/collector.rs | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core/archipelago/src/api/rpc/system/handlers.rs b/core/archipelago/src/api/rpc/system/handlers.rs index 86fa7906..309f739c 100644 --- a/core/archipelago/src/api/rpc/system/handlers.rs +++ b/core/archipelago/src/api/rpc/system/handlers.rs @@ -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, diff --git a/core/archipelago/src/monitoring/collector.rs b/core/archipelago/src/monitoring/collector.rs index c511646f..a785ae97 100644 --- a/core/archipelago/src/monitoring/collector.rs +++ b/core/archipelago/src/monitoring/collector.rs @@ -113,10 +113,15 @@ fn parse_kb(val: &str) -> Result { .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")?;