Add debug logging for Docker container and image collection
All checks were successful
Build and Release / build-and-release (push) Successful in 1m10s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m10s
Agent changes: - Added debug logging to Docker images collection function - Log when Docker sub-services are being collected for a service - Log count of containers and images found - Log total sub-services added - Show command failure details instead of silently returning empty vec This will help diagnose why Docker images aren't showing up as sub-services on some hosts. The logs will show if the docker commands are failing or if the collection is working but data isn't being transmitted properly. Updated to version 0.1.175
This commit is contained in:
parent
3f98f68b51
commit
f23a1b5cec
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard"
|
||||
version = "0.1.174"
|
||||
version = "0.1.175"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
@ -301,7 +301,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard-agent"
|
||||
version = "0.1.174"
|
||||
version = "0.1.175"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -324,7 +324,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cm-dashboard-shared"
|
||||
version = "0.1.174"
|
||||
version = "0.1.175"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"serde",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard-agent"
|
||||
version = "0.1.174"
|
||||
version = "0.1.175"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@ -118,7 +118,10 @@ impl SystemdCollector {
|
||||
}
|
||||
|
||||
if service_name.contains("docker") && active_status == "active" {
|
||||
debug!("Collecting Docker sub-services for service: {}", service_name);
|
||||
|
||||
let docker_containers = self.get_docker_containers();
|
||||
debug!("Found {} Docker containers", docker_containers.len());
|
||||
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.
|
||||
@ -133,6 +136,7 @@ impl SystemdCollector {
|
||||
|
||||
// Add Docker images
|
||||
let docker_images = self.get_docker_images();
|
||||
debug!("Found {} Docker images", docker_images.len());
|
||||
for (image_name, image_status, image_size) in docker_images {
|
||||
let mut metrics = Vec::new();
|
||||
metrics.push(SubServiceMetric {
|
||||
@ -147,6 +151,8 @@ impl SystemdCollector {
|
||||
metrics,
|
||||
});
|
||||
}
|
||||
|
||||
debug!("Total Docker sub-services added: {}", sub_services.len());
|
||||
}
|
||||
|
||||
// Create complete service data
|
||||
@ -818,6 +824,8 @@ impl SystemdCollector {
|
||||
fn get_docker_images(&self) -> Vec<(String, String, String)> {
|
||||
let mut images = Vec::new();
|
||||
|
||||
debug!("Collecting Docker images");
|
||||
|
||||
// Check if docker is available (use sudo for permissions)
|
||||
let output = Command::new("sudo")
|
||||
.args(&["docker", "images", "--format", "{{.Repository}}:{{.Tag}},{{.Size}}"])
|
||||
@ -825,7 +833,14 @@ impl SystemdCollector {
|
||||
|
||||
let output = match output {
|
||||
Ok(out) if out.status.success() => out,
|
||||
_ => return images, // Docker not available or failed
|
||||
Ok(out) => {
|
||||
debug!("Docker images command failed with status: {}", out.status);
|
||||
return images;
|
||||
}
|
||||
Err(e) => {
|
||||
debug!("Docker images command error: {}", e);
|
||||
return images;
|
||||
}
|
||||
};
|
||||
|
||||
let output_str = match String::from_utf8(output.stdout) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard"
|
||||
version = "0.1.174"
|
||||
version = "0.1.175"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cm-dashboard-shared"
|
||||
version = "0.1.174"
|
||||
version = "0.1.175"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user