fix: force LC_ALL=C for metric commands to avoid comma decimal separator #51

Merged
rafaga21 merged 1 commits from feat/push-monitoring-agent-v2 into master 2026-06-11 20:50:31 -04:00
2 changed files with 2 additions and 10 deletions

View File

@@ -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

View File

@@ -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);
}