Gate telemetry debug via DEV_MODE
Replace unconditional debug echoes in misc/api.func with checks on DEV_MODE so telemetry debug output is only shown when DEV_MODE=true. Make curl fire-and-forget: verbose HTTP code and payload logging only in DEV_MODE, while production uses a silent curl invocation that never blocks or fails. Remove a stray trailing whitespace in detect_ram. Add misc/data/telemetry-ingest.exe binary to repo.
This commit is contained in:
parent
0876c417d3
commit
54f59505d1
@ -254,7 +254,7 @@ detect_ram() {
|
||||
if command -v dmidecode &>/dev/null; then
|
||||
# Get configured memory speed (actual running speed)
|
||||
RAM_SPEED=$(dmidecode -t memory 2>/dev/null | grep -m1 "Configured Memory Speed:" | grep -oE "[0-9]+" | head -1)
|
||||
|
||||
|
||||
# Fallback to Speed: if Configured not available
|
||||
if [[ -z "$RAM_SPEED" ]]; then
|
||||
RAM_SPEED=$(dmidecode -t memory 2>/dev/null | grep -m1 "Speed:" | grep -oE "[0-9]+" | head -1)
|
||||
@ -284,24 +284,21 @@ detect_ram() {
|
||||
# - Never blocks or fails script execution
|
||||
# ------------------------------------------------------------------------------
|
||||
post_to_api() {
|
||||
# DEBUG: Show function entry
|
||||
echo "[DEBUG] post_to_api() called" >&2
|
||||
|
||||
# Silent fail - telemetry should never break scripts
|
||||
command -v curl &>/dev/null || {
|
||||
echo "[DEBUG] curl not found, skipping" >&2
|
||||
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] curl not found, skipping" >&2
|
||||
return 0
|
||||
}
|
||||
[[ "${DIAGNOSTICS:-no}" == "no" ]] && {
|
||||
echo "[DEBUG] DIAGNOSTICS=no, skipping" >&2
|
||||
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] DIAGNOSTICS=no, skipping" >&2
|
||||
return 0
|
||||
}
|
||||
[[ -z "${RANDOM_UUID:-}" ]] && {
|
||||
echo "[DEBUG] RANDOM_UUID empty, skipping" >&2
|
||||
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] RANDOM_UUID empty, skipping" >&2
|
||||
return 0
|
||||
}
|
||||
|
||||
echo "[DEBUG] Checks passed: DIAGNOSTICS=$DIAGNOSTICS RANDOM_UUID=$RANDOM_UUID NSAPP=$NSAPP" >&2
|
||||
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] post_to_api() DIAGNOSTICS=$DIAGNOSTICS RANDOM_UUID=$RANDOM_UUID NSAPP=$NSAPP" >&2
|
||||
|
||||
# Set type for later status updates
|
||||
TELEMETRY_TYPE="lxc"
|
||||
@ -358,16 +355,21 @@ post_to_api() {
|
||||
EOF
|
||||
)
|
||||
|
||||
echo "[DEBUG] Sending to: $TELEMETRY_URL" >&2
|
||||
echo "[DEBUG] Payload: $JSON_PAYLOAD" >&2
|
||||
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] Sending to: $TELEMETRY_URL" >&2
|
||||
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] Payload: $JSON_PAYLOAD" >&2
|
||||
|
||||
# Fire-and-forget: never block, never fail
|
||||
local http_code
|
||||
http_code=$(curl -sS -w "%{http_code}" -m "${TELEMETRY_TIMEOUT}" -X POST "${TELEMETRY_URL}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$JSON_PAYLOAD" -o /dev/stderr 2>&1) || true
|
||||
|
||||
echo "[DEBUG] HTTP response code: $http_code" >&2
|
||||
if [[ "${DEV_MODE:-}" == "true" ]]; then
|
||||
http_code=$(curl -sS -w "%{http_code}" -m "${TELEMETRY_TIMEOUT}" -X POST "${TELEMETRY_URL}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$JSON_PAYLOAD" -o /dev/stderr 2>&1) || true
|
||||
echo "[DEBUG] HTTP response code: $http_code" >&2
|
||||
else
|
||||
curl -fsS -m "${TELEMETRY_TIMEOUT}" -X POST "${TELEMETRY_URL}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$JSON_PAYLOAD" &>/dev/null || true
|
||||
fi
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user