Skip to content

Instantly share code, notes, and snippets.

@nde1
Forked from Multikas/add-flow-to-vm.sh
Created November 22, 2022 19:21
Show Gist options
  • Save nde1/41c1f42f5560599d271fd726726f8921 to your computer and use it in GitHub Desktop.
Save nde1/41c1f42f5560599d271fd726726f8921 to your computer and use it in GitHub Desktop.
Script for limiting SmartOS zones bandwidth.
#!/usr/bin/bash
#
# Script should be run in GZ.
#
# example:
# ./add-flow-to-vm.sh c480b89f-f8a1-41b1-abd0-45bac4685cb2 15M
#
# It will add TCP/UDP flows for this particular VM, and limits bandwidth to 15Mbps
#
VM_UUID=$1
MAXBW=$2
for next in `vmadm get $VM_UUID | grep interface | awk -F\" '{ print $4 }'`
do
flowadm add-flow -l $next -z $VM_UUID -a transport=tcp -p maxbw=$MAXBW $VM_UUID-$next-tcp
flowadm add-flow -l $next -z $VM_UUID -a transport=udp -p maxbw=$MAXBW $VM_UUID-$next-udp
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment