Linux网络统计工具/命令
我在Linux(基于CentOS 或者 Debian 的发行版)中该如何查看当前网络端口吞吐量的统计信息?在Linux操作系统中如何查看当前内核snmp计数器以及网络端口的统计信息?

你可以使用以下任何一个命令:
nstat 命令 : 网络统计工具
键入以下命令:
# nstat
输出样例:
#kernelIpInReceives 133243 0.0IpInDelivers 133243 0.0IpOutRequests 92904 0.0IcmpOutErrors 97 0.0IcmpOutTimeExcds 97 0.0IcmpMsgOutType3 97 0.0TcpActiveOpens 538 0.0TcpEstabResets 56 0.0TcpInSegs 129837 0.0TcpOutSegs 89720 0.0TcpRetransSegs 42 0.0TcpOutRsts 704 0.0UdpInDatagrams 3255 0.0UdpNoPorts 97 0.0UdpOutDatagrams 3270 0.0Ip6OutNoRoutes 206 0.0TcpExtTW 141 0.0TcpExtDelayedACKs 508 0.0TcpExtDelayedACKLocked 1 0.0TcpExtDelayedACKLost 42 0.0TcpExtTCPHPHits 117659 0.0TcpExtTCPPureAcks 2158 0.0TcpExtTCPHPAcks 605 0.0TcpExtTCPSackRecovery 1 0.0TcpExtTCPLossUndo 16 0.0TcpExtTCPSackFailures 4 0.0TcpExtTCPFastRetrans 1 0.0TcpExtTCPSlowStartRetrans 3 0.0TcpExtTCPTimeouts 33 0.0TcpExtTCPDSACKOldSent 40 0.0TcpExtTCPDSACKRecv 5 0.0TcpExtTCPAbortOnData 120 0.0TcpExtTCPAbortOnClose 55 0.0TcpExtTCPSackShiftFallback 9 0.0IpExtInOctets 180131682 0.0IpExtOutOctets 7289106 0.0
ss 命令 : 查询套接字工具
要查看统计汇总, 输入:
# ss -s
输出样例:
Total: 786 (kernel 804)TCP: 65 (estab 40, closed 7, orphaned 0, synrecv 0, timewait 6/0), ports 56Transport Total IP IPv6* 804 - -RAW 1 1 0UDP 12 9 3TCP 58 52 6INET 71 62 9FRAG 0 0 0
查看ss 命令教程 获取更多信息。
netstat 命令 : 不错的显示套接字信息的旧工具
查看所有网络端口以及汇总信息表,输入:
# netstat -i
输出样例:
Kernel Interface tableIface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flgeth0 1500 0 941022 0 0 0 688165 0 0 0 BMRUlo 16436 0 9304 0 0 0 9304 0 0 0 LRUppp0 1496 0 3784 0 0 0 4177 0 0 0 MOPRU
查看每个协议的汇总统计信息,输入:
# netstat -s
输出样例:
Ip:1092065 total packets received0 forwarded0 incoming packets discarded1091681 incoming packets delivered798913 requests sent out895 dropped because of missing route759 reassemblies required375 packets reassembled okIcmp:17 ICMP messages received0 input ICMP message failed.ICMP input histogram:timeout in transit: 8echo replies: 91747 ICMP messages sent0 ICMP messages failedICMP output histogram:destination unreachable: 1730echo request: 17IcmpMsg:InType0: 9InType11: 8OutType3: 1730OutType8: 17Tcp:4822 active connections openings1129 passive connection openings457 failed connection attempts165 connection resets received7 connections established1062519 segments received771394 segments send out7158 segments retransmited6 bad segments received.2578 resets sentUdp:20846 packets received1730 packets to unknown port received.0 packet receive errors19242 packets sentUdpLite:TcpExt:71 invalid SYN cookies received8 resets received for embryonic SYN_RECV sockets142 packets pruned from receive queue because of socket buffer overrun2109 TCP sockets finished time wait in fast timer84 packets rejects in established connections because of timestamp19454 delayed acks sent6 delayed acks further delayed because of locked socketQuick ack mode was activated 7306 times1 packets directly queued to recvmsg prequeue.1 bytes directly received in process context from prequeue823921 packet headers predicted24412 acknowledgments not containing data payload received10150 predicted acknowledgments242 times recovered from packet loss by selective acknowledgements33 congestion windows recovered without slow start by DSACK335 congestion windows recovered without slow start after partial ack336 TCP data loss eventsTCPLostRetransmit: 351 timeouts after reno fast retransmit156 timeouts after SACK recovery116 timeouts in loss state461 fast retransmits5 forward retransmits608 retransmits in slow start2073 other TCP timeouts62 SACK retransmits failed43074 packets collapsed in receive queue due to low socket buffer8499 DSACKs sent for old packets101 DSACKs sent for out of order packets308 DSACKs received9 DSACKs for out of order packets received427 connections reset due to unexpected data122 connections reset due to early user close28 connections aborted due to timeoutTCPDSACKIgnoredOld: 3TCPDSACKIgnoredNoUndo: 60TCPSpuriousRTOs: 4TCPSackShifted: 282TCPSackMerged: 740TCPSackShiftFallback: 1017IpExt:InMcastPkts: 47OutMcastPkts: 51InBcastPkts: 1InOctets: 1341508973OutOctets: 72525352InMcastOctets: 8649OutMcastOctets: 7519InBcastOctets: 328
查看 netstat 命令教程 获取更多信息。
ip / ifconfig 命令 : 配置或者显示网络端口信息
键入以下命令:
# ifconfig
或者
# /sbin/ifconfig
或者
# ifconfig eth0
eth0 Link encap:Ethernet HWaddr b8:ac:6f:65:31:e5inet addr:192.168.1.5 Bcast:192.168.1.255 Mask:255.255.255.0inet6 addr: fe80::baac:6fff:fe65:31e5/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:966334 errors:0 dropped:0 overruns:0 frame:0TX packets:703297 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:1186255648 (1.1 GiB) TX bytes:73968238 (70.5 MiB)Interrupt:17lo Link encap:Local Loopbackinet addr:127.0.0.1 Mask:255.0.0.0inet6 addr: ::1/128 Scope:HostUP LOOPBACK RUNNING MTU:16436 Metric:1RX packets:9666 errors:0 dropped:0 overruns:0 frame:0TX packets:9666 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0RX bytes:1399578 (1.3 MiB) TX bytes:1399578 (1.3 MiB)ppp0 Link encap:Point-to-Point Protocolinet addr:10.1.11.70 P-t-P:10.0.31.18 Mask:255.255.255.255UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1496 Metric:1RX packets:3784 errors:0 dropped:0 overruns:0 frame:0TX packets:4177 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:3RX bytes:2400265 (2.2 MiB) TX bytes:275983 (269.5 KiB)
显示网络端口统计信息,输入:
# ip -s link
输出样例:
1: lo: mtu 16436 qdisc noqueue state UNKNOWNlink/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00RX: bytes packets errors dropped overrun mcast1444187 9960 0 0 0 0TX: bytes packets errors dropped carrier collsns1444187 9960 0 0 0 02: eth0: mtu 1500 qdisc mq state UP qlen 1000link/ether b8:ac:6f:65:31:e5 brd ff:ff:ff:ff:ff:ffRX: bytes packets errors dropped overrun mcast1221956483 991501 0 0 0 24TX: bytes packets errors dropped carrier collsns75623937 720272 0 0 0 03: wlan0: mtu 1500 qdisc noop state DOWN qlen 1000link/ether 00:21:6a:ca:9b:10 brd ff:ff:ff:ff:ff:ffRX: bytes packets errors dropped overrun mcast0 0 0 0 0 0TX: bytes packets errors dropped carrier collsns0 0 0 0 0 04: pan0: mtu 1500 qdisc noop state DOWNlink/ether 4a:c7:5f:0e:8e:d8 brd ff:ff:ff:ff:ff:ffRX: bytes packets errors dropped overrun mcast0 0 0 0 0 0TX: bytes packets errors dropped carrier collsns0 0 0 0 0 08: ppp0: mtu 1496 qdisc pfifo_fast state UNKNOWN qlen 3link/pppRX: bytes packets errors dropped overrun mcast2419881 3848 0 0 0 0TX: bytes packets errors dropped carrier collsns284151 4287 0 0 0 0
sar 命令: 显示网络统计信息
输入以下命令 (你需要 通过sysstat包安装并启用sar):
sar -n DEV
Linux 2.6.32-220.2.1.el6.x86_64 (www.cyberciti.biz) Tuesday 13 March 2012 _x86_64_ (2 CPU)12:00:01 CDT IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s12:10:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.0012:10:01 CDT eth0 127.13 121.32 95.45 18.34 0.00 0.00 0.0012:10:01 CDT eth1 98.48 110.62 16.72 96.33 0.00 0.00 0.0012:20:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.0012:20:01 CDT eth0 139.95 133.41 106.30 19.95 0.00 0.00 0.0012:20:01 CDT eth1 110.65 121.85 18.14 107.13 0.00 0.00 0.0012:30:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.0012:30:01 CDT eth0 147.85 132.49 115.78 20.45 0.00 0.00 0.0012:30:01 CDT eth1 111.88 127.39 18.61 117.65 0.00 0.00 0.0012:40:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.0012:40:01 CDT eth0 136.75 124.64 105.24 19.48 0.00 0.00 0.0012:40:01 CDT eth1 101.65 115.32 17.58 104.50 0.00 0.00 0.0012:50:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.0012:50:01 CDT eth0 131.45 125.69 96.49 19.58 0.00 0.00 0.0012:50:01 CDT eth1 101.41 111.31 17.54 96.78 0.00 0.00 0.0001:00:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.0001:00:01 CDT eth0 140.30 133.27 102.17 20.75 0.00 0.00 0.0001:00:01 CDT eth1 106.90 119.51 18.53 103.09 0.00 0.00 0.0001:10:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.0001:10:01 CDT eth0 152.03 127.74 125.56 19.85 0.00 0.00 0.0001:10:01 CDT eth1 115.60 134.57 18.73 126.96 0.00 0.00 0.0001:20:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.0001:20:01 CDT eth0 138.55 130.55 103.03 20.20 0.00 0.00 0.00.............01:00:01 CDT eth1 156.82 169.48 28.83 138.49 0.00 0.00 0.0001:10:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.0001:10:01 CDT eth0 215.19 194.82 163.11 30.99 0.00 0.00 0.0001:10:01 CDT eth1 162.49 183.79 28.36 163.70 0.00 0.00 0.0001:20:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.0001:20:01 CDT eth0 200.20 192.23 140.64 30.93 0.00 0.00 0.0001:20:01 CDT eth1 153.60 166.96 27.32 140.26 0.00 0.00 0.0001:30:01 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.0001:30:01 CDT eth0 111.98 103.58 79.12 16.52 0.00 0.00 0.4801:30:01 CDT eth1 87.50 95.58 14.74 79.35 0.00 0.00 0.00Average: IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/sAverage: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00Average: eth0 211.21 196.20 156.18 31.20 0.00 0.00 0.01Average: eth1 159.10 174.52 28.00 149.95 0.00 0.00 0.00
或者输入以下命令:
# sar -n DEV 1 3
输出样例:
Linux 2.6.32-220.2.1.el6.x86_64 (www.cyberciti.biz) Tuesday 13 March 2012 _x86_64_ (2 CPU)01:44:03 CDT IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s01:44:04 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.0001:44:04 CDT eth0 161.70 154.26 105.20 26.63 0.00 0.00 0.0001:44:04 CDT eth1 145.74 142.55 25.11 144.94 0.00 0.00 0.0001:44:04 CDT IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s01:44:05 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.0001:44:05 CDT eth0 162.14 156.31 107.46 42.18 0.00 0.00 0.0001:44:05 CDT eth1 135.92 138.83 39.38 104.92 0.00 0.00 0.0001:44:05 CDT IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s01:44:06 CDT lo 0.00 0.00 0.00 0.00 0.00 0.00 0.0001:44:06 CDT eth0 303.92 293.14 272.91 37.40 0.00 0.00 0.0001:44:06 CDT eth1 252.94 290.20 34.87 263.50 0.00 0.00 0.00Average: IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/sAverage: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00Average: eth0 210.37 202.34 163.19 35.66 0.00 0.00 0.00Average: eth1 178.93 191.64 33.36 171.60 0.00 0.00 0.00
Linux网络统计工具/命令的更多相关文章
- Linux网络状态工具ss命令使用详解【转】
ss命令用于显示socket状态. 他可以显示PACKET sockets, TCP sockets, UDP sockets, DCCP sockets, RAW sockets, Unix dom ...
- (转)Linux网络状态工具ss命令使用详解
Linux网络状态工具ss命令使用详解 原文:http://www.landui.com/help/show-5991.html ss 是 socket statistics 的缩写.顾名思义,ss ...
- 工作常用的linux/mysql/php/工具命令
工作常用的linux/mysql/php/工具命令: 1. tar备份目录 tar zcvf ****.tar.gz ****/ tar 备份跳过目录 tar --exclude=test1 3. s ...
- Linux_10个需要了解的Linux网络和监控命令(转)
源文地址:http://www.linuxde.net/2013/10/15325.html 1. hostname hostname 没有选项,显示主机名字 hostname –d 显示机器所属域名 ...
- 需要了解的 Linux 网络和监控命令
列出来的10个基础的每个linux用户都应该知道的网络和监控命令.网络和监控命令类似于这些: hostname, ping, ifconfig, iwconfig, netstat, nslookup ...
- 10个基础的linux网络和监控命令
配置zookeeper集群时,需要查看本机ip,输入命令 hostname -i 就会只显示主机ip, 下边搜了一篇常用的 命令,闲的时候多敲敲命令,以便用的时候再找! 我下面列出来的10个 ...
- 注意啦!10 个你需要了解的 Linux 网络和监控命令
下面列出来的10个基础的每个Linux用户都应该知道的网络和监控命令.网络和监控命令类似于这些:hostname, ping, ifconfig, iwconfig, netstat, nslooku ...
- 10个实用的 Linux 网络和监控命令[转]
本文列出了10个基础的每个Linux用户都应该知道的网络和监控命令.网络和监控命令类似于这些: hostname, ping, ifconfig, iwconfig, netstat, nslooku ...
- 10个linux网络和监控命令
我下面列出来的10个基础的每个linux用户都应该知道的网络和监控命令.网络和监控命令类似于这些: hostname, ping, ifconfig, iwconfig, netstat, nsloo ...
随机推荐
- paper 4:支持向量机系列一: Maximum Margin Classifier —— 支持向量机简介。
支持向量机即 Support Vector Machine,简称 SVM .我最开始听说这头机器的名号的时候,一种神秘感就油然而生,似乎把 Support 这么一个具体的动作和 Vector 这么一个 ...
- ubuntu的目录结构
/:根目录,一般根目录下只存放目录,不要存放文件,/etc./bin./dev./lib./sbin应该和根目录放置在一个分区中 /bin:/usr/bin:可执行二进制文件的目录,如常用的命令ls. ...
- OpenStack 虚拟机监控方案确定
Contents [hide] 1 监控方案调研过程 1.1 1. 虚拟机里内置监控模块 1.2 2. 通过libvirt获取虚拟机数据监控. 2 a.测试openstack的自待组件ceilomet ...
- python 去除字符串中连续的空格,并使用其他的分隔符替代连续的空格
例:1: filt函数用法及匿名函数lamda用法,详见http://www.cnblogs.com/apple2016/p/5657698.html join()用法详见http://www.cnb ...
- 161028、Nginx负载均衡实现tomcat集群方案简要小结
重点两部分:一.负载均衡二.tomcat集群 所谓tomcat集群,就是可以向外提供并行服务的多台机器,任何一台服务器宕机,其它服务器可以替代它向外提供服务,而不影响用户访问. Nginx是一个常用的 ...
- jQuery上传插件,文件上传测试用例
jQuery上传插件,文件上传测试用例 jQuery File Upload-jQuery上传插件介绍http://www.jq22.com/jquery-info230 jQuery File Up ...
- jQuery.isNumeric() 和 js isNaN()
jQuery.isNumeric( value ) Description: 判断指定参数是否是一个数字值(字符串形式的数字也符合条件),返回 true 或者 false. Example: $.is ...
- MySQL 获得当前日期时间 函数
获得当前日期+时间(date + time)函数:now() mysql> select now(); +---------------------+ | now() | +---------- ...
- React-Native入门指导之iOS篇
React-Native 入门指导系列教程目录 一.准备工作 (已完成) 二.项目介绍与调试 三.CSS样式与Flex布局 四.常用UI控件的使用 五.JSX在React-Native中的应用 六.事 ...
- php curl语句的用法
system32文件夹下,修改php.ini文件,找到;extension= php_curl.dll行,去掉前面的;号,保存,重启服务器.在站点目录下建立一个PHP文件,内容如下 $ch = cur ...