-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathlimitbw
executable file
·46 lines (36 loc) · 995 Bytes
/
limitbw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
#current bug
# each ip is limited, not each account
if [ -e /etc/dhcp/dhcpd.vps ]; then
DHCPVPS=/etc/dhcp/dhcpd.vps
else
DHCPVPS=/etc/dhcpd.vps
fi
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
base="$(readlink -f "$(dirname "$0")")";
IFS="
"
# don't run on qs
check=`crontab -l | grep qs_cron | grep -v "^#"`;
if [ ! "$check" = "" ]; then
echo "#skipping for qs";
exit;
fi
if [ -e ${base}/_notclimit ]; then
echo "#skipping for ${base}/_notclimit"
for i in `ifconfig | grep ^vnet | cut -d: -f1`; do /sbin/tc qdisc del dev $i root; done
exit;
fi
for vm in `cat $DHCPVPS | grep fixed | awk '{ print $2 " " $8 }' | cut -d\; -f1`; do
ip=`echo $vm | cut -d" " -f2`;
host=`echo $vm | cut -d" " -f1`;
check=`virsh list | grep $host | grep run`;
if [ "$check" = "" ]; then
echo "$host not running";
else
vnet=`virsh dumpxml $host | grep "vnet" | cut -d\' -f2`;
echo "Limiting $ip";
${base}/tclimit $ip $vnet $host
fi
echo
done