Files
proxmox-manager/tests/mock-bin/sendmail
Tim BaumannandClaude Opus 5 479820a579 fix(health): address review findings
- Metric alerts resolve when a guest stops (CPU counter restarts); an
  n/a metric on a running guest keeps its state without being reported.
- Unexpected-stop detection uses the most recent lifecycle task per
  guest (no time window, OK or WARNINGS; suspend, reboot in progress and
  stop-mode backups included); a stop task clears an existing latch.
  onboot=1 guests stopped by a task are WARN instead of CRIT.
- Tasks are read with --source all so running tasks are visible.
- --force warning goes to stderr for --json/--health --json/--check.
- --check: INT/TERM and usage errors exit 3 from the very start.
- Total delivery failure saves the state but keeps the unsent changes
  (and the task watermark) pending, so they fire once on the next run.
- Lock on fd 9, closed for pvesh/python3/qm/pct/curl/sendmail.
- onboot read from /etc/pve/{qemu-server,lxc}/ID.conf (current section)
  with qm/pct fallback; node name from `uname -n` up to the first dot.
- Findings shorten the guest name, never the text; narrow terminals drop
  UPTIME/DISK%/TYPE; ignored guests are not counted; an empty node is
  not an error for --health.
- Regression tests for each item.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-19 19:01:30 +02:00

16 lines
480 B
Bash
Executable File

#!/usr/bin/env bash
# Mock sendmail: appends argv and the message (stdin) to $PMAN_MOCK_SENDMAIL_LOG;
# exits ${PMAN_MOCK_SENDMAIL_RC:-0}.
set -euo pipefail
if [[ -n "${PMAN_MOCK_FD_LOG:-}" ]]; then
for fd in /proc/"$$"/fd/*; do
printf 'sendmail %s\n' "$(readlink "$fd" || true)"
done >>"$PMAN_MOCK_FD_LOG"
fi
log="${PMAN_MOCK_SENDMAIL_LOG:-}"
msg="$(cat)"
if [[ -n "$log" ]]; then
printf 'ARGV: %s\n%s\n---\n' "$*" "$msg" >>"$log"
fi
exit "${PMAN_MOCK_SENDMAIL_RC:-0}"