Compare commits

..

2 Commits

Author SHA1 Message Date
fefe30ec51 Remove sudo from docker commands - use docker group membership instead
All checks were successful
Build and Release / build-and-release (push) Successful in 1m19s
Agent changes:
- Changed docker ps and docker images commands to run without sudo
- cm-agent user is already in docker group, so sudo is not needed
- Fixes "unable to change to root gid: Operation not permitted" error
- Systemd security restrictions were blocking sudo gid changes

This fixes Docker container and image collection on systems with
systemd security hardening enabled.

Updated to version 0.1.178
2025-11-27 12:35:38 +01:00
fb40cce748 Add stderr logging for Docker images command failure
All checks were successful
Build and Release / build-and-release (push) Successful in 1m9s
Agent changes:
- Log stderr output when docker images command fails
- This will show the actual error message (e.g., permission denied, docker not found)
- Helps diagnose why docker images collection is failing

Updated to version 0.1.177
2025-11-27 12:28:55 +01:00
4 changed files with 11 additions and 10 deletions

View File

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

View File

@@ -779,10 +779,10 @@ impl SystemdCollector {
fn get_docker_containers(&self) -> Vec<(String, String)> { fn get_docker_containers(&self) -> Vec<(String, String)> {
let mut containers = Vec::new(); let mut containers = Vec::new();
// Check if docker is available (use sudo for permissions) // Check if docker is available (cm-agent user is in docker group)
// Use -a to show ALL containers (running and stopped) // Use -a to show ALL containers (running and stopped)
let output = Command::new("sudo") let output = Command::new("docker")
.args(&["docker", "ps", "-a", "--format", "{{.Names}},{{.Status}}"]) .args(&["ps", "-a", "--format", "{{.Names}},{{.Status}}"])
.output(); .output();
let output = match output { let output = match output {
@@ -826,15 +826,16 @@ impl SystemdCollector {
info!("Collecting Docker images"); info!("Collecting Docker images");
// Check if docker is available (use sudo for permissions) // Check if docker is available (cm-agent user is in docker group)
let output = Command::new("sudo") let output = Command::new("docker")
.args(&["docker", "images", "--format", "{{.Repository}}:{{.Tag}},{{.Size}}"]) .args(&["images", "--format", "{{.Repository}}:{{.Tag}},{{.Size}}"])
.output(); .output();
let output = match output { let output = match output {
Ok(out) if out.status.success() => out, Ok(out) if out.status.success() => out,
Ok(out) => { Ok(out) => {
info!("Docker images command failed with status: {}", out.status); let stderr = String::from_utf8_lossy(&out.stderr);
info!("Docker images command failed with status: {}, stderr: {}", out.status, stderr);
return images; return images;
} }
Err(e) => { Err(e) => {

View File

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

View File

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