81 lines
4.4 KiB
Bash
Executable File
81 lines
4.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# ==============================================================================================
|
|
# ==================================== Uptime Probe ============================================
|
|
# ==============================================================================================
|
|
#
|
|
# PURPOSE
|
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
# Probes every hostname NPM serves, from outside the proxy, once per run. Produces the uptime
|
|
# percentages and history strip on the Proxies tab, and the wobble list for the Sunday report.
|
|
#
|
|
# NPM's access log only describes hosts somebody visited. The host most likely to be quietly
|
|
# broken is the one nobody visited, and nothing was watching those at all.
|
|
#
|
|
# ==============================================================================================
|
|
# OPERATIONAL MODEL
|
|
# ==============================================================================================
|
|
#
|
|
# A wrapper. The work is in uptime_probe.php, which issues all probes in parallel through
|
|
# curl_multi so one pass costs about as long as the slowest domain rather than the sum.
|
|
#
|
|
# Runs every minute, injected by include/scheduler.php alongside the other background writers.
|
|
# Nothing about the storage assumes that cadence — everything is counts and time buckets.
|
|
#
|
|
# Probes carry the User-Agent Varaverk-Uptime/1.0, which npm_access_stats.sh excludes. Without
|
|
# that, this monitor becomes fifty thousand requests a day in the logs it reports on.
|
|
#
|
|
# ==============================================================================================
|
|
# DESIGN PRINCIPLES
|
|
# ==============================================================================================
|
|
#
|
|
# Probe what is served, not what was visited.
|
|
# The domain list comes from NPM's own proxy hosts, so a host nobody has requested is measured
|
|
# exactly like a busy one. Deriving the list from traffic would leave the quietest hosts — the
|
|
# ones most likely to be broken without anyone noticing — permanently unmonitored.
|
|
#
|
|
# The probe is excluded from the statistics it feeds.
|
|
# Every request carries Varaverk-Uptime/1.0, which npm_access_stats.sh filters out. Without
|
|
# that the monitor would be the largest single source of traffic in the logs it reports on,
|
|
# and every access figure would be measuring this script.
|
|
#
|
|
# The wrapper holds no logic.
|
|
# Flags are forwarded verbatim and nothing is interpreted here. Two places that both know what
|
|
# --dry-run means is two places that can disagree about it.
|
|
#
|
|
# ==============================================================================================
|
|
# OPERATIONAL SAFEGUARDS
|
|
# ==============================================================================================
|
|
#
|
|
# UPTIME_PROBE_ENABLED gates the whole run. Off means no probes and no writes.
|
|
#
|
|
# Bounded per domain by UPTIME_PROBE_TIMEOUT, so an unresponsive host costs one timeout rather
|
|
# than stalling the pass — the probes run in parallel, so one slow domain never delays the rest.
|
|
#
|
|
# --dry-run probes and reports without writing. --status and --events read stored history and
|
|
# probe nothing, so neither can alter what it is describing.
|
|
#
|
|
# Read-only against NPM. The domain list is read; no proxy host, certificate or setting is
|
|
# touched by anything in this path.
|
|
#
|
|
# ==============================================================================================
|
|
# RUNTIME MODES
|
|
# ==============================================================================================
|
|
#
|
|
# uptime_probe.sh one pass
|
|
# uptime_probe.sh --dry-run probe and report, write nothing
|
|
# uptime_probe.sh --status per-domain uptime table (24h / 7d / 30d / 1y)
|
|
# uptime_probe.sh --events recent state changes, newest first
|
|
#
|
|
# ==============================================================================================
|
|
# CONFIGURATION
|
|
# ==============================================================================================
|
|
#
|
|
# UPTIME_PROBE_ENABLED master switch
|
|
# UPTIME_PROBE_TIMEOUT seconds per domain
|
|
# UPTIME_PROBE_LIST_TTL seconds to reuse the cached domain list from NPM
|
|
#
|
|
# ==============================================================================================
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
php "$SCRIPT_DIR/uptime_probe.php" "$@"
|