|
发表于 2006-2-2 23:30:01
|
显示全部楼层
Post by ivyharry
- stp=3
- until [ $stp = 0 ]
- do
- ifconfig eth1 | sed -n '2p;5p;6p;8p' >> log
- p1=$(tail -11 log | sed -n '4p' | awk '{print $6}' | awk -F: '{print $2}')
- p2=$(tail log | sed -n '10p' | awk '{print $6}' | awk -F: '{print $2}')
- p3=$((($p2 - $p1)/2))
- echo $p3 "bytes per-second downloading" >> log
- date >> log
- echo '-------------------------------------------------------' >> log
- tail -7 log
- sleep 2
- done
复制代码
this script monitors a NIC on the computer, refreshes every 2 sec. write the resualt into a log file with time appended
it also caculated the download speed in the last 2 sec of the computer
it is a very simple script
any comments about make it better or more useful?
thanks
- ifconfig if_name|grep "TX bytes" | awk -F: '{print $3}' | awk '{print $1}'
复制代码
The above can catch the bytes too. Would it be easier? Also, its not necessary to put everything to the log file, the whole procedure can be done in memory. |
|