From 3d38a7a9843205ba0c71a758b3ce8d34d6ac434a Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Thu, 27 Nov 2025 10:56:15 +0100 Subject: [PATCH] Show all Docker containers as sub-services with active/inactive status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent changes: - Use docker ps -a to show ALL containers (running and stopped) - Map container status: Up -> active, Exited/Created -> inactive, other -> failed - Display Docker containers as sub-services under the docker service - Each container shown with proper status indicator Example display: ● docker active 139M 1MB ├─ ● docker_gitea active ├─ ○ docker_old-app inactive └─ ● docker_immich active Updated to version 0.1.173 --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- agent/src/collectors/systemd.rs | 31 ++++++++++++++----------------- dashboard/Cargo.toml | 2 +- shared/Cargo.toml | 2 +- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8b41bda..6f8ac5a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.172" +version = "0.1.173" dependencies = [ "anyhow", "chrono", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.172" +version = "0.1.173" dependencies = [ "anyhow", "async-trait", @@ -324,7 +324,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.172" +version = "0.1.173" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 187405c..db68843 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.172" +version = "0.1.173" edition = "2021" [dependencies] diff --git a/agent/src/collectors/systemd.rs b/agent/src/collectors/systemd.rs index ee8457d..2f76b7f 100644 --- a/agent/src/collectors/systemd.rs +++ b/agent/src/collectors/systemd.rs @@ -117,8 +117,20 @@ impl SystemdCollector { } } - // Docker containers are now collected as top-level services below - // Keeping nginx as sub-services for now + if service_name.contains("docker") && active_status == "active" { + let docker_containers = self.get_docker_containers(); + for (container_name, container_status) in docker_containers { + // For now, docker containers have no additional metrics + // Future: could add memory_mb, cpu_percent, restart_count, etc. + let metrics = Vec::new(); + + sub_services.push(SubServiceData { + name: container_name.clone(), + service_status: self.calculate_service_status(&container_name, &container_status), + metrics, + }); + } + } // Create complete service data let service_data = ServiceData { @@ -140,21 +152,6 @@ impl SystemdCollector { } } - // Collect Docker containers as top-level services - let docker_containers = self.get_docker_containers(); - for (container_name, container_status) in docker_containers { - let service_data = ServiceData { - name: container_name.clone(), - memory_mb: 0.0, // TODO: Could add container memory via docker stats - disk_gb: 0.0, // TODO: Could add container disk usage - user_stopped: false, - service_status: self.calculate_service_status(&container_name, &container_status), - sub_services: Vec::new(), - }; - agent_data.services.push(service_data.clone()); - complete_service_data.push(service_data); - } - // Update cached state { let mut state = self.state.write().unwrap(); diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 73da373..8e7e57f 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.172" +version = "0.1.173" edition = "2021" [dependencies] diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 948d700..a78d2cf 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.172" +version = "0.1.173" edition = "2021" [dependencies]