Operating System - HP-UX
1819794 Members
3220 Online
109607 Solutions
New Discussion юеВ

Calculating Bytes per Second or KB per Second

 
SOLVED
Go to solution
BEN WRIGHT
Advisor

Calculating Bytes per Second or KB per Second

Hello there
This may seem a strange question but does any one know how to calculate the bytes per second throughput through a network card.
We have Glance on one machine in the States but not on one of our machines in Germany.
I want to calculate the throughput, or at least be able to say we are using at this point in time X% of the Network Cards 100MB/s capacity.
If you need further explaination please let me know and I will explain further.
So far we have:
1) used the netstat command and taken the results for number of Packets In / Out, assumed (bad thing to do but what else do we have) that the packet size is 1500 bytes (Mtu) and tried to calculate it that way but it does not seem to be even close
2) used the netstat command (-s -p tcp) and used the bytes (total) taken away from each other but again this seems to give us a figure way above what Glance is reporting.
I know I have simplified it greatly but where / which metric's should I use.
Thanks and Best regards
Ben
9 REPLIES 9
Bill McNAMARA_1
Honored Contributor

Re: Calculating Bytes per Second or KB per Second

check out the command
lanadmin

Later,
Bill
It works for me (tm)
Stefan Farrelly
Honored Contributor

Re: Calculating Bytes per Second or KB per Second


netstat -s
Im from Palmerston North, New Zealand, but somehow ended up in London...
Stefan Farrelly
Honored Contributor

Re: Calculating Bytes per Second or KB per Second

oops, youve already tried netstat -s. In that case PerfView is the best. Use it to graph network packets in/out on your server (from anything from an hour to a few months) and then do a test whereby you swamp the network card (say ftp a 1Gb file) and then on the PerfView graph you will see the max throughput of your card, which you can then compare to a normal day and see what% you are actually utilising.
Im from Palmerston North, New Zealand, but somehow ended up in London...
BEN WRIGHT
Advisor

Re: Calculating Bytes per Second or KB per Second

Thanks Bill
But this would mean that I would have to run the command manually to get the values, I want to script it if possible.
Also I would then assume that:
1 Octet = 8 bits = 1 byte
Thus my reading of (over 15 Seconds):
965,002 Inbound Octets
445,241 Outbound Octets
Brings a reading of for 15 Seconds:
(965,002 / 15) / 1024 = 62 KB / s Inbound
(445,241 / 15) / 1024 = 28 KB / s Outbound
This is again high compared to Glance's average 10 KB / s In, and 8 KB /s Out - very differnt.
Best regards
Ben
BEN WRIGHT
Advisor

Re: Calculating Bytes per Second or KB per Second

PerView is the same as Glance me thinks, we don't (if we can want to spend any money on this machine).
Best regards
Ben
Ron Kinner
Honored Contributor

Re: Calculating Bytes per Second or KB per Second

MRTG is what you want. It will poll the site every 5 minutes and get the number of packets in and out and then draw you a neat graph of the traffic which makes a lot more sense than an average usage over 24 hours (which MRTG also provides).

http://people.ee.ethz.ch/~oetiker/webtools/mrtg/

It's free and runs on almost anything.

Ron
U.SivaKumar_2
Honored Contributor

Re: Calculating Bytes per Second or KB per Second

Hi,

Iam using a free network bandwidth measurement tool called iperf for net benchmarking.

you can download it from

http://dast.nlanr.net/Projects/Iperf/

regards,
U.SivaKumar

Innovations are made when conventions are broken
rick jones
Honored Contributor
Solution

Re: Calculating Bytes per Second or KB per Second

Netstat -p tcp will be for all TCP connections on the system, which will be all NICs and loopback. It will not include UDP traffic or traffic for link-level applications. It is also stats since boot, with no way to clear (see beforeafter below)

Lanadmin can be used to retrieve stats from the individual links. If you are up-to-date on patches, you can use lanadmin -g mibstats .

You can take lanadmin snapshots over intervals, and if you like, use beforeafter (ftp://ftp.cup.hp.com/dist/networking/tools/)
to subtract one from the other

Keep in mind that the octet counters (bytes) are still only 32-bits, which means they can wrap in short lengths of time on links that can actually do 100 MB/s (which would be gigabit links). It can still happen before tooo terribly long on 100Mb/s (case is important here :) links.

Also, not all 100 Mbit/s links can go 100 Mbit/s - for example the HP-PB and EISA NICs cannot.

Another thing to consider watching is the outbound queue length. If this is non-zero for non-trivial lengths of time, it means the NIC is getting saturated.

There may be some additional useful stuff at ftp://ftp.cup.hp.com/dist/networking/briefs/sane_glance.txt which was written before Glance was enhanced to have the byte counters...
there is no rest for the wicked yet the virtuous have no pillows
Wilfred Chau_1
Respected Contributor

Re: Calculating Bytes per Second or KB per Second

Try use glance with adviser_only mode turned on.

glance -adviser_only -syntax mysyntax -j1 > networkstat.log 2>&1


Here is the content of mysyntax:
print gbl_stattime
NETIF LOOP
print bynetif_name, " : ", bynetif_in_packet_rate, "(IN) : ", bynetif_out_packet_rate, "(OUT)"


This will give you an output like this every second: (These are # of packet per second though)

=============16:42:21============
lan0 : 2.8(IN) : 0.0(OUT)
lo0 : 0.0(IN) : 0.0(OUT)
=============16:42:22============
lan0 : 3.3(IN) : 4.1(OUT)
lo0 : 0.0(IN) : 0.0(OUT)
=============16:42:23============
lan0 : 4.4(IN) : 5.5(OUT)
lo0 : 0.0(IN) : 0.0(OUT)