Files
proxmox/scripts/get-container-distribution.sh

35 lines
1.1 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Get container distribution across cluster nodes using direct commands
set -euo pipefail
PROXMOX_HOST="${PROXMOX_HOST:-192.168.11.10}"
PROXMOX_PASS="${PROXMOX_PASS:-L@kers2010}"
ssh_proxmox() {
sshpass -p "$PROXMOX_PASS" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 root@"$PROXMOX_HOST" "$@"
}
echo "Container Distribution Across Cluster Nodes"
echo "============================================"
echo ""
# Get all containers from ml110 (since they're all there currently)
echo "All containers (currently on ml110):"
ssh_proxmox "pct list" 2>&1 | grep -v "^VMID" | while IFS= read -r line; do
if [[ -n "$line" ]]; then
vmid=$(echo "$line" | awk '{print $1}')
status=$(echo "$line" | awk '{print $2}')
name=$(echo "$line" | awk '{for(i=5;i<=NF;i++) printf "%s ", $i; print ""}' | xargs)
printf " %-6s %-12s %s\n" "$vmid" "$status" "$name"
fi
done
echo ""
echo "To check which node each container is on:"
echo " ssh root@192.168.11.10 'pvesh get /nodes/ml110/lxc'"
echo " ssh root@192.168.11.10 'pvesh get /nodes/pve/lxc'"
echo " ssh root@192.168.11.10 'pvesh get /nodes/pve2/lxc'"
echo ""