OpenVZ Forum


Home » General » Support » How to limit traffic per vps?
Re: How to limit traffic per vps? [message #31653 is a reply to message #31651] Fri, 04 July 2008 14:41 Go to previous messageGo to previous message
silentninja is currently offline  silentninja
Messages: 37
Registered: September 2007
Member
I've noticed that the HTB example on the wiki creates one qdisc for each class.. and this script doesn't, may that be something ?

EDIT: YEAP, it was that, and the quantum amounts Smile, this is the fixed script for anyone

#!/bin/bash

# Server Total Bandwidth
IFSPEED="4mbit"
MAXBURST="256kbit"

# Get VE IPs 
SHAPEIPS=`grep IP_ADDRESS /etc/vz/conf/* | cut -d\" -f2 | sed 's/ /\n/'`

# Each VE speed
SPEEDLIMIT="512kbit"
VEBURST="64kbit"

# Shape Number constant
STARTSHAPECLASS=10

addtc()
{
        tc qdisc del dev $DEV root
        tc qdisc add dev $DEV root handle 1: htb default 10
        tc class add dev $DEV parent 1: classid 1:1 htb rate "$IFSPEED" burst "$MAXBURST"
        SHAPECLASS=$STARTSHAPECLASS
        for IP in `echo "$SHAPEIPS"`
        do
                tc class add dev $DEV parent 1:1 classid 1:"$SHAPECLASS" htb rate "$SPEEDLIMIT" ceil "$SPEEDLIMIT" burst "$VEBURST"
		tc qdisc add dev $DEV parent 1:"$SHAPECLASS" handle "$SHAPECLASS": sfq perturb 10
                SHAPECLASS=$(($SHAPECLASS+1))
        done
        SHAPECLASS=$STARTSHAPECLASS
        for IP in `echo "$SHAPEIPS"`
        do
                tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 match ip $1 "$IP" flowid 1:"$SHAPECLASS"
                SHAPECLASS=$(($SHAPECLASS+1))
        done
}

# Trafico saliente
DEV="eth0"
addtc src
# Trafico entrante
DEV="venet0"
addtc dst


It would be GREAT to update the example on the wiki, so anyone could edit it faster.

[Updated on: Fri, 04 July 2008 15:00]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [solved] 3ware 9690SA and 2.6.18-53.1.19.el5.028stab053.14
Next Topic: Xfce Openvz
Goto Forum:
  


Current Time: Fri Jul 18 23:08:24 GMT 2025

Total time taken to generate the page: 0.05417 seconds