How can I get the in/out bytes separate for ifconfig??
I check packets and bytes by ifconfig
.
ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 153.126.***.** netmask 255.255.254.0 broadcast 153.126.179.255
ether 9c:a3:ba:01:df:c3 txqueuelen 1000 (Ethernet)
RX packets 60777328 bytes 18377900528 (18.3 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 33420428 bytes 11013732175 (11.0 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
I run this script every day and gets byte.
However in this way, in/out packets are mixed.
Is there a way to separate in/out packets??
Or is it impossible for ifconfig (I need to use another tools???)
What I want to do is just get the in/out bytes/packets per day.
PATH="/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin"
NIC="ens3"
LOG="/var/log/transmit_bytes.log"
AT=`date '+%Y-%m-%d %H:%M:%S'`
TX=`cat /proc/net/dev | grep $NIC | sed -e 's/:/ /' | awk '{print$10}'`
echo "${AT} ${TX}" >> $LOG
exit 0