23 Juli 2006

HTB

Nama : Marah Sakti Lubis

[root@server htb]# more /usr/sbin/htbstat.new
#!/bin/sh
# Author: JuanJo Ciarlante
# Licence: GPLv2
#
# $Id: htb-stats.sh,v 1.3 2003/09/12 16:35:46 jjo Exp $
#
#default device if no arg1 passed
DEV=${1:-eth1}

#
# to_kbits: Convert passed rate to kbits
#
# ugly global variable instead of eg. ret=$(func arg)
# to avoid fork()ing
#
to_kbits() {
RET_to_kbits=
case "$1" in
#*bit) RET_to_kbits="$((${1%bit}/1000))Kbit";; #Jika menggunakan ini maka hasil nya "bps"
*bps) RET_to_kbits="$((${1%bps}*8/1024))Kbit";;
*) RET_to_kbits="$1";;# eg. "Kbit" is returned as-is
esac
}
#
# do_stat: Core function
#
do_stat() {
while read line ;do
#echo $line
set -- $line
case "$1-$2-$3-$4" in
class-htb-*-parent) classid=$3;rate=0;backlog=" ";continue;;
class-htb-*-*) classid=$3;rate=0;backlog=" ";continue;;
rate-*-*)
test "$4" = "backlog" && backlog="$5"
rate=$2
continue
;;
tokens:*) ;;
*) continue;;
esac
file=$(cd /etc/sysconfig/htb&& ls $DEV*[:-]${classid#1:}.*)
label="${file##*[0-9].}"
to_kbits "$rate"
rate=$RET_to_kbits
printf "%-8s %10s %4s %-18s %s\n" "$classid" "$rate" "$backlog" "$label" "$file"
done <
$(/sbin/tc -s class show dev $DEV)
EOF
}

# set sort separator to ':' and compare as num.
do_stat | sort -t: -n

#
# $Log: htb-stats.sh,v $
# Revision 1.3 2003/09/12 16:35:46 jjo
# . boring doc
#
# Revision 1.2 2003/09/12 16:23:07 jjo
# . 1st public release
#
#


Untuk htb.init nya ada di;
http://freshmeat.net/projects/htb.init

file htb minimal;

eth1:
#DEFAULT=30
R2Q=100

eth1-10.root:
RATE=256Kbit
BURST=15Kbit

eth1-10:11.user1:
RATE=8Kbit
CEIL=32Kbit
BURST=15Kbit
CBURST=15Kbit
LEAF=sfq
RULE=192.168.1.10/32

eth1-10:12.user2:
RATE=8Kbit
CEIL=32Kbit
BURST=15Kbit
CBURST=15Kbit
LEAF=sfq
RULE=192.168.1.11/32


Letak file2 htb user default nya di /etc/sysconfig/htb/
Letak htb.init, jika dijadikan service di /etc/init.d/htb, file binary nya di /usr/sbin/htb.init
Letak htbstat nya ada di /usr/sbin/htbstat

2 komentar:

Thohir mengatakan...

niki settinga opo tho mas... ???

kulo boten ngertos je... :))

M.S. Lubis. mengatakan...

iki script HTB dudulz ;)) :-J.