fix : t 001 a 020 fait

This commit is contained in:
2026-03-19 09:21:45 +01:00
parent e68c99a8b3
commit 11f69a9eda
18 changed files with 137 additions and 75 deletions

View File

@@ -44,13 +44,23 @@ set +a
: "${CHECK_MAX_TIME:?Variable CHECK_MAX_TIME manquante}"
: "${APP_URLS:?Variable APP_URLS manquante}"
[[ "$CHECK_CONNECT_TIMEOUT" =~ ^[0-9]+$ ]] || {
echo "ERROR: Variable CHECK_CONNECT_TIMEOUT invalide" >&2
exit 1
}
[[ "$CHECK_MAX_TIME" =~ ^[0-9]+$ ]] || {
echo "ERROR: Variable CHECK_MAX_TIME invalide" >&2
exit 1
}
#######################################
# Sites à vérifier
#######################################
read -r -a SITES <<< "$APP_URLS"
SCHEME="http"
SCHEME="${APP_SCHEME:-http}"
CONNECT_TIMEOUT="${CHECK_CONNECT_TIMEOUT}"
MAX_TIME="${CHECK_MAX_TIME}"
@@ -75,6 +85,16 @@ DISCORD_PING="${DISCORD_PING:-@here}"
SUMMARY_LINES=()
FAILURES=0
TMPFILES=()
cleanup() {
local tmpfile
for tmpfile in "${TMPFILES[@]}"; do
[[ -n "$tmpfile" ]] || continue
rm -f -- "$tmpfile"
done
}
trap cleanup EXIT
#######################################
# Logging
@@ -158,6 +178,7 @@ check_site() {
local http_code curl_exit err
local stderr
stderr="$(mktemp)"
TMPFILES+=("$stderr")
http_code="$(
curl -sS -o /dev/null \
@@ -170,15 +191,12 @@ check_site() {
if [[ "$curl_exit" -ne 0 ]]; then
err="$(head -n 1 "$stderr" | tr -d '\r')"
rm -f "$stderr"
log_line "DOWN" "$host" "curl exit=$curl_exit : ${err:-"(aucun)"}"
add_summary_line "$host" "DOWN" "DOWN - curl"
return 1
fi
rm -f "$stderr"
if [[ "$http_code" =~ ^[0-9]{3}$ ]]; then
if [[ "$http_code" -ge 200 && "$http_code" -le 399 ]]; then
log_line "OK" "$host" "HTTP $http_code"