网站改版怎样做301,长沙seo网站排名,鞍山自适应网站制作,缩我短链接生成器Linux中一行命令查看网卡流量、统计网络流量的各种实现方法。
方法一、nload工具
源码包路径#xff1a;
wget http://heanet.dl.sourceforge.net/project/nload/nload/0.7.2/nload-0.7.2.tar.gz查看参数帮助命令#xff1a;
nload –help-a#xff1a;这个好像是全部数…Linux中一行命令查看网卡流量、统计网络流量的各种实现方法。
方法一、nload工具
源码包路径
wget http://heanet.dl.sourceforge.net/project/nload/nload/0.7.2/nload-0.7.2.tar.gz查看参数帮助命令
nload –help-a这个好像是全部数据的刷新时间周期单位是秒默认是300.
-i进入网卡的流量图的显示比例最大值设置默认10240 kBit/s.
-m不显示流量图只显示统计数据。
-o出去网卡的流量图的显示比例最大值设置默认10240 kBit/s.
-t显示数据的刷新时间间隔单位是毫秒默认500。
-u设置右边Curr、Avg、Min、Max的数据单位默认是自动变的.注意大小写单位不同
h|b|k|m|g h: auto, b: Bit/s, k: kBit/s, m: MBit/s etc.
H|B|K|M|G H: auto, B: Byte/s, K: kByte/s, M: MByte/s etc.
-U设置右边Ttl的数据单位默认是自动变的.注意大小写单位不同与-u相同
Devices自定义监控的网卡默认是全部监控的使用左右键切换。如只监控eth0命令 nload eth0
方法二、iftop工具
源码包路径
wget http://www.ex-parrot.com/%7Epdw/iftop/download/iftop-0.17.tar.gz1、iftop界面相关说明
界面上面显示的是类似刻度尺的刻度范围为显示流量图形的长条作标尺用的。 中间的 这两个左右箭头表示的是流量的方向。
TX发送流量 RX接收流量 TOTAL总流量 Cumm运行iftop到目前时间的总流量 peak流量峰值 rates分别表示过去 2s 10s 40s 的平均流量
2、iftop相关参数
常用的参数
-i设定监测的网卡如# iftop -i eth1
-B 以bytes为单位显示流量(默认是bits)如# iftop -B
-n使host信息默认直接都显示IP如# iftop -n
-N使端口信息默认直接都显示端口号如: # iftop -N
-F显示特定网段的进出流量如# iftop -F 10.10.1.0/24或# iftop -F 10.10.1.0/255.255.255.0
-hdisplay this message帮助显示参数信息
-p使用这个参数后中间的列表显示的本地主机信息出现了本机以外的IP信息;
-b使流量图形条默认就显示;
-f这个暂时还不太会用过滤计算包用的;
-P使host信息及端口信息默认就都显示;
-m设置界面最上边的刻度的最大值刻度分五个大段显示例# iftop -m 100M
进入iftop画面后的一些操作命令(注意大小写)
按h切换是否显示帮助;
按n切换显示本机的IP或主机名;
按s切换是否显示本机的host信息;
按d切换是否显示远端目标主机的host信息;
按t切换显示格式为2行/1行/只显示发送流量/只显示接收流量;
按N切换显示端口号或端口服务名称;
按S切换是否显示本机的端口信息;
按D切换是否显示远端目标主机的端口信息;
按p切换是否显示端口信息;
按P切换暂停/继续显示;
按b切换是否显示平均流量图形条;
按B切换计算2秒或10秒或40秒内的平均流量;
按T切换是否显示每个连接的总流量;
按l打开屏幕过滤功能输入要过滤的字符比如ip,按回车后屏幕就只显示这个IP相关的流量信息;
按L切换显示画面上边的刻度;刻度不同流量图形条会有变化;
按j或按k可以向上或向下滚动屏幕显示的连接记录;
按1或2或3可以根据右侧显示的三列流量数据进行排序;
按根据左边的本机名或IP排序;
按根据远端目标主机的主机名或IP排序;
按o切换是否固定只显示当前的连接;
按f可以编辑过滤代码这是翻译过来的说法我还没用过这个
按!可以使用Shell命令这个没用过没搞明白啥命令在这好用呢
按q退出监控。方法三、 ifstat
源码包路径 http://gael.roualland.free.fr/ifstat/ifstat-1.1.tar.gz 参数
-a 监测能检测到的所有网络接口的状态信息 -z 隐藏流量是无的接口例如那些接口虽然启动了但是未用的 -i 指定要监测的接口,后面跟网络接口名 时间 -T 报告所有监测接口的全部带宽 -w 用指定的列宽而不是为了适应接口名称的长度而去自动放大列宽 -W 如果内容比终端窗口的宽度还要宽就自动换行 -b 用kbits/s显示带宽而不是kbytes/s
方法四、iptraf
安装方式
yum -y install iptrafiptraf是一个基于ncurses开发的IP局域网监控工具它可以实时地监视网卡流量可以生成各种网络统计数据包括TCP信息、UDP统计、ICMP和OSPF信息、以太网负载信息、节点统计、IP校验和错误和其它一些信息。
iptraf的参数列表
iptraf后面加上不同的参数可以起到不同的作用下面是iptraf的参数命令列表
参数命令及作用
-i iface 网络接口立即在指定网络接口上开启IP流量监视,iface为all指监视所有的网络接口iface指相应的interface
-g 立即开始生成网络接口的概要状态信息
-d iface 网络接口在指定网络接口上立即开始监视明细的网络流量信息,iface指相应的interface
-s iface 网络接口在指定网络接口上立即开始监视TCP和UDP网络流量信息,iface指相应的interface
-z iface 网络接口在指定网络接口上显示包计数,iface指相应的interface
-l iface 网络接口在指定网络接口上立即开始监视局域网工作站信息,iface指相应的interface
-t timeout 时间指定iptraf指令监视的时间timeout指监视时间的minute数
-B 将标注输出重新定向到“/dev/null”关闭标注输入将程序作为后台进程运行
-L logfile 指定一个文件用于记录所有命令行的log默认文件是地址/var/log/iptraf
-I interval 指定记录log的时间间隔单位是minute不包括IP traffic monitor
-u 允许使用不支持的接口作为以太网设备
-f 清空所有计数器
-h 显示帮助信息方法五、watch ifconfig
watch命令可以反复的执行一个命令默认时间间隔为2秒钟。
watch ifconfig 可以每隔两秒监视网络状态、
watch -d ifconfig 可以每隔两秒监视网络状态, 并标记发生变化的部分
watch -d ifconfig eth0 可以每隔两秒只监视 网卡eth0, 并标记发生变化的部分
watch -d ifconfig eth0 | grep bytes 可以每隔一秒只监视网卡eth0,只显示流量部分,并标记发生变化的部分watch也可以用来查看文件变化的情况例如 例如 watch ls -la file这条命令的意思是没两秒察看 file1的文件大小变化情况。
退出 ctrlc
watch命令详解
NAME watch - execute a program periodically, showing output fullscreen SYNOPSIS watch [-dhvt] [-n ] [–differences[cumulative]] [–help] [–interval] [–no-title] [–version] DESCRIPTION watch runs command repeatedly, displaying its output (the first screenfull). This allows you to watch the program output change over time. By default, the program is run every 2 seconds; use -n or --interval to specify a different interval. The -d or --differences flag will highlight the differences between successive updates. The --cumulative option makes highlighting “sticky”, presenting a running display of all positions that have ever changed. The -t or --no-title option turns off the header showing the interval, command, and current time at the top of the display, as well as the following blank line. watch will run until interrupted. NOTE Note that command is given to “sh -c” which means that you may need to use extra quoting to get the desired effect. Note that POSIX option processing is used (i.e., option processing stops at the first non-option argument). This means that flags after command don’t get interpreted by watch itself. EXAMPLES To watch for mail, you might do: watch -n 60 from To watch the contents of a directory change, you could use: watch -d ls -l If youre only interested in files owned by user joe, you might use: watch -d ‘ls -l | fgrep joe’ You can watch for your administrator to install the latest kernel with: watch uname -r (Just kidding.)呵呵 BUGS Upon terminal resize, the screen will not be correctly repainted until the next scheduled update. All --differences highlighting is lost on that update as well. Non-printing characters are stripped from program output. Use “cat -v” as part of the command pipeline if you want to see them.
方法六、watch cat /proc/net/dev
一、查看总流量 ip ip 命令来自 iproute2util 包是查看、配置网络/路由的工具。作为 ifconfig 的替代品ip 命令功能更强大用法更语义化。
ip命令在大多数系统上都已经默认安装也可通过 yum install -y iproute 安装。ip 的 “-s -h” 参数查看各网卡的总流量下图是 ip -s -h link 的输出结果
nload nload 命令可以查看各个网络设备的当前网络速率也会展示流经设备的总流量。
nload 来自EPEL软件库CentOS安装命令为yum install -y epel-release yum install -y nload。查看eth0网卡流量 nload eth0命令输出如下
PSnetstat -s 和 ifconfig -s 都可以查看收发的总包(netstat分协议给出)但不会给出字节数据。
二、查看实时网速网速
nload 命令可以输出当前网速上面已经介绍过本节不再赘述。
dstat dstat 是一个用来替换vmstat、iostat、netstat、nfsstat和ifstat的全能系统信息统计工具支持数据实时刷新输出直观易懂。
dstat 默认没有安装安装命令为yum install -y dstat。dstat -tnf 1 10 输出接下来10秒内每秒的网络数据
sar sar 是System Activity Report的缩写是一款全面的Linux系统运行状态统计和性能分析工具可从磁盘IO、CPU负载、内存使用等多个维度对系统活动进行报告。
sar 命令来自 sysstat 包可使用这个命令安装yum install -y sysstat。sar -n TCP 1 10可查看接下来10秒内的tcp数据
三、查看连接/进程流量 ss/netstat ss 和 netstat 是查看活动链接/监听端口的常用命令。ss 是 netstat 的替代性能更好建议使用。
ss 是 iproute2util 包的一部分因此在大多数系统上默认安装也可通过yum install -y iproute安装。netstat 来自 net-tools 包新版系统上需要自行安装yum install -y net-tools。
iftop iftop 是一款实时流量监控工具可以查看每个连接的实时速率。
iftop 来自EPEL软件库安装命令是yum install -y epel-release yum install -y iftop。iftop -nN -i eth0实时查看eth0网卡的各个连接和网速
nethogs nethogs 是为了查看单个进程流量而设计的工具按照进程进行带宽分组。
nethogs 来自EPEL软件库安装命令是yum install -y epel-release yum install -y nethogs。nethogs -d 2 eth0 每2秒刷新流经eth0网卡的进程流量信息
其他 tcpdump可以用来抓包保存的数据可以用wireshark打开和查看。