fix capacity-available with virsh net-dhcp-leases

This commit is contained in:
forest 2022-04-11 17:32:57 -05:00
parent 01f16019ff
commit 0cb2731876

View File

@ -20,9 +20,7 @@ if [ "$ram_bytes_remainder" -le $((20 * 1024 * 1024 * 1024)) ]; then
fi fi
ipv4_limit=61 ipv4_limit=61
used_ips=$(grep ip-add "/var/lib/libvirt/dnsmasq/virbr3.status" | cut -d '"' -f 4) total_addresses_used=$(virsh net-dhcp-leases public3 | grep -E '.+' | tail -n +3 | wc -l)
reserved_ips=$(cat "/var/lib/libvirt/dnsmasq/public3.hostsfile" | cut -d ',' -f 2)
total_addresses_used=$(printf "$used_ips\n$reserved_ips" | sort | uniq | wc -l)
ipv4_count=$(printf "$total_addresses_used") ipv4_count=$(printf "$total_addresses_used")
if [ "$ipv4_count" -ge "$ipv4_limit" ]; then if [ "$ipv4_count" -ge "$ipv4_limit" ]; then