fix: disk stats show LUKS data partition, not 29GB root
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:
parent
adeb57edbf
commit
9a294fbb94
@ -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,
|
||||
|
||||
@ -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")?;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user