1

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 Answers2

2

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?

Community
  • 1
  • 1
Andrew Henle
  • 32,625
  • 3
  • 24
  • 56
  • Yeah, this is only 11.0 unfortunately. And pfiles is out of the question because it takes entirely too long to execute, plus the fact that it can sometimes crash processes since it has to suspend them. – monkeygame7 Aug 06 '15 at 21:10
1

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.

Community
  • 1
  • 1
jlliagre
  • 29,783
  • 6
  • 61
  • 72
  • They are different questions, the other one isn't about kstat at all. I mean they're trying to do the same thing, but I'm asking about different mechanisms in each question. – monkeygame7 Aug 10 '15 at 13:59