[20200306]expand格式化输出.txt
--//以前提到ss输出太宽,使用column过滤。实际上输出是不对齐的。
# ss -notp | column -t
State Recv-Q Send-Q Local Address:Port Peer Address:Port
ESTAB 0 0 192.168.100.78:1521 192.168.100.78:9988 timer:(keepalive,6.786ms,0) users:(("tnslsnr",40011,12))
ESTAB 0 0 192.168.100.78:63637 192.168.100.40:1521 users:(("oracle",23221,10))
ESTAB 0 0 192.168.100.78:63636 192.168.100.40:1521 users:(("oracle",41372,12))
ESTAB 0 0 192.168.100.78:9988 192.168.100.78:1521 users:(("oracle",23173,10))
--// Local Address:Port 应该是一个字段。比较好的方法是使用expand。
# ss -notp | expand
State Recv-Q Send-Q Local Address:Port Peer Address:Port
ESTAB 0 0 192.168.100.78:1521 192.168.100.78:9988 timer:(keepalive,18sec,0) users:(("tnslsnr",40011,12))
ESTAB 0 0 192.168.100.78:63637 192.168.100.40:1521 users:(("oracle",23221,10))
ESTAB 0 0 192.168.100.78:63636 192.168.100.40:1521 users:(("oracle",41372,12))
ESTAB 0 0 192.168.100.78:9988 192.168.100.78:1521 users:(("oracle",23173,10))
--//这样就比较好看了。使用column 不用加 -t 参数也能获得好的输出效果。
# ss -notp | column
State Recv-Q Send-Q Local Address:Port Peer Address:Port
ESTAB 0 0 192.168.100.78:1521 192.168.100.78:9988 timer:(keepalive,3.285ms,0) users:(("tnslsnr",40011,12))
ESTAB 0 0 192.168.100.78:63637 192.168.100.40:1521 users:(("oracle",23221,10))
ESTAB 0 0 192.168.100.78:63636 192.168.100.40:1521 users:(("oracle",41372,12))
ESTAB 0 0 192.168.100.78:9988 192.168.100.78:1521 users:(("oracle",23173,10))
--//看看后面users:(("oracle",23173,10))表示什么?远程登录数据库。
SCOTT@78> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- -------------------- ------- ---------- --------------------------------------------------
30 2279 8012:7276 DEDICATED 40816 26 65 alter system kill session '30,2279' immediate;
# netstat -ntop 2>/dev/null | egrep "Proto|40816"
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name Timer
tcp 0 0 192.168.100.78:1521 192.168.98.6:57576 ESTABLISHED 40816/oraclebook keepalive (22.94/0/0)
# ss -notp | column | egrep "40816|State"
State Recv-Q Send-Q Local Address:Port Peer Address:Port
ESTAB 0 0 192.168.100.78:1521 192.168.98.6:57576 timer:(keepalive,20sec,0) users:(("oracle",40816,13))
--//users:(("oracle",40816,13)) 第1个参数是进程名oracle。 第2个参数是进程好。第3个表示什么呢?
--//猜测是socket文件句柄:
$ ls -l /proc/40816/fd
total 0
lr-x------ 1 oracle oinstall 64 2020-03-06 10:42:20 0 -> /dev/null
l-wx------ 1 oracle oinstall 64 2020-03-06 10:42:20 1 -> /dev/null
lrwx------ 1 oracle oinstall 64 2020-03-06 10:42:20 13 -> socket:[9648757]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
l-wx------ 1 oracle oinstall 64 2020-03-06 10:42:20 2 -> /dev/null
lrwx------ 1 oracle oinstall 64 2020-03-06 10:42:20 256 -> /mnt/ramdisk/book/system01.dbf
lr-x------ 1 oracle oinstall 64 2020-03-06 10:42:20 3 -> /dev/null
lr-x------ 1 oracle oinstall 64 2020-03-06 10:42:20 4 -> /u01/app/oracle/product/11.2.0.4/dbhome_1/rdbms/mesg/oraus.msb
lr-x------ 1 oracle oinstall 64 2020-03-06 10:42:20 5 -> /proc/40816/fd
lr-x------ 1 oracle oinstall 64 2020-03-06 10:42:20 6 -> /dev/zero
--//很奇怪ss命令没有man文档。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2678798/ ,如需转载,请注明出处,否则将追究法律责任。