下面是监控网卡流量的 shell 脚本,运行后提示:
expr:语法错误
while true
do
ens33_in=`ifconfig eth0 |grep "RX pack" | awk '{print $5}'`
ens33_out=`ifconfig eth0 |grep "Tx pack" | awk '{print $5}'`
inK=`expr $ens33_in / 8192`
outK=`expr $ens33_out / 8192`
echo "网卡接收的流量为:$ens33_in bit/s, $inK K/s"
echo "网卡发送的流量为:$ens33_out bit/s, $outK K/s"
#控制下刷新时间为2s
sleep 2
done
看来看去不知道哪里出错了。