(base) [root@localhost ~]# netstat -ntlp | awk 'BEGIN{ system("echo \\|IP\\|Port\\|PID\\|Parameter\\| > /tmp/
reporter.md; echo \\|-\\|-\\|-\\|-\\| >> /tmp/
reporter.md") } NR>2 {if($4 !~ "::" && $7 != "-"){split($4,ipAndPort,":"); split($7,pidAndProgress,"/"); system("echo \\|"ipAndPort[1]"\\|"ipAndPort[2]"\\|"pidAndProgress[1]"\\|`cat /proc/"pidAndProgress[1]"/cmdline`\\| >> /tmp/
reporter.md")}}'
(base) [root@localhost ~]# cat /tmp/
reporter.md |IP|Port|PID|Parameter|
|-|-|-|-|
|0.0.0.0|139|5042|/usr/sbin/smbd--foreground--no-process-group|
|0.0.0.0|22|5044|/usr/sbin/sshd-D|
|127.0.0.1|25|5479|/usr/libexec/postfix/master-w|
|0.0.0.0|445|5042|/usr/sbin/smbd--foreground--no-process-group|
只能显示几个服务,redis, mysql, docker 里运行的 web 服务都没有显示呢