Add quorum-autofix.sh
This commit is contained in:
32
quorum-autofix.sh
Normal file
32
quorum-autofix.sh
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user