LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (https://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   netstat and PID (https://www.linuxquestions.org/questions/solaris-opensolaris-20/netstat-and-pid-598053/)

czezz 11-08-2007 09:00 AM

netstat and PID
 
On linux box I can type "netstat -anop" and it shows me PID of established connections like this:
Code:

root@proxy:~# netstat -anop
Proto Recv-Q Send-Q Local Address          Foreign Address        State      PID/Program name    Timer
tcp        0      0 0.0.0.0:3128            0.0.0.0:*              LISTEN    2652/(squid)        off (0.00/0/0)
tcp6      0      0 :::10022                :::*                    LISTEN    2580/sshd          off (0.00/0/0)
tcp6      0      0 :::80                  :::*                    LISTEN    26693/httpd        off (0.00/0/0)
tcp6      0    400 ::ffff:72.185.201:10022 ::ffff:62.134.95.:45412 ESTABLISHED29203/sshd: mxer  on (0.21/0/0)
udp        0      0 0.0.0.0:32768          0.0.0.0:*                          2652/(squid)        off (0.00/0/0)
udp        0      0 0.0.0.0:32769          0.0.0.0:*                          26713/snmpd        off (0.00/0/0)
udp        0      0 0.0.0.0:32770          0.0.0.0:*                          26713/snmpd        off (0.00/0/0)
udp        0      0 0.0.0.0:32771          0.0.0.0:*                          26713/snmpd        off (0.00/0/0)
udp        0      0 0.0.0.0:32772          0.0.0.0:*                          26713/snmpd        off (0.00/0/0)
udp        0      0 0.0.0.0:32773          0.0.0.0:*                          26713/snmpd        off (0.00/0/0)
udp        0      0 0.0.0.0:32774          0.0.0.0:*                          26713/snmpd        off (0.00/0/0)
udp        0      0 0.0.0.0:32775          0.0.0.0:*                          26713/snmpd        off (0.00/0/0)
udp        0      0 0.0.0.0:32776          0.0.0.0:*                          26713/snmpd        off (0.00/0/0)
udp        0      0 0.0.0.0:32777          0.0.0.0:*                          26713/snmpd        off (0.00/0/0)
udp        0      0 0.0.0.0:32778          0.0.0.0:*                          26713/snmpd        off (0.00/0/0)
udp        0      0 0.0.0.0:161            0.0.0.0:*                          26713/snmpd        off (0.00/0/0)
udp        0      0 0.0.0.0:162            0.0.0.0:*                          26714/snmptrapd    off (0.00/0/0)
udp        0      0 0.0.0.0:3130            0.0.0.0:*                          2652/(squid)        off (0.00/0/0)


Is there any way to do this similar under solaris 10 ?

jlliagre 11-09-2007 05:17 AM

There is no such option with Solaris netstat.

You can retrieve the ports used by a specific process with the pfiles command.

Here is a script that will display all running processes and the ports they use if any.

Code:

pfiles `ptree | awk '{print $1}'` | egrep '^[0-9]|port:'

czezz 11-09-2007 06:43 AM

That's tricky - thanks.


All times are GMT -5. The time now is 10:40 AM.