Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Regarding ifconfig command


    The ifconfig command o/p format got changed in recent releases of OS.
    Earlier output format :
    $ ifconfig
    bond0 Link encap:Ethernet HWaddr xx:yy:de:ad:be:ef
    inet addr:10.1.1.1 Bcast:10.1.1.255 Mask:255.255.255.0
    inet6 addr: fe80::1602:ecff:fe6c:6248/64 Scope:Link
    UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
    RX packets:78754933233 errors:12 dropped:0 overruns:0 frame:12
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:83417317310129 (75.8 TiB) TX bytes:0 (0.0 b)

    eth8 Link encap:Ethernet HWaddr xx:yy:de:ad:be:ef
    UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
    RX packets:56120366224 errors:3 dropped:0 overruns:0 frame:3
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:60876314731840 (55.3 TiB) TX bytes:0 (0.0 b)

    Changed format:

    enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    inet 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255
    inet6 fe80::a00:27ff:fed5:b2a2 prefixlen 64 scopeid 0x20<link>
    ether 08:00:27:d5:b2:a2 txqueuelen 1000 (Ethernet)
    RX packets 67 bytes 8725 (8.5 KiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 110 bytes 16373 (15.9 KiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

    enp0s8: flags=4098<BROADCAST,MULTICAST> mtu 1500
    ether 08:00:27:20:02:39 txqueuelen 1000 (Ethernet)
    RX packets 0 bytes 0 (0.0 B)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 0 bytes 0 (0.0 B)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0



    Help me to write a common shell script to output Rx/Tx bytes
    irrespective of ifconfig output format

  2. #2
    May be useful :

    One option is to use the /proc filesystem. The /proc/net/dev file contains statistics about the configured network interfaces. Each line is dedicated to one network interface and it contains statistics for receive and transmit. The statistics include metrics such total number of received/transmittted bytes, packets, drops, errors and so on.

    Cmd : cat /proc/net/dev


    Or

    netstat -i

    Or

    ip -s link

    Or

    # cat /sys/class/net/eth0/statistics/rx_bytes
    # cat /sys/class/net/eth0/statistics/rx_packets

    # cat /sys/class/net/eth0/statistics/tx_packets
    # cat /sys/class/net/eth0/statistics/tx_bytes

  3. #3
    Thank you sir. It really helped me.

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •