From c5795e3add89cf1997dfd65d71803f0faccb57d9 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Mon, 13 Oct 2025 19:47:45 +0200 Subject: [PATCH] Remove storage info from immich, focus on connections only --- agent/src/collectors/service.rs | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/agent/src/collectors/service.rs b/agent/src/collectors/service.rs index 62c7b29..0ddf46d 100644 --- a/agent/src/collectors/service.rs +++ b/agent/src/collectors/service.rs @@ -911,9 +911,9 @@ impl ServiceCollector { } async fn get_immich_info(&self) -> Option { - // Check upload directory for photo count estimate - let output = Command::new("find") - .args(["/var/lib/immich/upload", "-type", "f", "-name", "*.jpg", "-o", "-name", "*.png", "-o", "-name", "*.mp4", "-o", "-name", "*.mov"]) + // Check HTTP connections - Immich typically runs on port 2283 or behind nginx + let output = Command::new("/run/current-system/sw/bin/ss") + .args(["-tn", "state", "established", "dport", "= :2283"]) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .output() @@ -922,25 +922,9 @@ impl ServiceCollector { if output.status.success() { let stdout = String::from_utf8_lossy(&output.stdout); - let file_count = stdout.lines().count(); - if file_count > 0 { - return Some(format!("~{} media files", file_count)); - } - } - - // Fallback: check storage usage - let output = Command::new("sudo") - .args(["/run/current-system/sw/bin/du", "-sh", "/var/lib/immich/upload"]) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .output() - .await - .ok()?; - - if output.status.success() { - let stdout = String::from_utf8_lossy(&output.stdout); - if let Some(size) = stdout.split_whitespace().next() { - return Some(format!("Storage: {}", size)); + let connection_count = stdout.lines().count().saturating_sub(1); + if connection_count > 0 { + return Some(format!("{} connections", connection_count)); } }