linux 网络流量监控脚本
2013-03-07 09:43
501 查看
#!/bin/bash
if [ -z "$1" ]
then
echo "Oops...Please specify network device name."
echo "Usage: `basename $0` device"
echo "eg. `basename $0` eth0"
exit 1
else
dev_name="$1"
fi
/sbin/ifconfig $dev_name 2> /dev/null > /dev/null
if [ $? -ne 0 ]
then
echo "Oops...Cannot find the specified device."
exit 1
fi
while true
do
rece_all1=`/sbin/ifconfig $dev_name | grep bytes | awk '{print $2}' | awk -F : '{print $2}'`
send_all1=`/sbin/ifconfig $dev_name | grep bytes | awk '{print $6}' | awk -F : '{print $2}'`
sleep 1
rece_all2=`/sbin/ifconfig $dev_name | grep bytes | awk '{print $2}' | awk -F : '{print $2}'`
send_all2=`/sbin/ifconfig $dev_name | grep bytes | awk '{print $6}' | awk -F : '{print $2}'`
rece=`expr $rece_all2 - $rece_all1`
send=`expr $send_all2 - $send_all1`
clear
echo "Last second receive:$(($rece/1024)) KB Last second Send:$(($send/1024)) KB"
echo "Total receive:$(($rece_all2/1024)) KB ($(($rece_all2/1024/1024))MB) Total send:$(($send_all2/1024)) KB ($(($send_all2/1024/1024))MB)"
done
http://blog.chinaunix.net/uid-25524253-id-2783110.html
if [ -z "$1" ]
then
echo "Oops...Please specify network device name."
echo "Usage: `basename $0` device"
echo "eg. `basename $0` eth0"
exit 1
else
dev_name="$1"
fi
/sbin/ifconfig $dev_name 2> /dev/null > /dev/null
if [ $? -ne 0 ]
then
echo "Oops...Cannot find the specified device."
exit 1
fi
while true
do
rece_all1=`/sbin/ifconfig $dev_name | grep bytes | awk '{print $2}' | awk -F : '{print $2}'`
send_all1=`/sbin/ifconfig $dev_name | grep bytes | awk '{print $6}' | awk -F : '{print $2}'`
sleep 1
rece_all2=`/sbin/ifconfig $dev_name | grep bytes | awk '{print $2}' | awk -F : '{print $2}'`
send_all2=`/sbin/ifconfig $dev_name | grep bytes | awk '{print $6}' | awk -F : '{print $2}'`
rece=`expr $rece_all2 - $rece_all1`
send=`expr $send_all2 - $send_all1`
clear
echo "Last second receive:$(($rece/1024)) KB Last second Send:$(($send/1024)) KB"
echo "Total receive:$(($rece_all2/1024)) KB ($(($rece_all2/1024/1024))MB) Total send:$(($send_all2/1024)) KB ($(($send_all2/1024/1024))MB)"
done
http://blog.chinaunix.net/uid-25524253-id-2783110.html
相关文章推荐
- linux下监控网络流量的脚本
- linux监控网络流量的脚本
- linux网络流量监控脚本
- linux系统CPU,内存,磁盘,网络流量监控脚本
- linux网络流量的监控脚本
- Linux 脚本 实现网络流量监控
- linux系统CPU,内存,磁盘,网络流量监控脚本
- linux下监控网络流量的脚本
- linux系统CPU,内存,磁盘,网络流量监控脚本
- 监控Linux网络流量的脚本
- Linux下网络流量监控工具大全,查看网卡的实时流量脚本
- linux网络流量实时监控工具之iptraf
- Linux网络流量实时监控ifstat iftop命令详解
- linux 下网络流量监控
- linux 下网络流量监控 yum环境
- Linux网络流量实时监控工具-ifstat
- 监控linux网络流量shell
- Linux下的实时网络流量监控工具 – iftop
- linux网络流量实时监控工具之iptraf
- nethogs命令_Linux nethogs 命令用法详解:终端下的网络流量监控工具