Files
proxmox/scripts/archive/consolidated/list/list-all-vmids-final.sh
defiQUG fbda1b4beb
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
docs: Ledger Live integration, contract deploy learnings, NEXT_STEPS updates
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands
- CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround
- CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check
- NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere
- MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates
- LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 15:46:57 -08:00

172 lines
8.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Complete list of all VMIDs with IPs and status - working version
set -euo pipefail
# Load IP configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[⚠]${NC} $1"; }
log_error() { echo -e "${RED}[✗]${NC} $1"; }
# Proxmox hosts
PROXMOX_HOSTS=("${PROXMOX_HOST_ML110:-192.168.11.10}" "${PROXMOX_HOST_R630_01:-192.168.11.11}" "${PROXMOX_HOST_R630_02:-192.168.11.12}")
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "📋 All VMIDs Complete Status Report"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
total_vmids=0
running_count=0
stopped_count=0
# Process each Proxmox host
for host in "${PROXMOX_HOSTS[@]}"; do
log_info "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
log_info "Host: $host"
log_info "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
# Check if host is reachable
if ! ssh -o ConnectTimeout=3 -o StrictHostKeyChecking=no root@"$host" "echo 'connected' > /dev/null" 2>/dev/null; then
log_warn "Host $host is not reachable"
echo ""
continue
fi
# Get all containers - use direct SSH command to avoid subshell issues
log_info "Containers (LXC):"
echo ""
printf "%-8s %-15s %-20s %-30s\n" "VMID" "Status" "IP Address" "Name"
echo "────────────────────────────────────────────────────────────────────"
# Get container list with IPs directly from host
container_data=$(ssh root@"$host" "pct list 2>/dev/null | tail -n +2 | while read vmid status rest; do if [[ \$vmid =~ ^[0-9]+$ ]]; then ip=\$(pct exec \$vmid -- hostname -I 2>/dev/null | awk '{print \$1}' || echo 'N/A'); name=\$(echo \"\$rest\" | sed 's/[[:space:]]*\$//'); echo \"\$vmid|\$status|\$ip|\$name\"; fi; done" 2>/dev/null || echo "")
if [ -n "$container_data" ]; then
while IFS='|' read -r vmid status ip name; do
if [ -z "$vmid" ]; then continue; fi
total_vmids=$((total_vmids + 1))
if [ "$status" = "running" ]; then
running_count=$((running_count + 1))
if [ "$ip" = "N/A" ] || [ -z "$ip" ]; then
printf "%-8s ${GREEN}%-15s${NC} %-20s %-30s\n" "$vmid" "$status" "N/A" "${name:0:28}"
else
printf "%-8s ${GREEN}%-15s${NC} %-20s %-30s\n" "$vmid" "$status" "$ip" "${name:0:28}"
fi
else
stopped_count=$((stopped_count + 1))
printf "%-8s ${RED}%-15s${NC} %-20s %-30s\n" "$vmid" "$status" "N/A" "${name:0:28}"
fi
done <<< "$container_data"
else
log_warn "No containers found or unable to list"
fi
echo ""
# Get all VMs
log_info "Virtual Machines (QEMU):"
echo ""
printf "%-8s %-15s %-20s %-30s\n" "VMID" "Status" "IP Address" "Name"
echo "────────────────────────────────────────────────────────────────────"
vms=$(ssh root@"$host" "qm list 2>/dev/null" || echo "")
if [ -n "$vms" ] && [ "$(echo "$vms" | wc -l)" -gt 1 ]; then
echo "$vms" | tail -n +2 | while IFS= read -r line || [ -n "$line" ]; do
if [ -z "$line" ]; then continue; fi
vmid=$(echo "$line" | awk '{print $1}')
status=$(echo "$line" | awk '{print $2}')
name=$(echo "$line" | awk '{for(i=3;i<=NF;i++) printf "%s ", $i; print ""}' | sed 's/[[:space:]]*$//')
if [ -z "$vmid" ] || [ "$vmid" = "VMID" ] || ! [[ "$vmid" =~ ^[0-9]+$ ]]; then continue; fi
if [ "$status" = "running" ]; then
ip=$(ssh root@"$host" "qm guest cmd $vmid network-get-interfaces 2>/dev/null | jq -r '.[] | select(.name != \"lo\") | .ip-addresses[]? | select(.ip-address-type == \"ipv4\") | .ip-address' | head -1" 2>/dev/null || echo "N/A")
if [ "$ip" = "N/A" ] || [ -z "$ip" ]; then
printf "%-8s ${GREEN}%-15s${NC} %-20s %-30s\n" "$vmid" "$status" "N/A" "${name:0:28}"
else
printf "%-8s ${GREEN}%-15s${NC} %-20s %-30s\n" "$vmid" "$status" "$ip" "${name:0:28}"
fi
else
printf "%-8s ${RED}%-15s${NC} %-20s %-30s\n" "$vmid" "$status" "N/A" "${name:0:28}"
fi
done
# Count VMs
vm_total=$(echo "$vms" | tail -n +2 | grep -c "^[0-9]" || echo "0")
vm_running=$(echo "$vms" | tail -n +2 | grep -c "running" || echo "0")
vm_stopped=$((vm_total - vm_running))
total_vmids=$((total_vmids + vm_total))
running_count=$((running_count + vm_running))
stopped_count=$((stopped_count + vm_stopped))
else
log_warn "No VMs found or unable to list"
fi
echo ""
done
# Backend services summary
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
log_info "Backend Services for NPMplus"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
declare -A BACKEND_SERVICES=(
["5000"]="${IP_BLOCKSCOUT:-${IP_DEVICE_14:-${IP_DEVICE_14:-${IP_DEVICE_14:-192.168.11.14}}}0}:80|blockscout-1|${PROXMOX_HOST_R630_02:-192.168.11.12}"
["10130"]="${IP_DBIS_FRONTEND:-${IP_SERVICE_13:-${IP_SERVICE_13:-${IP_SERVICE_13:-192.168.11.13}}}0}:80|dbis-frontend|${PROXMOX_HOST_R630_01:-192.168.11.11}"
["10150"]="${IP_DBIS_API:-192.168.11.155}:3000|dbis-api-primary|${PROXMOX_HOST_R630_01:-192.168.11.11}"
["10151"]="${IP_DBIS_API_2:-192.168.11.156}:3000|dbis-api-secondary|${PROXMOX_HOST_R630_01:-192.168.11.11}"
["7811"]="${IP_SERVICE_36:-${IP_SERVICE_36:-${IP_SERVICE_36:-${IP_SERVICE_36:-192.168.11.36}}}}:80|mim-api-1|${PROXMOX_HOST_R630_02:-192.168.11.12}"
["2101"]="${RPC_CORE_1:-${IP_SERVICE_21:-${IP_SERVICE_21:-${IP_SERVICE_21:-192.168.11.21}}}1}:443|besu-rpc-core-1|${PROXMOX_HOST_ML110:-192.168.11.10}"
["2201"]="${RPC_PUBLIC_1:-192.168.11.221}:443|besu-rpc-public-1|${PROXMOX_HOST_ML110:-192.168.11.10}"
["2301"]="${RPC_PRIVATE_1:-192.168.11.232}:443|besu-rpc-private-1|${PROXMOX_HOST_ML110:-192.168.11.10}"
["2302"]="${RPC_PRIVATE_1:-192.168.11.232}:443|besu-rpc-private-2|${PROXMOX_HOST_ML110:-192.168.11.10}"
)
printf "%-8s %-20s %-25s %-15s %-15s\n" "VMID" "IP:Port" "Service Name" "Host" "Status"
echo "────────────────────────────────────────────────────────────────────────────────────"
for vmid in "${!BACKEND_SERVICES[@]}"; do
service_info="${BACKEND_SERVICES[$vmid]}"
IFS='|' read -r ip_port service_name service_host <<< "$service_info"
status=$(ssh root@"$service_host" "pct status $vmid 2>/dev/null || qm status $vmid 2>/dev/null" || echo "not found")
if echo "$status" | grep -q "running"; then
printf "%-8s %-20s %-25s %-15s ${GREEN}%-15s${NC}\n" "$vmid" "$ip_port" "$service_name" "$service_host" "Running"
elif echo "$status" | grep -q "stopped"; then
printf "%-8s %-20s %-25s %-15s ${RED}%-15s${NC}\n" "$vmid" "$ip_port" "$service_name" "$service_host" "Stopped"
else
printf "%-8s %-20s %-25s %-15s ${YELLOW}%-15s${NC}\n" "$vmid" "$ip_port" "$service_name" "$service_host" "Not Found"
fi
done
echo ""
log_info "Summary:"
log_info " Total VMIDs: $total_vmids"
if [ $running_count -gt 0 ]; then
log_success " Running: $running_count"
fi
if [ $stopped_count -gt 0 ]; then
log_error " Stopped: $stopped_count"
fi
echo ""