How to get port/socket information from kstat on Solaris

659 Views Asked by At

Is it possible to use kstat to get information about which processes have which ports open? I've looked into how lsof does it and apparently they read volatile kernel memory, which kstat seems to give access to (please correct me if I'm wrong).

I was just wondering if anyone knows how to filter kstat to display information about which processes a port has open. Perhaps which module should I look at?

2

There are 2 best solutions below

1
On

No, kstat doesn't store process level information. Moreover, kstat doesn't give access to volatile kernel memory but only to specific kernel statistics.

Finally, you shouldn't have started a new question instead of following up here.

1
On

On Solaris 11.2, you can use netstat -u to obtain that information. Per the man page:

–u

Lists the user, process id, and the program which originally created the network endpoint or controls it now.

On earlier versions of Solaris, there's no easy way - you can use pfiles to some degree, but its utility in identifying sockets is limited.

Also see What process is listening on a certain port on Solaris?