#!/bin/bash
# Run pvesm status and lsblk on R630-01 using sshpass
# Usage: ./check-storage-sshpass.sh [password]
# Or: PROXMOX_PASSWORD=yourpass ./check-storage-sshpass.sh

PROXMOX_HOST="192.168.11.11"
PROXMOX_USER="root"

# Get password from argument or environment variable
if [ -n "$1" ]; then
    PASSWORD="$1"
elif [ -n "$PROXMOX_PASSWORD" ]; then
    PASSWORD="$PROXMOX_PASSWORD"
else
    echo "Usage: $0 <password>"
    echo "Or: PROXMOX_PASSWORD=yourpass $0"
    exit 1
fi

echo "=========================================="
echo "Checking Proxmox Storage and Block Devices"
echo "=========================================="
echo ""

echo "=== Proxmox Storage Status ==="
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no "$PROXMOX_USER@$PROXMOX_HOST" "pvesm status"
echo ""

echo "=== Block Devices ==="
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no "$PROXMOX_USER@$PROXMOX_HOST" "lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,FSTYPE,MODEL"
echo ""

echo "=== 250GB Drives Detail ==="
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no "$PROXMOX_USER@$PROXMOX_HOST" "
for drive in sdc sdd sde sdf sdg sdh; do
    if [ -b \"/dev/\$drive\" ]; then
        echo \"\"
        echo \"/dev/\$drive:\"
        lsblk /dev/\$drive
        fdisk -l /dev/\$drive 2>/dev/null | head -5
    fi
done
"

