#查看实时网卡流量脚本
#创建wqw脚本文件
root@ubuntu:~#touch wqw.sh
编辑wqw.sh脚本文件
vi wqw.sh
cat wqw.sh
#!/bin/bash
NIC=$1
echo -e " IN -----Out"
while true: do
OLD_IN=$(awk '$0~ "'$NIC'"{print $2}' /proc/net/dev)
OLD_OUT=$(awk '$0~ "'$NIC'"{print $2}' /proc/net/dev)
sleep 1
NEW_IN=$(awk '$0~ "'$NIC'"{print $2}' /proc/net/dev)
NEW_OUT=$(awk '$0~ "'$NIC'"{print $2}' /proc/net/dev)
IN=$(printf "%.1f%s" "$((($NEW_IN-$OLD_IN)/1024))" "KB/S")
OUT=$(printf "%.1f%s" "$((($NEW_IN-$OLD_IN)/1024))" "KB/S")
echo "$IN $OUT"
sleep 1
done