mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-10-07 03:21:00 +02:00
monitor-all: read container IP from the host side (#17686)
The CT check resolved the IP by running ip inside the guest via pct exec, which depends on the guest having it installed. If not, this always comes back empty, so the container is restarted every cycle despite answering ping. lxc-info reports the addresses from the host without running anything inside the guest. Fixes #17685
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user