Bandwidth Accounting for VPS [message #187] |
Mon, 03 October 2005 13:29 |
Ukyo
Messages: 2 Registered: October 2005 Location: Dallas
|
Junior Member |
|
|
Bandwidth Accounting for VPS
Bandwidth accounting allows you to track bandwidth usage of your VPS.
This is possible using the Linux iptables. You add an iptables entry for
the INBOUND, and OUTBOUND on the FORWARD chain. You can do this
with the following example:
# iptables -A FORWARD -o eth0 -s 10.69.69.201
# iptables -A FORWARD -i eth0 -d 10.69.69.201
Please note that the bandwidth accounting works by IP, not VPSID.
You must have BOTH lines to properly track traffic that is INBOUND as well
as OUTBOUND.
You can view the accounting results with the following command:
# iptables -L FORWARD -v -x
Chain FORWARD (policy ACCEPT 54 packets, 3240 bytes)
pkts bytes target prot opt in out source destination
11 660 all -- any eth0 10.69.69.201 anywhere
11 660 all -- eth0 any anywhere 10.69.69.201
You can also use the following command to only show
accounting information for specific IP 's:
# iptables -L FORWARD -v -x | grep '10.69.69.201'
14 840 all -- any eth0 10.69.69.201 anywhere
14 840 all -- eth0 any anywhere 10.69.69.201
To clear/reset the counters you can use the following command:
# iptables -Z
However, please note that this will simply reset all counters to 0.
If you want to get the latest accounting results before it resets the
counter you can use the following command:
# iptables -L FORWARD -Z -v
Chain FORWARD (policy ACCEPT 60 packets, 3600 bytes)
pkts bytes target prot opt in out source destination
0 0 all -- any eth0 10.69.69.201 anywhere
0 0 all -- eth0 any anywhere 10.69.69.201
Zeroing chain `FORWARD'
Please remember that using these commands will reset the counters for
ALL of your IP Addresses. If you want to just reset a single one, please
delete the counter, and recreate it.
To delete a counter, you use the same line that you created it with, except
you use a -D instead of -A. Here is an example:
# iptables -D FORWARD -o eth0 -s 10.69.69.201
# iptables -D FORWARD -i eth0 -d 10.69.69.201
The iptables WILL be cleared if the server resets.
Once the server restarts you will need to re-create
every counter. I suggest scripting it.
Jon Montroll / CEO
ColoGuys - Colocation, Dedicated Servers & More!
Http://www.ColoGuys.Com
24/7 Toll-Free Support - 1-866-510-5799
[Updated on: Mon, 03 October 2005 13:38] Report message to a moderator
|
|
|
|
|
|
|
|
Re: Bandwidth Accounting for VPS [message #2073 is a reply to message #2064] |
Fri, 17 March 2006 22:25 |
jbond007
Messages: 78 Registered: January 2006 Location: Miami
|
Member |
|
|
how you think manage the Speed ?
vzctl set ?
--numtcpsock items[:items]
Maximum number of TCP sockets. This parameter limits the number of TCP connections and, thus, the number of clients the server application can handle in parallel. Setting the barrier and the limit to different values does not make practical sense.
--numothersock items[:items]
Maximum number of non-TCP sockets (local sockets, UDP and other types of sockets). Setting the barrier and the limit to different values does not make practical sense
or
--tcpsndbuf bytes[:bytes]
Maximum size of TCP send buffers. Barrier should be not less than 64 KB, and difference between barrier and limit should be equal to or more than value of numtcpsock multiplied by 2.5 KB.
--tcprcvbuf bytes[:bytes]
Maximum size of TCP receive buffers. Barrier should be not less than 64 KB, and difference between barrier and limit should be equal to or more than value of numtcpsock multiplied by 2.5 KB.
right ?
[Updated on: Fri, 17 March 2006 22:26] Report message to a moderator
|
|
|