monkeygame7
monkeygame7

Reputation: 39

How to get port/socket information from kstat on Solaris

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?

Upvotes: 1

Views: 788

Answers (2)

jlliagre
jlliagre

Reputation: 30833

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.

Upvotes: 1

Andrew Henle
Andrew Henle

Reputation: 1

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?

Upvotes: 2

Related Questions