绝对实用LINUX双网卡流量查看脚推荐

原写了个单网卡的,但是具很多朋友及网友反映最好是双网卡流量查看,为了瞒足大家需足,我特意修改脚本了,如功能上还需增加请提出,我尽我所能修改脚本下载地址:http://down.51cto.com/data/279658运行方法很简单第一步:设权限[root@skyxue network]# chmod 777 traff.py 第二步:执行脚本[root@skyxue network]# ./traff.py 查看效果图吧RX:接收流量TX:发送流量ESTABLISHED:已建立的连接TIME_WAIT:连接等待请求HTTP:80端口连接数如下是主程序代码#!/usr/bin/python#Show network of trafficy#Sky.xue(10.21)import os,re,time,syslist_R=[]list_T=[]class pattern: def RX(self): if len(list_R) 2: p=re.compile(“RX bytes:\d+”) find=”.join(p.findall(ip))[9:] list_R.append(find) if len(list_R) == 2: count=(int(list_R[1]) – int(list_R[0]))/1024 print eth + ‘-RX:’+str(count) + “KB/s” def TX(self): if len(list_T) 2: p=re.compile(“TX bytes:\d+”) find=”.join(p.findall(ip))[9:] list_T.append(find) if len(list_T) == 2: count=(int(list_T[1]) – int(list_T[0]))/1024 print eth + ‘-TX:’+str(count) + “KB/s” def read(self): while len(list_R+list_T) 4: global ip ip = os.popen(‘/sbin/ifconfig %s’ % eth ).read() time.sleep(1) d.RX() d.TX() def network(self): tcp=os.popen(“netstat -n | awk ‘/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'”).read() http=os.popen(“netstat -an |grep ’80’|wc -l “).read() print tcp,’HTTP:’+http d = pattern()if __name__ == ‘__main__’: eth = ‘eth0’ print ‘———-eth0———–‘ d.read() try: del list_R[:] del list_T[:] eth = ‘eth1’ print ‘———-eth1———–‘ d.read() finally: print ‘———-TCP————‘ d.network() sys.exit() 有时我们选择改变,并非经过深思熟虑,

绝对实用LINUX双网卡流量查看脚推荐

相关文章:

你感兴趣的文章:

标签云: