diff --git a/tools/pve/monitor-all.sh b/tools/pve/monitor-all.sh index 650c86a8b..d1084aea4 100644 --- a/tools/pve/monitor-all.sh +++ b/tools/pve/monitor-all.sh @@ -110,8 +110,9 @@ while true; do pct start "$instance" >/dev/null 2>&1 continue fi - # Not every container names its interface eth0. - IP=$(pct exec "$instance" -- ip -4 -o addr show scope global 2>/dev/null | awk '{print $4}' | cut -d/ -f1 | head -n1) + # Read the IP from the host side; pct exec depends on tools inside the + # guest, which minimal/OCI images may lack. + IP=$(lxc-info -n "$instance" -iH 2>/dev/null | awk '/^[0-9.]+$/ && !/^(127|169\.254)\./ {print; exit}') if [ -z "$IP" ] || ! ping -c 1 -W 2 "$IP" >/dev/null 2>&1; then echo "$(date): CT $instance is not responding, restarting..." pct stop "$instance" >/dev/null 2>&1