检测服务端口的方法

通过以下方法,可查询 win 或 linux 系统中各种服务的端口是多少,方便加入到 zabbix 监管平台中

1. Linux 系统

1.1 查询 /etc/services 找端口

1
2
3
4
5
cat /etc/services | grep postgres

postgres 5432/tcp postgresql # POSTGRES

postgres 5432/udp postgresql # POSTGRES

注意:如果用户没有配置services的话,这个方法就无效。

1.2 netstat 命令查看

1
2
3
# netstat -a | grep PGSQL

unix 2 [ ACC ] STREAM LISTENING 12693978 /tmp/.s.PGSQL.5432

2. Windows 系统

待补充