From 552e30751d506d22b8b1bbbea0809ff5c216190c Mon Sep 17 00:00:00 2001 From: Agent Date: Thu, 11 Jun 2026 20:49:14 -0400 Subject: [PATCH] fix: force LC_ALL=C for metric commands to avoid comma decimal separator Some locales use comma as decimal separator (e.g., es_DO.UTF-8). This caused invalid JSON like "cpu": 2,4 instead of "cpu": 2.4. Prefixed CPU and RAM commands with LC_ALL=C to force dot decimals. Also removed debug logging from pushMetrics endpoint. --- install/agent-install.sh | 4 ++-- src/Controllers/ApiController.php | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/install/agent-install.sh b/install/agent-install.sh index e8c0563..76c6b32 100644 --- a/install/agent-install.sh +++ b/install/agent-install.sh @@ -49,9 +49,9 @@ AGENT_KEY="$AGENT_KEY" INTERVAL=$INTERVAL collect_metrics() { - CPU=\$(top -bn1 2>/dev/null | grep 'Cpu(s)' | awk '{print \$2}' | cut -d'%' -f1 || true) + CPU=\$(LC_ALL=C top -bn1 2>/dev/null | grep 'Cpu(s)' | awk '{print \$2}' | cut -d'%' -f1 || true) [ -z "\$CPU" ] && CPU=0 - RAM=\$(free 2>/dev/null | grep Mem | awk '{printf "%.1f", \$3/\$2 * 100}' || true) + RAM=\$(LC_ALL=C free 2>/dev/null | grep Mem | awk '{printf "%.1f", \$3/\$2 * 100}' || true) [ -z "\$RAM" ] && RAM=0 DISK=\$(df / 2>/dev/null | tail -1 | awk '{print \$5}' | sed 's/%//' || true) [ -z "\$DISK" ] && DISK=0 diff --git a/src/Controllers/ApiController.php b/src/Controllers/ApiController.php index 8bbecdd..f7bd03b 100755 --- a/src/Controllers/ApiController.php +++ b/src/Controllers/ApiController.php @@ -303,14 +303,6 @@ class ApiController $rawBody = file_get_contents('php://input'); $input = json_decode($rawBody, true); - $logger = \ServerManager\Core\Logger::getInstance(); - $logger->warning('Push metrics received', [ - 'input_keys' => $input ? array_keys($input) : [], - 'has_agent_key' => !empty($input['agent_key']), - 'agent_key_prefix' => isset($input['agent_key']) ? substr((string)$input['agent_key'], 0, 8) . '...' : 'none', - 'raw_body_prefix' => substr($rawBody, 0, 200), - ]); - if (!$input || empty($input['agent_key'])) { $this->view->json(['error' => 'agent_key is required'], 401); }