> Gurus;
>
> Is there a way, through the procfs of Solaris to
> determine whether the a
> process has opened listening network ports?
>
> Either using Perl or otherwise?
>
> I know of a very iterative approach but if we apply
> the approach to all
> the ports and the processes in a running system, it
> well...does not
> really perform.
>
> I was wondering whether there was a specific API call
> in the Solaris
> procfs which readily gives the opened network port
> (if the process has one)?
>
> The above methodology must work in all three Solaris
> version. 8, 9 and 10.
>
> This implies no dtrace and no special pfiles output
> parsing (the pfiles
> output in Solaris 10 easily provides the network
> port).
>
> Warmest Regards
> Steven Sim
>
>
>
>
>
> Fujitsu Asia Pte. Ltd.
> _____________________________________________________
>
> This e-mail is confidential and may also be
> privileged. If you are not the intended recipient,
> please notify us immediately. You should not copy or
> use it for any purpose, nor disclose its contents to
> any other person.
>
> Opinions, conclusions and other information in this
> message that do not relate to the official business
> of my firm shall be understood as neither given nor
> endorsed by it.
>
>
> _______________________________________________
> opensolaris-discuss mailing list
> opensolaris-discuss at opensolaris.org
You can use "netstat -a" to determine what ports are open.
localhost.35878 *.* 0 0 49152 0 LISTEN
localhost.printer *.* 0 0 49152 0 LISTEN
localhost.57855 *.* 0 0 49152 0 LISTEN
localhost.35845 *.* 0 0 49152 0 LISTEN
localhost.52256 *.* 0 0 49152 0 LISTEN
localhost.34781 *.* 0 0 49152 0 LISTEN
localhost.59300 *.* 0 0 49152 0 LISTEN
localhost.57594 *.* 0 0 49152 0 LISTEN
localhost.41428 *.* 0 0 49152 0 LISTEN
localhost.52035 *.* 0 0 49152 0 LISTEN
localhost.62129 *.* 0 0 49152 0 LISTEN
localhost.65284 *.* 0 0 49152 0 LISTEN
localhost.63682 *.* 0 0 49152 0 LISTEN
localhost.55571 *.* 0 0 49152 0 LISTEN
localhost.53421 *.* 0 0 49152 0 LISTEN
localhost.63762 *.* 0 0 49152 0 LISTEN
localhost.39700 *.* 0 0 49152 0 LISTEN
localhost.33613 *.* 0 0 49152 0 LISTEN
localhost.60710 *.* 0 0 49152 0 LISTEN
localhost.64089 *.* 0 0 49152 0 LISTEN
localhost.37041 *.* 0 0 49152 0 LISTEN
localhost.51288 *.* 0 0 49152 0 LISTEN
[b]localhost.44341[/b] *.* 0 0 49152 0
[b]LISTEN[/b]
The example in bold says that something is listening to port 44341 on localhost.
You can use /usr/proc/bin/pfiles against your process to see which ports it has
open.
Here is a simple script:
for x in `ps -ef|awk '{print $2}'`; do echo $x; pfexec /usr/proc/bin/pfiles
$x|grep sockname; done
Output looks like this:
590
644
4309
sockname: AF_UNIX
4106
596
634
sockname: AF_UNIX
1502
728
sockname: AF_INET 0.0.0.0 port: 631
3528
3521
sockname: AF_UNIX
sockname: AF_UNIX
sockname: AF_UNIX
sockname: AF_INET 127.0.0.1 port: 34781
This message posted from opensolaris.org