see current network usage ubuntu code example
Example 1: centos monitor network traffic
# yum install nethogs -y
# nethogs
Example 2: centos monitor network traffic
# yum install nload -y
# nload
# yum install nethogs -y
# nethogs
# yum install nload -y
# nload