From a1b31b16842455c9dbfeceeb795da60fd8bc561c Mon Sep 17 00:00:00 2001 From: yukkop Date: Tue, 7 Oct 2025 10:55:37 +0000 Subject: [PATCH] =?UTF-8?q?fix(package):=20`sentin=C3=A8lla=20one=20more?= =?UTF-8?q?=20unset=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package/sentinèlla/probe-loop.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/package/sentinèlla/probe-loop.sh b/package/sentinèlla/probe-loop.sh index e8baab4..1a4e801 100644 --- a/package/sentinèlla/probe-loop.sh +++ b/package/sentinèlla/probe-loop.sh @@ -100,28 +100,28 @@ base64() { : "${VOLUMES:=$(df -P | awk 'NR>1{print $6}')}" route_status() { - if [ -z "$URLS" ]; then - printf '{\n "checks": [],\n "summary":{"total":0,"ok":0}\n}\n' + if [ -z "${URLS:-}" ]; then + printf '{"checks":[],"summary":{"total":0,"ok":0}}' return fi { - printf '{\n "checks": [\n' + printf '{"checks":[' first=1 okcnt=0 tot=0 for u in $URLS; do tot=$((tot+1)) res=$(curl -sS -m "$TIMEOUT" -o /dev/null -w '%{http_code} %{time_total}' "$u" 2>/dev/null) || res="000 0" code=${res%% *}; ttot=${res#* } case $code in 2*|3*) ok=true; okcnt=$((okcnt+1));; *) ok=false;; esac - [ $first -eq 0 ] && printf ',\n'; first=0 - printf ' {"url":"%s","code":%s,"time_s":%s,"ok":%s}' "$u" "$code" "$ttot" "$ok" + [ $first -eq 0 ] && printf ','; first=0 + printf '{"url":"%s","code":%s,"time_s":%s,"ok":%s}' "$u" "$code" "$ttot" "$ok" done - printf '\n ],\n "summary":{"total":%s,"ok":%s}\n}\n' "$tot" "$okcnt" + printf '],"summary":{"total":%s,"ok":%s}}' "$tot" "$okcnt" } } route_disk() { { - printf '{\n "volumes": [\n' + printf '{"volumes":[' first=1 for v in $VOLUMES; do # POSIX df -P: Filesystem 1K-blocks Used Available Capacity Mounted on @@ -129,11 +129,11 @@ route_disk() { set -- $(df -P "$v" 2>/dev/null | awk 'NR==2{print $2, $3, $4, $5, $6}') size=$1 used=$2 avail=$3 usep=$4 mnt=$5 [ -z "$size" ] && continue - [ $first -eq 0 ] && printf ',\n'; first=0 - printf ' {"mount":"%s","size_blocks":%s,"used":%s,"avail":%s,"use_percent":"%s"}' \ + [ $first -eq 0 ] && printf ','; first=0 + printf '{"mount":"%s","size_blocks":%s,"used":%s,"avail":%s,"use_percent":"%s"}' \ "$mnt" "$size" "$used" "$avail" "$usep" done - printf '\n ]\n}\n' + printf ']}' } }