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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user