Files
check_swap_all/check_swap_all.sh
2025-11-03 16:55:55 +01:00

43 lines
1.2 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
VM_IDS=(100 101 102 103 104)
CT_IDS=(20009000 20232400 20308096 20401080 20508080)
echo -e "\n======================"
echo "🔍 CHECK SWAP - VMs"
echo "======================"
for vmid in "${VM_IDS[@]}"; do
echo -e "\n➡ VM $vmid"
# Vérifie si la VM est allumée
if qm status "$vmid" | grep -q "status: running"; then
# Teste si lagent répond
if qm guest cmd "$vmid" get-osinfo &>/dev/null; then
echo "✅ QEMU Agent actif sur VM $vmid"
qm guest exec "$vmid" -- bash -c "echo '[swapon]'; swapon --show || echo 'Aucun swap'; echo; echo '[free]'; free -h"
else
echo "⚠️ VM $vmid allumée mais QEMU agent inactif ou non installé"
fi
else
echo "⚠️ VM $vmid éteinte"
fi
done
echo -e "\n======================"
echo "🔍 CHECK SWAP - CTs"
echo "======================"
for ctid in "${CT_IDS[@]}"; do
echo -e "\n➡ CT $ctid"
if pct status "$ctid" | grep -q "status: running"; then
echo "✅ CT $ctid en cours d'exécution"
pct exec "$ctid" -- bash -c "echo '[swapon]'; swapon --show || echo 'Aucun swap'; echo; echo '[free]'; free -h"
else
echo "⚠️ CT $ctid éteint"
fi
done