ssh
-h:显示帮助信息;
-V:显示指令版本信息;
-n:不解析服务名称,以数字方式显示;
-a:显示所有的套接字;
-l:显示处于监听状态的套接字;
-o:显示计时器信息;
-m:显示套接字的内存使用情况;
-p:显示使用套接字的进程信息;
-i:显示内部的TCP信息;
-4:只显示ipv4的套接字;
-6:只显示ipv6的套接字;
-t:只显示tcp套接字;
-u:只显示udp套接字;
-d:只显示DCCP套接字;
-w:仅显示RAW套接字;
-x:仅显示UNIX域套接字。
统计tcp链接数
#/bin/bash
o=$(date +%Y-%m-%d-%H)
u=$(date "+%H:%M:%S")
mkdir -p /ss
touch /ss/${o}ssyunshi.txt
echo $u>>/ss/${o}ssyunshi.txt
a=ss -t -a|wc -l
echo "总连接数$a">>/ss/${o}ssyunshi.txt
b=ss -t -a|grep TIME-WAIT|wc -l
echo "TIME-WAIT数量$b">>/ss/${o}ssyunshi.txt
c=ss -t -a|grep SYN-RECV|wc -l
echo "SYN-RECV数量$c">>/ss/${o}ssyunshi.txt
d=ss -t -a|grep SYN-SENT|wc -l
echo "SYN-SENT数量$d">>/ss/${o}ssyunshi.txt
e=ss -t -a|grep ESTAB|wc -l
echo "ESTAB数量$e">>/ss/${o}ssyunshi.txt
f=ss -t -a|grep CLOSE-WAIT|wc -l
echo "CLOSE-WAIT数量$f">>/ss/${o}ssyunshi.txt
g=ss -t -a|grep LISTEN|wc -l
echo "LISTEN数量$g">>/ss/${o}ssyunshi.txt
本文转自 苑洪武 51CTO博客,原文链接:http://blog.51cto.com/12927979/2056528