Skip to content

Instantly share code, notes, and snippets.

@Multikas
Last active November 22, 2022 19:21
Show Gist options
  • Save Multikas/ebdabe800b4e6df5d232 to your computer and use it in GitHub Desktop.
Save Multikas/ebdabe800b4e6df5d232 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
@dungvn3000
Copy link

dungvn3000 commented Dec 24, 2018

Simpler version Smart OS build 20181206

dladm set-linkprop -z $VM_UUID -p maxbw=15M eth0

It'll be remove after vm reboot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment