From 7af4f09ca2d051c805a2591d5223cbcb87781b49 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Mon, 13 Oct 2025 14:51:41 +0200 Subject: [PATCH] Fix sudo nginx and psql commands to use full paths - Change nginx command from 'nginx' to '/run/current-system/sw/bin/nginx' - Change psql command from 'psql' to '/run/current-system/sw/bin/psql' - This ensures sudo rules can properly match the commands with full paths --- agent/src/collectors/service.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/agent/src/collectors/service.rs b/agent/src/collectors/service.rs index 75a786d..37bdb18 100644 --- a/agent/src/collectors/service.rs +++ b/agent/src/collectors/service.rs @@ -526,7 +526,7 @@ impl ServiceCollector { async fn get_postgres_connections(&self) -> Option { let output = Command::new("sudo") - .args(["-u", "postgres", "psql", "-t", "-c", "SELECT count(*) FROM pg_stat_activity WHERE state = 'active';"]) + .args(["-u", "postgres", "/run/current-system/sw/bin/psql", "-t", "-c", "SELECT count(*) FROM pg_stat_activity WHERE state = 'active';"]) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .output() @@ -585,10 +585,10 @@ impl ServiceCollector { None => { // Fallback to default nginx -T let mut cmd = if self.is_running_as_root() { - Command::new("nginx") + Command::new("/run/current-system/sw/bin/nginx") } else { let mut cmd = Command::new("sudo"); - cmd.arg("nginx"); + cmd.arg("/run/current-system/sw/bin/nginx"); cmd }; @@ -615,10 +615,10 @@ impl ServiceCollector { // Use the specific config file let mut cmd = if self.is_running_as_root() { - Command::new("nginx") + Command::new("/run/current-system/sw/bin/nginx") } else { let mut cmd = Command::new("sudo"); - cmd.arg("nginx"); + cmd.arg("/run/current-system/sw/bin/nginx"); cmd };