Compare commits

..

2 Commits

Author SHA1 Message Date
b0ee0242bd Show all Docker containers as top-level services with active/inactive status
All checks were successful
Build and Release / build-and-release (push) Successful in 1m20s
Agent changes:
- Changed docker ps to docker ps -a to show ALL containers (running and stopped)
- Map container status: Up -> active, Exited/Created -> inactive, other -> failed
- Display Docker containers as individual top-level services instead of sub-services
- Each container shown as "docker_{container_name}" in service list

This provides better visibility of all containers and their status directly in the
services panel, making it easier to see stopped containers at a glance.

Updated to version 0.1.172
2025-11-27 10:51:47 +01:00
8f9e9eabca Sort virtual interfaces: VLANs first by ID, then alphabetically
All checks were successful
Build and Release / build-and-release (push) Successful in 1m32s
Dashboard changes:
- Sort child interfaces under physical NICs with VLANs first (by VLAN ID ascending)
- Non-VLAN virtual interfaces sorted alphabetically by name
- Applied same sorting to both nested children and standalone virtual interfaces

Example output order:
- wan (vlan 5)
- lan (vlan 30)
- isolan (vlan 32)
- seclan (vlan 35)
- br-48df2d79b46f
- docker0
- tailscale0

Updated to version 0.1.171
2025-11-27 10:12:59 +01:00
6 changed files with 51 additions and 27 deletions

6
Cargo.lock generated
View File

@@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
[[package]] [[package]]
name = "cm-dashboard" name = "cm-dashboard"
version = "0.1.170" version = "0.1.172"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@@ -301,7 +301,7 @@ dependencies = [
[[package]] [[package]]
name = "cm-dashboard-agent" name = "cm-dashboard-agent"
version = "0.1.170" version = "0.1.172"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@@ -324,7 +324,7 @@ dependencies = [
[[package]] [[package]]
name = "cm-dashboard-shared" name = "cm-dashboard-shared"
version = "0.1.170" version = "0.1.172"
dependencies = [ dependencies = [
"chrono", "chrono",
"serde", "serde",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "cm-dashboard-agent" name = "cm-dashboard-agent"
version = "0.1.170" version = "0.1.172"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@@ -117,20 +117,8 @@ impl SystemdCollector {
} }
} }
if service_name.contains("docker") && active_status == "active" { // Docker containers are now collected as top-level services below
let docker_containers = self.get_docker_containers(); // Keeping nginx as sub-services for now
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 // Create complete service data
let service_data = ServiceData { let service_data = ServiceData {
@@ -152,6 +140,21 @@ 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 // Update cached state
{ {
let mut state = self.state.write().unwrap(); let mut state = self.state.write().unwrap();
@@ -757,8 +760,9 @@ impl SystemdCollector {
let mut containers = Vec::new(); let mut containers = Vec::new();
// Check if docker is available (use sudo for permissions) // Check if docker is available (use sudo for permissions)
// Use -a to show ALL containers (running and stopped)
let output = Command::new("sudo") let output = Command::new("sudo")
.args(&["docker", "ps", "--format", "{{.Names}},{{.Status}}"]) .args(&["docker", "ps", "-a", "--format", "{{.Names}},{{.Status}}"])
.output(); .output();
let output = match output { let output = match output {
@@ -783,10 +787,10 @@ impl SystemdCollector {
let container_status = if status_str.contains("Up") { let container_status = if status_str.contains("Up") {
"active" "active"
} else if status_str.contains("Exited") { } else if status_str.contains("Exited") || status_str.contains("Created") {
"warning" // Match original: Exited → Warning, not inactive "inactive" // Stopped/created containers are inactive
} else { } else {
"failed" // Other states → failed "failed" // Other states (restarting, paused, dead) → failed
}; };
containers.push((format!("docker_{}", container_name), container_status.to_string())); containers.push((format!("docker_{}", container_name), container_status.to_string()));

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "cm-dashboard" name = "cm-dashboard"
version = "0.1.170" version = "0.1.172"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@@ -629,10 +629,20 @@ impl SystemWidget {
let virtual_interfaces: Vec<_> = self.network_interfaces.iter().filter(|i| !i.is_physical).collect(); let virtual_interfaces: Vec<_> = self.network_interfaces.iter().filter(|i| !i.is_physical).collect();
// Find standalone virtual interfaces (those without a parent) // Find standalone virtual interfaces (those without a parent)
let standalone_virtual: Vec<_> = virtual_interfaces.iter() let mut standalone_virtual: Vec<_> = virtual_interfaces.iter()
.filter(|i| i.parent_interface.is_none()) .filter(|i| i.parent_interface.is_none())
.collect(); .collect();
// Sort standalone virtual: VLANs first (by VLAN ID), then others alphabetically
standalone_virtual.sort_by(|a, b| {
match (a.vlan_id, b.vlan_id) {
(Some(vlan_a), Some(vlan_b)) => vlan_a.cmp(&vlan_b),
(Some(_), None) => std::cmp::Ordering::Less,
(None, Some(_)) => std::cmp::Ordering::Greater,
(None, None) => a.name.cmp(&b.name),
}
});
// Render physical interfaces with their children // Render physical interfaces with their children
for (phy_idx, interface) in physical.iter().enumerate() { for (phy_idx, interface) in physical.iter().enumerate() {
let is_last_physical = phy_idx == physical.len() - 1 && standalone_virtual.is_empty(); let is_last_physical = phy_idx == physical.len() - 1 && standalone_virtual.is_empty();
@@ -646,7 +656,7 @@ impl SystemWidget {
lines.push(Line::from(header_spans)); lines.push(Line::from(header_spans));
// Find child interfaces for this physical interface // Find child interfaces for this physical interface
let children: Vec<_> = virtual_interfaces.iter() let mut children: Vec<_> = virtual_interfaces.iter()
.filter(|vi| { .filter(|vi| {
if let Some(parent) = &vi.parent_interface { if let Some(parent) = &vi.parent_interface {
parent == &interface.name parent == &interface.name
@@ -656,6 +666,16 @@ impl SystemWidget {
}) })
.collect(); .collect();
// Sort children: VLANs first (by VLAN ID), then others alphabetically
children.sort_by(|a, b| {
match (a.vlan_id, b.vlan_id) {
(Some(vlan_a), Some(vlan_b)) => vlan_a.cmp(&vlan_b),
(Some(_), None) => std::cmp::Ordering::Less,
(None, Some(_)) => std::cmp::Ordering::Greater,
(None, None) => a.name.cmp(&b.name),
}
});
// Count total items under this physical interface (IPs + children) // Count total items under this physical interface (IPs + children)
let ip_count = interface.ipv4_addresses.len() + interface.ipv6_addresses.len(); let ip_count = interface.ipv4_addresses.len() + interface.ipv6_addresses.len();
let total_children = ip_count + children.len(); let total_children = ip_count + children.len();

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "cm-dashboard-shared" name = "cm-dashboard-shared"
version = "0.1.170" version = "0.1.172"
edition = "2021" edition = "2021"
[dependencies] [dependencies]