一个进程打开了哪些端口在监听
为了让Node.js 能够充分利用多核的CPU,会开一个进程多个worker的模式, 每个worker是一个Node.js event loop. 如何查看开了哪些端口.
eric@eric1:~$ sudo netstat --all --program | grep '8481'
tcp 0 0 localhost:6666 *:* LISTEN 8481/pm2: Daemon
tcp 0 0 localhost:ircd *:* LISTEN 8481/pm2: Daemon
tcp6 0 0 [::]:http-alt [::]:* LISTEN 8481/pm2: Daemon
tcp6 0 0 [::]:8082 [::]:* LISTEN 8481/pm2: Daemon
tcp6 0 0 [::]:10100 [::]:* LISTEN 8481/pm2: Daemon
tcp6 0 0 [::]:10101 [::]:* LISTEN 8481/pm2: Daemon
tcp6 0 0 [::]:10102 [::]:* LISTEN 8481/pm2: Daemon
unix 3 [ ] STREAM CONNECTED 573099484 8481/pm2: Daemon
unix 3 [ ] STREAM CONNECTED 573099481 8481/pm2: Daemon
unix 3 [ ] STREAM CONNECTED 573099491 8481/pm2: Daemon
eric@eric1:~$ sudo lsof -i -P |grep 8481
pm2: 8481 rebot 3u IPv6 573099604 0t0 TCP *:10100 (LISTEN)
pm2: 8481 rebot 12u IPv4 573098742 0t0 TCP localhost:6666 (LISTEN)
pm2: 8481 rebot 13u IPv4 573098743 0t0 TCP localhost:6667 (LISTEN)
pm2: 8481 rebot 17u IPv6 573099599 0t0 TCP *:8082 (LISTEN)
pm2: 8481 rebot 18u IPv6 573099600 0t0 TCP *:8080 (LISTEN)
pm2: 8481 rebot 20u IPv6 573099610 0t0 TCP *:10101 (LISTEN)
pm2: 8481 rebot 22u IPv6 573099619 0t0 TCP *:10102 (LISTEN)
进程的线程之间的相互关系:
pstree -a -p -H 8481
pstree -a -l -p -s 8481
top -H -p 8481
ps -L H 8481
ps -eLf
htop 8481