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
|
if command -v dmidecode &>/dev/null; then
|
||||||
# Get configured memory speed (actual running speed)
|
# 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)
|
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
|
# Fallback to Speed: if Configured not available
|
||||||
if [[ -z "$RAM_SPEED" ]]; then
|
if [[ -z "$RAM_SPEED" ]]; then
|
||||||
RAM_SPEED=$(dmidecode -t memory 2>/dev/null | grep -m1 "Speed:" | grep -oE "[0-9]+" | head -1)
|
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
|
# - Never blocks or fails script execution
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
post_to_api() {
|
post_to_api() {
|
||||||
# DEBUG: Show function entry
|
|
||||||
echo "[DEBUG] post_to_api() called" >&2
|
|
||||||
|
|
||||||
# Silent fail - telemetry should never break scripts
|
# Silent fail - telemetry should never break scripts
|
||||||
command -v curl &>/dev/null || {
|
command -v curl &>/dev/null || {
|
||||||
echo "[DEBUG] curl not found, skipping" >&2
|
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] curl not found, skipping" >&2
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
[[ "${DIAGNOSTICS:-no}" == "no" ]] && {
|
[[ "${DIAGNOSTICS:-no}" == "no" ]] && {
|
||||||
echo "[DEBUG] DIAGNOSTICS=no, skipping" >&2
|
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] DIAGNOSTICS=no, skipping" >&2
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
[[ -z "${RANDOM_UUID:-}" ]] && {
|
[[ -z "${RANDOM_UUID:-}" ]] && {
|
||||||
echo "[DEBUG] RANDOM_UUID empty, skipping" >&2
|
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] RANDOM_UUID empty, skipping" >&2
|
||||||
return 0
|
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
|
# Set type for later status updates
|
||||||
TELEMETRY_TYPE="lxc"
|
TELEMETRY_TYPE="lxc"
|
||||||
@ -358,16 +355,21 @@ post_to_api() {
|
|||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
echo "[DEBUG] Sending to: $TELEMETRY_URL" >&2
|
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] Sending to: $TELEMETRY_URL" >&2
|
||||||
echo "[DEBUG] Payload: $JSON_PAYLOAD" >&2
|
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] Payload: $JSON_PAYLOAD" >&2
|
||||||
|
|
||||||
# Fire-and-forget: never block, never fail
|
# Fire-and-forget: never block, never fail
|
||||||
local http_code
|
local http_code
|
||||||
http_code=$(curl -sS -w "%{http_code}" -m "${TELEMETRY_TIMEOUT}" -X POST "${TELEMETRY_URL}" \
|
if [[ "${DEV_MODE:-}" == "true" ]]; then
|
||||||
-H "Content-Type: application/json" \
|
http_code=$(curl -sS -w "%{http_code}" -m "${TELEMETRY_TIMEOUT}" -X POST "${TELEMETRY_URL}" \
|
||||||
-d "$JSON_PAYLOAD" -o /dev/stderr 2>&1) || true
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$JSON_PAYLOAD" -o /dev/stderr 2>&1) || true
|
||||||
echo "[DEBUG] HTTP response code: $http_code" >&2
|
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