Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- 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>
181 lines
6.8 KiB
Bash
Executable File
181 lines
6.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
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
|
|
|
|
|
|
# Check storage for all VMs and containers across Proxmox hosts
|
|
# Usage: ./check-all-vm-storage.sh [proxmox-host]
|
|
|
|
set -e
|
|
|
|
PROXMOX_HOST="${1:-192.168.11.12}"
|
|
declare -a 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 "Storage Check - All VMs and Containers"
|
|
echo "=========================================="
|
|
echo ""
|
|
|
|
# Function to check storage on a host
|
|
check_host_storage() {
|
|
local host=$1
|
|
echo "=========================================="
|
|
echo "Proxmox Host: $host"
|
|
echo "=========================================="
|
|
echo ""
|
|
|
|
# Check if host is reachable
|
|
if ! ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@$host "echo 'Connected'" 2>/dev/null >/dev/null; then
|
|
echo "❌ Host $host is not reachable"
|
|
echo ""
|
|
return
|
|
fi
|
|
|
|
# Get hostname
|
|
HOSTNAME=$(ssh -o StrictHostKeyChecking=no root@$host "hostname" 2>/dev/null || echo "unknown")
|
|
echo "Hostname: $HOSTNAME"
|
|
echo ""
|
|
|
|
# Check Proxmox storage pools
|
|
echo "=== Proxmox Storage Pools ==="
|
|
ssh -o StrictHostKeyChecking=no root@$host "pvesm status --output-format json" 2>/dev/null | \
|
|
python3 -c "
|
|
import sys, json
|
|
try:
|
|
data = json.load(sys.stdin)
|
|
if 'data' in data:
|
|
print(f\"{'Storage':<30} {'Type':<15} {'Status':<10} {'Total':<12} {'Used':<12} {'Avail':<12} {'Usage %':<10}\")
|
|
print('-' * 110)
|
|
for item in data['data']:
|
|
storage = item.get('storage', 'N/A')
|
|
stype = item.get('type', 'N/A')
|
|
status = item.get('status', 'N/A')
|
|
total = item.get('total', 0)
|
|
used = item.get('used', 0)
|
|
avail = item.get('avail', 0)
|
|
if total > 0:
|
|
pct = (used / total) * 100
|
|
else:
|
|
pct = 0
|
|
|
|
# Format sizes
|
|
total_gb = total / (1024**3) if total else 0
|
|
used_gb = used / (1024**3) if used else 0
|
|
avail_gb = avail / (1024**3) if avail else 0
|
|
|
|
print(f\"{storage:<30} {stype:<15} {status:<10} {total_gb:>10.2f}G {used_gb:>10.2f}G {avail_gb:>10.2f}G {pct:>8.1f}%\")
|
|
else:
|
|
print('No storage data available')
|
|
except Exception as e:
|
|
print(f'Error parsing storage data: {e}')
|
|
ssh -o StrictHostKeyChecking=no root@$host 'pvesm status' 2>/dev/null
|
|
" 2>/dev/null || ssh -o StrictHostKeyChecking=no root@$host "pvesm status" 2>/dev/null
|
|
echo ""
|
|
|
|
# Get all VMs and containers
|
|
echo "=== VM and Container Storage Usage ==="
|
|
|
|
# Get containers (LXC)
|
|
CONTAINERS=$(ssh -o StrictHostKeyChecking=no root@$host "pct list --output-format json" 2>/dev/null || echo "[]")
|
|
# Get VMs (QEMU)
|
|
VMS=$(ssh -o StrictHostKeyChecking=no root@$host "qm list --output-format json" 2>/dev/null || echo "[]")
|
|
|
|
# Process containers
|
|
if [ "$CONTAINERS" != "[]" ] && [ -n "$CONTAINERS" ]; then
|
|
echo "$CONTAINERS" | python3 -c "
|
|
import sys, json
|
|
try:
|
|
containers = json.load(sys.stdin)
|
|
if containers and len(containers) > 0:
|
|
print(f\"{'VMID':<6} {'Name':<30} {'Status':<10} {'Size':<12} {'Root Disk':<12}\")
|
|
print('-' * 80)
|
|
for vm in containers:
|
|
vmid = str(vm.get('vmid', 'N/A'))
|
|
name = vm.get('name', 'N/A')[:28]
|
|
status = vm.get('status', 'N/A')
|
|
maxdisk = vm.get('maxdisk', 0)
|
|
if maxdisk:
|
|
size_gb = maxdisk / (1024**3)
|
|
size_str = f'{size_gb:.2f}G'
|
|
else:
|
|
size_str = 'N/A'
|
|
rootfs = vm.get('rootfs', 'N/A')[:10]
|
|
print(f\"{vmid:<6} {name:<30} {status:<10} {size_str:<12} {rootfs:<12}\")
|
|
except Exception as e:
|
|
print(f'Error parsing containers: {e}')
|
|
" 2>/dev/null || echo "Error parsing containers"
|
|
fi
|
|
|
|
# Process VMs
|
|
if [ "$VMS" != "[]" ] && [ -n "$VMS" ]; then
|
|
echo "$VMS" | python3 -c "
|
|
import sys, json
|
|
try:
|
|
vms = json.load(sys.stdin)
|
|
if vms and len(vms) > 0:
|
|
print(f\"{'VMID':<6} {'Name':<30} {'Status':<10} {'Size':<12} {'Disk':<12}\")
|
|
print('-' * 80)
|
|
for vm in vms:
|
|
vmid = str(vm.get('vmid', 'N/A'))
|
|
name = vm.get('name', 'N/A')[:28]
|
|
status = vm.get('status', 'N/A')
|
|
maxdisk = vm.get('maxdisk', 0)
|
|
if maxdisk:
|
|
size_gb = maxdisk / (1024**3)
|
|
size_str = f'{size_gb:.2f}G'
|
|
else:
|
|
size_str = 'N/A'
|
|
disk = vm.get('disk', 'N/A')[:10]
|
|
print(f\"{vmid:<6} {name:<30} {status:<10} {size_str:<12} {disk:<12}\")
|
|
except Exception as e:
|
|
print(f'Error parsing VMs: {e}')
|
|
" 2>/dev/null || echo "Error parsing VMs"
|
|
fi
|
|
echo ""
|
|
|
|
# Detailed disk usage for running containers
|
|
echo "=== Detailed Disk Usage (Running Containers) ==="
|
|
RUNNING_CONTAINERS=$(ssh -o StrictHostKeyChecking=no root@$host "pct list --output-format json" 2>/dev/null | \
|
|
python3 -c "import sys, json; [print(vm['vmid']) for vm in json.load(sys.stdin) if vm.get('status') == 'running']" 2>/dev/null || echo "")
|
|
|
|
if [ -n "$RUNNING_CONTAINERS" ]; then
|
|
printf "%-6s | %-30s | %-12s | %-12s | %-10s\n" "VMID" "Name" "Used" "Total" "Usage %"
|
|
echo "----------------------------------------------------------------------------------------"
|
|
|
|
for vmid in $RUNNING_CONTAINERS; do
|
|
NAME=$(ssh -o StrictHostKeyChecking=no root@$host "pct config $vmid 2>/dev/null | grep '^hostname:' | cut -d' ' -f2" || echo "unknown")
|
|
|
|
# Get disk usage
|
|
DISK_USAGE=$(ssh -o StrictHostKeyChecking=no root@$host "pct exec $vmid -- df -h / 2>/dev/null | tail -1" || echo "")
|
|
|
|
if [ -n "$DISK_USAGE" ]; then
|
|
USED=$(echo "$DISK_USAGE" | awk '{print $3}')
|
|
TOTAL=$(echo "$DISK_USAGE" | awk '{print $2}')
|
|
PERCENT=$(echo "$DISK_USAGE" | awk '{print $5}')
|
|
|
|
printf "%-6s | %-30s | %-12s | %-12s | %-10s\n" "$vmid" "${NAME:0:28}" "$USED" "$TOTAL" "$PERCENT"
|
|
fi
|
|
done
|
|
else
|
|
echo "No running containers found"
|
|
fi
|
|
echo ""
|
|
|
|
# Check root filesystem usage on host
|
|
echo "=== Host Root Filesystem ==="
|
|
ssh -o StrictHostKeyChecking=no root@$host "df -h / | tail -1" 2>/dev/null || echo "Unable to check host filesystem"
|
|
echo ""
|
|
}
|
|
|
|
# Check each host
|
|
for host in "${HOSTS[@]}"; do
|
|
check_host_storage "$host"
|
|
done
|
|
|
|
echo "=========================================="
|
|
echo "Storage Check Complete"
|
|
echo "==========================================" |