感谢我们的老大leon给我提供的脚本非常方便,而且使用:

[root@localhost local]# vi netflow.sh

 
  
  1. #! /bin/bash 
  2. while true 
  3. do 
  4. receive1=`cat /proc/net/dev|grep eth0 | awk '{print$1}'|sed -s 's/eth0://g'` 
  5. send1=`cat /proc/net/dev|grep eth0 | awk '{print$9}'` 
  6. sleep 1 
  7. receive2=`cat /proc/net/dev|grep eth0 | awk '{print$1}'|sed -s 's/eth0://g'` 
  8. receive_cnt=`expr $receive2 - $receive1` 
  9. receive_cnt=`expr $receive_cnt / 1024` 
  10. send2=`cat /proc/net/dev|grep eth0 | awk '{print$9}'` 
  11. send_cnt=`expr $send2 - $send1` 
  12. send_cnt=`expr $send_cnt / 1024` 
  13. total_cnt=`expr $send_cnt + $receive_cnt` 
  14. echo $total_cnt 
  15. echo  'eth0 Receive Bytes:'$receive_cnt 
  16. echo 'eth0 Send Bytes:' $send_cnt 
  17. done