capacity limiter and general cleanup
This commit is contained in:
25
capsulflask/shell_scripts/capacity-avaliable.sh
Normal file
25
capsulflask/shell_scripts/capacity-avaliable.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
## check avaliable RAM and IPv4s
|
||||
|
||||
RAM_BYTES_TO_ALLOCATE="$1"
|
||||
|
||||
if echo "$RAM_BYTES_TO_ALLOCATE" | grep -vqE "^[0-9]+$"; then
|
||||
echo "RAM_BYTES_TO_ALLOCATE \"$RAM_BYTES_TO_ALLOCATE\" must be an integer"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#100GB
|
||||
RAM_LIMIT=100000000000
|
||||
|
||||
## compare current allocated ram + RAM_BYTES_TO_ALLOCATE with RAM_LIMIT
|
||||
|
||||
IPV4_LIMIT=26
|
||||
IPV4_COUNT=$(grep ip-add /var/lib/libvirt/dnsmasq/virbr1.status | wc -l)
|
||||
|
||||
if [ $IPV4_COUNT -gt $IPV4_LIMIT ]; then
|
||||
echo "IPv4 address limit reached"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "yes"
|
Reference in New Issue
Block a user