netspeed.sh 內容
#!/bin/sh
ns(){A=$(grep $1 /proc/net/dev | while read a1 r1 c c c c c c c s1 c;do echo $r1-$s1; done;)
sleep 1;
B=$(grep $1 /proc/net/dev | while read a1 r1 c c c c c c c s1 c;do echo $r1-$s1; done;)
echo Receive: $(( ${B%-*} - ${A%-*} ));
echo Transmit: $(( ${B#*-} - ${A#*-} ));
};
[ -z "$1" ]&&exit 1||ns $1;
使用方法
sh netspeed.sh eth0
沒有留言:
張貼留言