help.sh: real Postgres cluster diagnostics.

The umbrella postgresql.service reports active with every cluster down,
which made two cluster failures look green.  Show pg_lsclusters, check
the first cluster is online, verify the data directory is under
/var/lib/postgresql, and reveal a mount over /var/lib/postgresql (the
Portable bind layout — wrong on an installed system).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-07-06 20:06:21 -06:00
parent 51a12b199e
commit 3180a29e82
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680

31
help.sh
View file

@ -95,6 +95,37 @@ fi
echo "OK: Postgres is using file socket" ||
echo "FAILED: Postgres is not using file socket"
# Cluster-level checks. The umbrella postgresql.service reports active even
# when every cluster is down, so inspect the real clusters.
if command -v pg_lsclusters >/dev/null 2>&1; then
pg_lsclusters
cluster_line=$(pg_lsclusters -h 2>/dev/null | head -1)
if [ -z "${cluster_line}" ]; then
echo "FAILED: No Postgres clusters exist (pg_lsclusters printed nothing)"
elif [ "$(echo "${cluster_line}" | awk '{print $4}')" = "online" ]; then
echo "OK: Postgres cluster is online (port $(echo "${cluster_line}" | awk '{print $3}'))"
else
echo "FAILED: Postgres cluster is not online: ${cluster_line}"
fi
cluster_data_dir=$(echo "${cluster_line}" | awk '{print $6}')
if [ -n "${cluster_data_dir}" ]; then
case "${cluster_data_dir}" in
/var/lib/postgresql/*) echo "OK: Postgres data directory is at ${cluster_data_dir}" ;;
*) echo "FAILED: Postgres data directory is in an unexpected location: ${cluster_data_dir}" ;;
esac
fi
fi
# A mount over /var/lib/postgresql means the Portable bind layout (expected
# only on live boots). On an installed system this indicates the cluster is
# on the media drive — the wrong spot; see mount-issues.md Problem 8.
if findmnt -n /var/lib/postgresql >/dev/null 2>&1; then
echo "Note: /var/lib/postgresql is a mount: $(findmnt -n -o SOURCE,FSTYPE /var/lib/postgresql)"
echo " (Portable/live-boot layout; on an installed system this is WRONG)"
else
echo "OK: /var/lib/postgresql is on the root filesystem (installed layout)"
fi
if sudo -i -u wrolpi psql -l 2>/dev/null | grep wrolpi >/dev/null; then
echo "OK: Found wrolpi database"