From 4dfa8bac3567de2ae8fa4c5c1a5e8af3a8e5cd60 Mon Sep 17 00:00:00 2001 From: Joey Date: Sat, 15 Nov 2025 02:11:40 +0100 Subject: [PATCH] Add quorum-autofix.sh --- quorum-autofix.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 quorum-autofix.sh diff --git a/quorum-autofix.sh b/quorum-autofix.sh new file mode 100644 index 0000000..47b86c6 --- /dev/null +++ b/quorum-autofix.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# /usr/local/sbin/quorum-autofix.sh +# Automatically fix Proxmox cluster quorum to prevent "activity blocked" + +LOGFILE="/var/log/quorum-autofix.log" +LOCAL_NODE=$(hostname) + +# Extract Total votes (nodes currently online) +TOTAL=$(pvecm status | awk -F: '/Total votes:/ {gsub(/ /,"",$2); print $2}') +# Extract Expected votes (cluster configuration) +EXPECTED=$(pvecm status | awk -F: '/Expected votes:/ {gsub(/ /,"",$2); print $2}') + +if [[ -z "$TOTAL" || -z "$EXPECTED" ]]; then + echo "[$(date)] [$LOCAL_NODE] Could not parse quorum status." >> $LOGFILE + exit 1 +fi + +# Current quorum in X/Y format +CURRENT="${TOTAL}/${EXPECTED}" + +echo "[$(date)] [$LOCAL_NODE] Current quorum: $CURRENT" >> $LOGFILE + +# Determine correct expected votes +if [[ "$TOTAL" -lt "$EXPECTED" ]]; then + echo "[$(date)] [$LOCAL_NODE] Total votes ($TOTAL) < Expected votes ($EXPECTED) → fixing quorum" >> $LOGFILE + pvecm expected "$TOTAL" + echo "[$(date)] [$LOCAL_NODE] Quorum fixed: expected votes set to $TOTAL" >> $LOGFILE +else + echo "[$(date)] [$LOCAL_NODE] Quorum OK, no change needed" >> $LOGFILE +fi + +exit 0