View NIC status with nicstat

Source: Internet
Author: User
Tags automake
Using nicstat to view the NIC status I previously used scripts to implement Xml code for real-time Nic traffic #! /Bin/bashNAMEnic_flowPIDFILE/var/tmp/$ NAME. pidLOGFILE/var/tmp/$ NAME. logfunctionstart () {if [-f & quot; $ PIDFILE & quot;]... using nicstat to view the NIC status I previously used scripts to implement Xml code for real-time Nic traffic #! /Bin/bash NAME = nic_flow PIDFILE =/var/tmp/$ NAME. pid LOGFILE =/var/tmp/$ NAME. log function start () {if [-f "$ PIDFILE"]; then echo $ PIDFILE exit 2 fi ((;;)); do eth = $1 [-z "$ {eth:-}"] & eth = eth0 time_range = $2 [-z "$ {time_range: -} "] & amp; time_range = 1 ifconfig | awk '{print $1}' | grep" eth ">/dev/null [$? -Gt 0] & echo "wrong NIC device" & exit 10 RX_1 =_1 (cat/proc/net/dev | grep "$ eth" | awk-F' [| :] + ''{print $4} ') TX_1 = $ (cat/proc/net/dev | grep" $ eth "| awk' {print $9 }') sleep $ time_range RX_2 =$ (cat/proc/net/dev | grep "$ eth" | awk-F' [|:] + ''{print $4 }') TX_2 = $ (cat/proc/net/dev | grep "$ eth" | awk '{print $9}') clear echo-e "'date + % k: % M: % S 'Rx TX "| tee-a $ logfile rx =$ ($ {RX_2}-$ {RX_1}) TX =$ ($ {TX_2}-$ {TX_1}) if [[$ RX-lt 1024]; then RX = "$ {RX} B/s" elif [[$ RX-gt 1048576]; then RX = $ (echo $ RX | awk '{print $1/1048576 "MB/s "}') else RX =$ (echo $ RX | awk '{print $1/1024 "KB/s"}') fi if [[$ TX-lt 1024]; then TX = "$ {TX} B/s" elif [[$ TX-gt 1048576]; then TX =$ (echo $ TX | awk '{print $1/1048576 "MB/s "}') else TX =$ (echo $ TX | awk '{print $1/1024 "KB/s"}') fi echo-e "$ eth $ RX $ T X "| tee-a $ LOGFILE done & echo $!> $ PIDFILE} function stop () {[-f $ PIDFILE] & kill 'cat $ pidfile' & rm-rf $ PIDFILE} case "$1" in start) start $2 $3; stop) stop; *) echo $ "Usage: $0 {start | stop, NIC device (eth *), time_range (s )} "exit 2 esac today found a better tool nicstat. Nicstat provides more comprehensive Nic information. Display TCP traffic statistics display UDP traffic statistics report number of bytes in and out of the network card report number of data in and out of the network card report NIC utilization report NIC saturation and other information install make environment yum install gcc-c ++ make automake autoconf-y because nicstat depends on 32 bit glibc package, therefore, yum install libgcc. i686 glibc. i686 glibc-devel.i686-y download file and install cd/usr/local/srcwget http://nchc.dl.sourceforge.net/project/nicstat/nicstat-1.92.tar.gz Tar xf nicstat-1.92.tar.gzcd nicstat-1.92cp Makefile. installation error and solution of Linux Makefilemake [root @ andy nicstat-1.92] # makegcc-O3-m32 nicstat. c-o nicstatIn file was ded from/usr/include/features. h: 385, from/usr/include/stdio. h: 28, from nicstat. c: 33:/usr/include/gnu/stubs. h: 7: 27: error: gnu/stubs-32.h: No such file or directorynicstat. c: 99: 1: warning: "DUPLEX_UNKNOWN" redefinedIn file stored ded from nicsta T. c: 84:/usr/include/linux/ethtool. h: 689: 1: warning: this is the location of the previous definitionmake: * ** [nicstat] Error 1 ======> yum install glibc-devel.i686 [root @ localhost nicstat-1.92] # makegcc-O3-m32 nicstat. c-o nicstatnicstat. c: 99: 1: warning: "DUPLEX_UNKNOWN" redefinedIn file stored ded from nicstat. c: 84:/usr/include/linux/ethtool. h: 519: 1: warning: this is the location of the previous de Finition/usr/bin/ld: skipping incompatible/usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so when searching for-lgcc_s/usr/bin/ld: skipping incompatible/usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so when searching for-lgcc_s/usr/bin/ld: cannot find-lgcc_scollect2: ld returned 1 exit statusmake: * ** [nicstat] Error 1 ======> yum install libgcc. i686 installation script: Xml code #/bin/bash # author junun # blog # SOFT_DIR =/usr/local/src function nicstat_ins {echo "============ will inst nicstat" ping-c 1-t 1 www.baidu.com if [[ $? -Gt 0]; then echo "nameserver 8.8.8.8 \ rnameserver 202.96.128.68">/etc/resolv. conf fi yum install gcc-c ++ make automake autoconf-y yum install libgcc. i686 glibc. glibc-devel.i686-y cd $ SOFT_DIR wget http://nchc.dl.sourceforge.net/project/nicstat/nicstat-1.92.tar.gz Tar xf nicstat-1.92.tar.gz nicstat-1.92 cd cp Makefile. Linux Makefile make [$? -Eq 0] | error "\ 033 [31 m there are something to make \ 033 [0 m" echo "alias nicstat = 'bash $ SOFT_DIR/nicstat-1.92/nicstat. sh '">/etc/profile. d/nicstat. sh} nicstat_ins
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.