NPM's access log only describes hosts somebody visited; the host most likely to be quietly broken is the one nobody does. Probes carry a User-Agent npm_access_stats.sh drops — unmarked, this monitor would be fifty thousand requests a day in the very logs it reports on.
58 lines
2.4 KiB
Bash
Executable File
58 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# ==============================================================================================
|
|
# ================================== Uptime Report =============================================
|
|
# ==============================================================================================
|
|
#
|
|
# PURPOSE
|
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
# The weekly read of what Tools/uptime_probe.sh has been recording every minute: anything down
|
|
# right now, and anything that was not perfect over the last seven days. Runs in the Sunday
|
|
# Morning Coffee Report.
|
|
#
|
|
# Silent on a clean week. A report that always says something is a report nobody reads, so this
|
|
# prints nothing and notifies nothing when every domain was 100%.
|
|
#
|
|
# ==============================================================================================
|
|
# OPERATIONAL MODEL
|
|
# ==============================================================================================
|
|
#
|
|
# uptime_probe.php --report exits 1 when it has something to say and 0 when it does not, so the
|
|
# decision to notify is the exit code rather than this script parsing the text it just printed.
|
|
#
|
|
# ==============================================================================================
|
|
# CONFIGURATION
|
|
# ==============================================================================================
|
|
#
|
|
# UPTIME_PROBE_ENABLED nothing here runs when the probe is switched off
|
|
#
|
|
# ==============================================================================================
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$SCRIPT_DIR/../load_config.sh"
|
|
|
|
acquire_lock
|
|
detect_hosts
|
|
|
|
if [[ "${UPTIME_PROBE_ENABLED:-true}" == "false" ]]; then
|
|
log "$ICON_GEAR Uptime probe disabled — nothing to report"
|
|
exit 0
|
|
fi
|
|
|
|
REPORT="$(php "$SCRIPT_DIR/../Plugin/unraid/Tools/uptime_probe.php" --report 2>/dev/null)"
|
|
RC=$?
|
|
|
|
if [[ $RC -eq 0 || -z "$REPORT" ]]; then
|
|
echo "$ICON_DONE All monitored domains at 100% this week ✅"
|
|
exit 0
|
|
fi
|
|
|
|
echo "$REPORT"
|
|
|
|
DOWN_COUNT=$(grep -c "DOWN" <<< "$REPORT" || true)
|
|
if [[ "$DOWN_COUNT" -gt 0 ]]; then
|
|
notify "$DOWN_COUNT domain(s) currently unreachable on $(hostname)" "Uptime" "warning"
|
|
else
|
|
notify "Some domains had downtime this week on $(hostname)" "Uptime" "normal"
|
|
fi
|
|
exit 0
|