* ports and processes in Solaris

Posted on September 24th, 2008 by doug. Filed under Solaris.


 

In Linux, “netstat -apn” will list processes versus ports bound to:


dsm@dali:~$ netstat -apn
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:24800 0.0.0.0:* LISTEN 9353/synergys
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN -
tcp 0 0 172.17.8.76:43003 172.19.235.82:22 ESTABLISHED 4305/ssh
tcp 0 0 172.17.8.76:32852 198.200.144.106:22 ESTABLISHED 13523/ssh
tcp 0 0 172.17.8.76:44173 198.200.144.106:22 ESTABLISHED 13546/ssh
tcp 0 0 172.17.8.76:53463 172.17.85.49:22 ESTABLISHED 28801/ssh
tcp 0 0 172.17.8.76:57385 172.19.230.85:22 ESTABLISHED 5208/ssh

If you want to see, say, all the ssh processes:


dsm@dali:~$ netstat -apn | grep ssh
tcp 0 0 172.17.8.76:43003 172.19.235.82:22 ESTABLISHED 4305/ssh
tcp 0 0 172.17.8.76:32852 198.200.144.106:22 ESTABLISHED 13523/ssh
tcp 0 0 172.17.8.76:44173 198.200.144.106:22 ESTABLISHED 13546/ssh
tcp 0 0 172.17.8.76:53463 172.17.85.49:22 ESTABLISHED 28801/ssh
tcp 0 0 172.17.8.76:57385 172.19.230.85:22 ESTABLISHED 5208/ssh
tcp 0 0 172.17.8.76:58116 172.19.220.114:22 ESTABLISHED 5459/ssh
etc...

On Solaris… On SUN’s Solaris there isn’t an easy way to accomplish the same. On a normal non-containerized server you can run netstat and then lsof…

Assume that you know there is a process conflict – some process has already bound to a port 8083. Your process fails because it can’t bind to the port it needs, that port is already in use – somewhere.

netstat –an | grep 8083 gives you:

[dsm@sun1 bin] $ netstat -an | grep 8083
198.200.144.14.8083 *.* 0 0 49152 0 LISTEN
198.200.144.30.8083 *.* 0 0 49152 0 LISTEN
198.200.144.17.8083 *.* 0 0 49152 0 LISTEN
*.8083 *.* 0 0 49152 0 LISTEN
198.200.144.90.8083 *.* 0 0 49152 0 LISTEN
198.200.144.10.8083 *.* 0 0 49152 0 LISTEN

The *.8083 is our problem child, but we don’t have which process is bound to that port yet.


[dsm@sun1 bin] $ lsof -i:8083
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 1548 jb-1 18u IPv4 0x3005df7be68 0t0 TCP s1q:8083 (LISTEN)
java 6903 appadmin 5u IPv4 0x30070580ae8 0t0 TCP *:8083 (LISTEN)
java 7497 jb-2 9u IPv4 0x300099344d0 0t0 TCP webq1:8083 (LISTEN)
java 7989 jb-3 9u IPv4 0x32af1cd79a8 0t0 TCP ntumq1:8083 (LISTEN)
java 9445 jb-ty 9u IPv4 0x30009925e30 0t0 TCP tyq1:8083 (LISTEN)
java 16369 jb-jun 9u IPv4 0x3007b9a21f0 0t0 TCP rjq1:8083 (LISTEN)
[dsm@sun1 bin] $

Process id 6903 if the villian of this piece in this case.

And this works on servers, but not within containerized servers… On a container you get:


$ lsof -i :8083
lsof: can't stat(/devices): No such file or directory

Basically, a zone within a Solaris10 global zone doesn’t have a /devices directory; so you can’t ! You have to do this from the global zone – not ideal :-|

 

— dsm

 

share: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • Bloglines
  • email
  • Facebook
  • Faves
  • LinkedIn
  • Mixx
  • Netscape
  • Newsrider
  • Slashdot
  • Technorati
  • TwitThis

Tags: ,



Trackback URI | Comments RSS

Leave a Reply


engineers

recent posts

What I'm Doing...

  • waiting for Dell to inform FedEx they've shipped my netbook... 2010-06-07
  • sorting out stuff (moving...) 2010-05-25
  • downloaded netbook remix (for my Asus) and amd64 (for my 64 bit Intel PC) - desktop for everything else has slowed to 120 kbs... 37 minutes 2010-04-29
  • More updates...

Posting tweet...

categories

archives

tag cloud

apache apache2 bash shell browsers comics compile cygwin data databases daughter eclipse economics engineer entropy finances firefox 3 hallucinations Heinlein internet java jboss KDE linux moinmoin monitoring nagios plugins RSE scifi script Solaris structure subversion support svn testing tweet UNIX UNIX & Windows web hosting website websphere windows WordPress writing

admin