具体的可以参考这里
他的最大特点是快, 当你的系统有上万个tcp链接要了解的时候的时候, 你就知道我说什么了. netstat等常规工具变成废铁了, 这时候他的作用就非常明显了.
/proc interface is inadequate, unfortunately. When amount of sockets is enough large, netstat or even plain cat /proc/net/tcp/ cause nothing but pains and curses. In linux-2.4 the desease became worse: even if amount of sockets is small reading /proc/net/tcp/ is slow enough.
This utility presents a new approach, which is supposed to scale well. I am not going to describe technical details here and will concentrate on description of the command. The only important thing to say is that it is not so bad idea to load module tcp_diag, which can be found in directory Modules of iproute2. If you do not make this ss will work, but it falls back to /proc and becomes slow like netstat, well, a bit faster yet (see section “Some numbers”).
从技术上讲, 它主要是通过/proc来获取各种各样的统计信息. 特别是当处理tcp的时候用到了, tcp_diag功能. tcp_diag是tcp协议栈用于诊断和统计的一个模块, 用netfilter来获取第一手的信息的. ss就用到了这个技术, 保证了信息的快捷获取.
这个软件是隶属于iproute包的, 如果你的系统没有的话可以这样安装:
apt-get -y install iproute |
用它可以了解下协议栈占用的内存, 每个链接的队列使用情况, 每个链接属于哪个进程.
而之前唯一能用的就是:
watch -n 1 'cat /proc/net/sockstat' |
下面简单介绍下他的使用:
root@ubuntu:/usr/src/iproute-20090324/misc# ss --help |
ss [ OPTIONS ] [ FILTER ] |
-V, --version output version information |
-n, --numeric don't resolve service names |
-r, --resolve resolve host names |
-a, --all display all sockets |
-l, --listening display listening sockets |
-o, --options show timer information |
-e, --extended show detailed socket information |
-m, --memory show socket memory usage |
-p, --processes show process using socket |
-i, --info show internal TCP information |
-s, --summary show socket usage summary |
-4, --ipv4 display only IP version 4 sockets |
-6, --ipv6 display only IP version 6 sockets |
-0, --packet display PACKET sockets |
-t, --tcp display only TCP sockets |
-u, --udp display only UDP sockets |
-d, --dccp display only DCCP sockets |
-w, --raw display only RAW sockets |
-x, --unix display only Unix domain sockets |
-f, --family=FAMILY display sockets of type FAMILY |
QUERY := {all|inet|tcp|udp|raw|unix|packet|netlink}[,QUERY] |
-F, --filter=FILE read filter information from FILE |
FILTER := [ state TCP-STATE ] [ EXPRESSION ] |
root@ubuntu:/usr/src/iproute-20090324/misc# ss -s |
TCP: 21 (estab 7, closed 0, orphaned 0, synrecv 0, timewait 0/0), ports 0 |
root@ubuntu:/usr/src/iproute-20090324/misc# ss -t -m |
State
Recv-Q
Send-Q
Local
Address:Port
Peer Address:Port |
ESTAB 0 0 192.168.235.147:ssh 192.168.235.155:4251 |
CLOSE-WAIT
38
0
192.168.235.147:13910
174.36.30.67:https |
ESTAB 0 0 192.168.235.147:ssh 192.168.235.155:4635 |
ESTAB
0
0
127.0.0.1:4369
127.0.0.1:54620 |
ESTAB 0 0 192.168.235.147:ssh 192.168.235.155:1095 |
ESTAB
0
0
127.0.0.1:4369
127.0.0.1:44234 |
ESTAB
0
0
127.0.0.1:54620
127.0.0.1:4369 |
ESTAB
0
0
127.0.0.1:44234
127.0.0.1:4369 |
root@ubuntu:/usr/src/iproute-20090324/misc# ss -p |
State
Recv-Q
Send-Q
Local
Address:Port
Peer Address:Port |
ESTAB 0 0 192.168.235.147:ssh 192.168.235.155:4251 users:(("sshd",8373,3)) |
CLOSE-WAIT
38
0
192.168.235.147:13910
174.36.30.67:https users:(("dropbox",2674,13)) |
ESTAB 0 0 192.168.235.147:ssh 192.168.235.155:4635 users:(("sshd",350,3)) |
ESTAB
0
0
127.0.0.1:4369
127.0.0.1:54620 users:(("epmd",28338,5)) |
ESTAB 0 0 192.168.235.147:ssh 192.168.235.155:1095 users:(("sshd",29044,3)) |
ESTAB
0
0
127.0.0.1:4369
127.0.0.1:44234 users:(("epmd",28338,4)) |
ESTAB
0
0
127.0.0.1:54620
127.0.0.1:4369 users:(("beam.smp",25947,11)) |
ESTAB
0
0
127.0.0.1:44234
127.0.0.1:4369 users:(("inet_gethost",23783,8),("inet_gethost",23784,8)) |
root@ubuntu:/usr/src/iproute-20090324/misc# ss -i |
State
Recv-Q
Send-Q
Local
Address:Port
Peer Address:Port |
ESTAB 0 0 192.168.235.147:ssh 192.168.235.155:4251 |
cubic rto:396 rtt:124.5/66 ato:40 cwnd:4 send 375.3Kbps rcv_rtt:296456 rcv_space:66472 |
CLOSE-WAIT
38
0
192.168.235.147:13910
174.36.30.67:https |
cubic wscale:7,9 rto:612 rtt:256/52 ato:40 cwnd:5 send 213.8Kbps rcv_rtt:259 rcv_space:5840 |
ESTAB 0 0 192.168.235.147:ssh 192.168.235.155:4635 |
cubic rto:356 rtt:144/33 ato:40 cwnd:4 send 324.4Kbps rcv_rtt:511258 rcv_space:46760 |
ESTAB
0
0
127.0.0.1:4369
127.0.0.1:54620 |
cubic wscale:9,9 rto:204 rtt:4/2 ato:40 cwnd:3 send 98.3Mbps rcv_space:32768 |
ESTAB 0 0 192.168.235.147:ssh 192.168.235.155:1095 |
cubic rto:232 rtt:21/18 ato:40 cwnd:5 ssthresh:4 send 2.8Mbps rcv_rtt:173516 rcv_space:118904 |
ESTAB
0
0
127.0.0.1:4369
127.0.0.1:44234 |
cubic wscale:9,9 rto:204 rtt:4/2 ato:40 cwnd:3 send 98.3Mbps rcv_space:32768 |
ESTAB
0
0
127.0.0.1:54620
127.0.0.1:4369 |
cubic wscale:9,9 rto:204 rtt:4/2 ato:40 cwnd:3 send 98.3Mbps rcv_space:32792 |
ESTAB
0
0
127.0.0.1:44234
127.0.0.1:4369 |
cubic wscale:9,9 rto:204 rtt:4/2 ato:40 cwnd:3 send 98.3Mbps rcv_space:32792 |
root@ubuntu:/usr/src/iproute-20090324/misc# ss -e |
State
Recv-Q
Send-Q
Local
Address:Port
Peer Address:Port |
ESTAB 0 0 192.168.235.147:ssh 192.168.235.155:4251 timer:(keepalive,50min,0) ino:1843366 sk:c2ea2600 |
CLOSE-WAIT
38
0
192.168.235.147:13910
174.36.30.67:https ino:12200 sk:c2ea2140 |
ESTAB 0 0 192.168.235.147:ssh 192.168.235.155:4635 timer:(keepalive,2min59sec,0) ino:1101514 sk:c2ea4740 |
ESTAB
0
0
127.0.0.1:4369
127.0.0.1:54620 ino:2309430 sk:c2ea2ac0 |
ESTAB 0 0 192.168.235.147:ssh 192.168.235.155:1095 timer:(keepalive,6min59sec,0) ino:379842 sk:c2f4af80 |
ESTAB
0
0
127.0.0.1:4369
127.0.0.1:44234 ino:2044745 sk:c2ea3440 |
ESTAB
0
0
127.0.0.1:54620
127.0.0.1:4369 ino:2309429 sk:c2ea7200 |
ESTAB
0
0
127.0.0.1:44234
127.0.0.1:4369 ino:2044744 sk:c2ea1300 |
root@ubuntu:/usr/src/iproute-20090324/misc# ss -o |
State
Recv-Q
Send-Q
Local
Address:Port
Peer Address:Port |
ESTAB 0 0 192.168.235.147:ssh 192.168.235.155:4251 timer:(keepalive,50min,0) |
CLOSE-WAIT
38
0
192.168.235.147:13910
174.36.30.67:https |
ESTAB 0 0 192.168.235.147:ssh 192.168.235.155:4635 timer:(keepalive,2min50sec,0) |
ESTAB
0
0
127.0.0.1:4369
127.0.0.1:54620 |
ESTAB 0 0 192.168.235.147:ssh 192.168.235.155:1095 timer:(keepalive,6min50sec,0) |
ESTAB
0
0
127.0.0.1:4369
127.0.0.1:44234 |
ESTAB
0
0
127.0.0.1:54620
127.0.0.1:4369 |
ESTAB
0
0
127.0.0.1:44234
127.0.0.1:4369 |
Have fun!!!
- ss-套接字监控工具
ss(Socket Statistics) - another utility to investigate sockets(研究套接字的另一个实用程序,原先的是netstat) ss用于转储套接字统 ...
- CentOS 7上的性能监控工具
Linux中基于命令行的性能监控工具:dstat.top.netstat.vmstat.htop.ss.glances 1.dstat – 多类型资源统计工具(需配置epel源) 该命令整合了vmst ...
- [转]Linux下网络常用命令和工具
转自:http://int32bit.me/2016/05/04/Linux%E5%B8%B8%E7%94%A8%E7%BD%91%E7%BB%9C%E5%B7%A5%E5%85%B7%E6%80%B ...
- linux基础之网络基础配置
基础命令:ifconfig/route/netstat,ip/ss,nmcli 一.ifconfig/route/netstat相关命令 1. ifconfig - configure a netw ...
- linux之网络命令
本文整理了在实践过程中使用的Linux网络工具,这些工具提供的功能非常强大,我们平时使用的只是冰山一角,比如lsof.ip.tcpdump.iptables等. 本文不会深入研究这些命令的强大用法,因 ...
- ss命令详解
ss是Socket Statistics的缩写.顾名思义,ss命令可以用来获取socket统计信息,它可以显示和netstat类似的内容.ss的优势在于它能够显示更多更详细的有关TCP和连接状态的信息 ...
- Linux-(ping,traceroute,ss)
ping命令 1.命令格式: ping [参数] [主机名或IP地址] 2.命令功能: ping命令用于:确定网络和各外部主机的状态:跟踪和隔离硬件和软件问题:测试.评估和管理网络.如果主机正在运行并 ...
- Linux ss命令详解
ss是Socket Statistics的缩写.顾名思义,ss命令可以用来获取socket统计信息,它可以显示和netstat类似的内容.ss的优势在于它能够显示更多更详细的有关TCP和连接状态的信息 ...
- 命令备忘 ss
简介: Socket Statistics(ss)命令类似于netstat,它用于显示各种有用的网络套接字信息. 长时间看,已经注意到netstat这个命令程序已经过时了.从而代替netstat的是s ...
随机推荐
- 程序员训练机器学习 SVM算法分享
http://www.csdn.net/article/2012-12-28/2813275-Support-Vector-Machine 摘要:支持向量机(SVM)已经成为一种非常受欢迎的算法.本文 ...
- [Algorithm] Check if a binary tree is binary search tree or not
What is Binary Search Tree (BST) A binary tree in which for each node, value of all the nodes in lef ...
- ListView显示不同布局
在使用不同布局的时候,getItemViewType和getViewType不能少,通常是不用这两个函数的重载的 listView.setAdapter(new BaseAdapter() { @Ov ...
- 【高德地图Android SDK】视频教学
前两天参加了高德在北航举办的公开课,感觉非常不错.完成老师布置的作业之后,还顺利地拿到了高德开发者认证证书!! 现在来跟大家分享一下,如何快速学习[高德地图Android SDK]的开发.一天包会!连 ...
- LintCode: Restore IP Address
C++ string::substr(start_pos, length) vector::push_back(element) class Solution { public: vector< ...
- SQLServer中char、varchar、nchar、nvarchar的区别
http://www.cnblogs.com/14lcj/archive/2012/07/08/2581234.html SQLServer中char.varchar.nchar.nvarchar的区 ...
- nyoj 119士兵杀敌(三)(线段树区间最值查询,RMQ算法)
题目119 题目信息 执行结果 本题排行 讨论区 士兵杀敌(三) 时间限制:2000 ms | 内存限制:65535 KB 难度:5 描写叙述 南将军统率着N个士兵,士兵分别编号为1~N,南将军常 ...
- 禁用系统的Ctrl+Alt+Left/Right(方向键)
对于非常多工具,如IntelliJ IDE,Ctrl+Alt+Left/Right(方向键)是一个非常重要的快捷键,可是这个快捷键经常会被一些显示相关的附属应用给占用用于调整屏幕显示的朝向,有时候即使 ...
- CyclicBarrier的用法
CyclicBarrier是一个同步辅助类,它允许一组线程互相等待,直到到达某个公共屏障点 (common barrier point).在涉及一组固定大小的线程的程序中,这些线程必须不时地互相等待, ...
- MySQL:Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT...
1:错误日志大量错误 150602 14:40:02 [Warning] Unsafe statement written to the binary log using statement form ...