View shell scripts for Linux server network traffic

Source: Internet
Author: User

Previously wrote a view of the Linux server current traffic small script, very simple, but can intuitively give us some information

#!/bin/sh## #统计10s内的平均流量, if [  "$"  =  " ];then   echo -e" in megabytes   "\n      use interface_name after the script,like  \ "$0 eth0\" ... \ n "   exit -1fiecho -e " \n       start monitoring the $1,press \ "ctrl+c\"  to stop "echo --------- -------------------------------------------------#ls   /etc/sysconfig/network-scripts/|grep  ifcfg|cut -d  "-"  -f 2while true   do   rx_bytes= ' cat  /proc/net/dev|grep  "$" |awk  ' {print $1} ' |cut -d  ":  -f 2 '     tx_bytes= ' cat /proc/net/dev|grep  ' $ ' |awk  ' {print $9} '    sleep  10   rx_bytes_later= ' cat /proc/net/dev|grep  ' $ ' |awk  ' {print $1} ' |cut  -d  ":"  -f 2 ' &nbsP;  tx_bytes_later= ' cat /proc/net/dev|grep  ' $ ' |awk  ' {print $9} '     ## #Mb =b*8/1024/1024   speed_rx= ' echo  ' scale=2; ($RX _bytes_later -  $RX _bytes ) *8/1024/1024/10 "|BC '    speed_tx= ' echo " scale=2; ($TX _bytes_later -  $TX _bytes) *8/ 1024/1024/10 "|BC '    printf "%-3s %-3.1f %-10s %-4s %-3.1f %-4s\n "  IN:  $speed _rx mb/s out:  $speed _tx mb/s   done

Use effects such as

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/4A/wKioL1X5cqbx0zQzAACEQKvxtAM837.jpg "title=" QQ picture 20150916213625.png "alt=" Wkiol1x5cqbx0zqzaaceqkvxtam837.jpg "/>

View shell scripts for Linux server network traffic

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.