Linux Script test network speed

Source: Internet
Author: User

Example:./netspeed eth0

1 #!/bin/bash

2
3 interval= "1" # Update INTERVAL in seconds
4
5 if [-Z ']; Then
6 Echo
7 echo Usage: $ [network-interface]
8 Echo
9 echo e.g. $ eth0
Ten Echoes
Exit
Fi
13
If=$1
15
While True
+ Do
r1= ' Cat/sys/class/net/$1/statistics/rx_bytes '
t1= ' Cat/sys/class/net/$1/statistics/tx_bytes '
Sleep $INTERVAL
R2= ' Cat/sys/class/net/$1/statistics/rx_bytes '
T2= ' Cat/sys/class/net/$1/statistics/tx_bytes '
tbps= ' Expr $T 2-$T 1 '
rbps= ' Expr $R 2-$R 1 '
tkbps= ' expr $TBPS/1024 '
rkbps= ' expr $RBPS/1024 '
echo "TX $: $TKBPS kb/s RX $: $RKBPS kb/s"
Done

Linux Script test network speed

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.