2026-08-03 12:26:42 +08:00
|
|
|
#!/usr/bin/env bash
|
2026-08-06 10:20:43 +08:00
|
|
|
set -o pipefail
|
2026-08-12 17:29:53 +08:00
|
|
|
source '{{ healthcheck_install_root }}/health-common.sh'
|
|
|
|
|
# Run every enabled health-check profile, exit with the worst (max) code, and
|
|
|
|
|
# merge the per-check results into /var/lib/vps-health/latest.json.
|
|
|
|
|
rc=0
|
|
|
|
|
# Drop per-check results from any prior run so a profile that crashes before
|
|
|
|
|
# reporting cannot leak a stale healthy result into the aggregate.
|
|
|
|
|
{% for profile in healthcheck_profiles %}
|
|
|
|
|
rm -f '{{ healthcheck_state_dir }}/latest-{{ healthcheck_profile_scripts[profile] | replace('.sh', '') }}.json'
|
|
|
|
|
{% endfor %}
|
|
|
|
|
{% for profile in healthcheck_profiles %}
|
|
|
|
|
'{{ healthcheck_install_root }}/{{ healthcheck_profile_scripts[profile] }}' 2>&1 | tee -a '{{ healthcheck_log_dir }}/healthcheck.log'
|
|
|
|
|
this_rc="${PIPESTATUS[0]}"
|
|
|
|
|
[ "$this_rc" -gt "$rc" ] && rc="$this_rc"
|
|
|
|
|
{% endfor %}
|
|
|
|
|
aggregate_result{% for profile in healthcheck_profiles %} {{ healthcheck_profile_scripts[profile] | replace('.sh', '') }}{% endfor %}
|
|
|
|
|
exit "$rc"
|