Как узнать сокеты, используемые в выполняющихся процессах
How to know sockets used in running processes

Создайте скрипт:

Create script:

#!/bin/sh
#
# For Solaris 10
#
LIST=`/usr/bin/ps -e | /usr/bin/nawk '{print $1}'`

for i in $LIST
do
  TXT=`/usr/bin/pfiles $i 2>&1 | /usr/bin/nawk "/^$i:/{print;next}/^\t.*AF_INET/{print;next}"`
  if [ `/usr/bin/echo "$TXT" | /usr/bin/wc -l` -ne 1 ]
  then
    /usr/bin/echo "$TXT"
  fi
done

Назовите его psocket. Теперь Вы будете иметь команду, с помощью которой можно посмотреть сокеты выполняющихся процессов. Если Вы запустите её как обычный пользователь, то получите информацию только о процессах принадлежащих этому пользователю. Root же получит информацию о всех выполняющихся процессах.

Name it "psocket". Now you will have the command, which shows for you sockets of running processes. If you start it like simple user, you will obtain only information about this user's processes. Root will obtain information about all processes.

# ./psocket
472:	/usr/lib/inet/inetd start
	sockname: AF_INET6 ::  port: 7100
	sockname: AF_INET 0.0.0.0  port: 6112
	sockname: AF_INET6 ::  port: 6481
	sockname: AF_INET 0.0.0.0  port: 6481
	sockname: AF_INET6 ::  port: 23
	sockname: AF_INET6 ::  port: 21
	sockname: AF_INET6 ::  port: 79
	sockname: AF_INET6 ::  port: 513
	sockname: AF_INET 0.0.0.0  port: 514
	sockname: AF_INET6 ::  port: 514
	sockname: AF_INET 0.0.0.0  port: 7008
	sockname: AF_INET6 ::  port: 69
486:	/usr/sadm/lib/smc/bin/smcboot
	sockname: AF_INET 127.0.0.1  port: 5987
	sockname: AF_INET 127.0.0.1  port: 898
	sockname: AF_INET 127.0.0.1  port: 5988
406:	/usr/lib/nfs/statd
	sockname: AF_INET 0.0.0.0  port: 0
	sockname: AF_INET 0.0.0.0  port: 0
	sockname: AF_INET 0.0.0.0  port: 0
487:	/usr/sadm/lib/smc/bin/smcboot
	sockname: AF_INET 127.0.0.1  port: 32773
488:	/usr/sadm/lib/smc/bin/smcboot
	sockname: AF_INET 127.0.0.1  port: 32774
782:	/usr/lib/sendmail -bd -q15m
	sockname: AF_INET 0.0.0.0  port: 25
	sockname: AF_INET6 ::  port: 25
	sockname: AF_INET 0.0.0.0  port: 587
686:	/usr/lib/snmp/snmpdx -y -c /etc/snmp/conf
	sockname: AF_INET 0.0.0.0  port: 16161
	sockname: AF_INET 0.0.0.0  port: 32791
	sockname: AF_INET 0.0.0.0  port: 32792
797:	/opt/mount_ntfs/bin/mount_ntfs /dev/rdsk/c2d0p1 /disk_c
	sockname: AF_INET 127.0.0.1  port: 32801
6768:	/usr/apache/bin/httpd
	sockname: AF_INET 0.0.0.0  port: 80
800:	/opt/mount_ntfs/bin/mount_ntfs /dev/rdsk/c2d0p2 /disk_d
	sockname: AF_INET 127.0.0.1  port: 32802
10212:	/usr/lib/gconfd-2 15
	sockname: AF_INET 127.0.0.1  port: 38848
10405:	/usr/local/bin/xmms
	sockname: AF_INET 192.168.175.19  port: 39720
	peername: AF_INET 91.121.113.72  port: 9068
916:	/opt/SUNWut/srds/lib/utdsd -p 7012
	sockname: AF_INET 0.0.0.0  port: 7012
	sockname: AF_INET 192.168.175.19  port: 7012
	peername: AF_INET 192.168.175.19  port: 32791
1046:	/usr/apache/bin/httpd
	sockname: AF_INET 0.0.0.0  port: 80
6750:	/usr/apache/bin/httpd
	sockname: AF_INET 0.0.0.0  port: 80
685:	/usr/lib/ssh/sshd
	sockname: AF_INET6 ::  port: 22
777:	/usr/sfw/sbin/snmpd
	sockname: AF_INET 0.0.0.0  port: 161
	sockname: AF_INET 0.0.0.0  port: 32803
	sockname: AF_INET 0.0.0.0  port: 0
959:	/usr/lib/inet/in.dhcpd
	sockname: AF_INET 255.255.255.255  port: 67
	sockname: AF_INET 192.168.175.0  port: 67
	sockname: AF_INET 192.168.175.19  port: 67
	sockname: AF_INET 255.255.255.255  port: 67
	sockname: AF_INET 192.168.0.0  port: 67
	sockname: AF_INET 192.168.0.1  port: 67
	sockname: AF_INET 255.255.255.255  port: 67
	sockname: AF_INET 192.168.56.0  port: 67
	sockname: AF_INET 192.168.56.1  port: 67
1141:	/usr/apache/bin/httpd
	sockname: AF_INET 0.0.0.0  port: 80
9890:	/usr/X11/bin/Xorg :0 -depth 24 -nobanner -auth /var/dt/A:0-J5ay_b
	sockname: AF_INET6 ::  port: 6000
	sockname: AF_INET 0.0.0.0  port: 6000
	sockname: AF_INET 192.168.175.19  port: 6000
	peername: AF_INET 192.168.175.19  port: 38933
1019:	/usr/dt/bin/dtlogin -daemon
	sockname: AF_INET6 ::  port: 177
	sockname: AF_INET 0.0.0.0  port: 32799
1143:	/usr/apache/bin/httpd
	sockname: AF_INET 0.0.0.0  port: 80
1145:	/usr/apache/bin/httpd
	sockname: AF_INET 0.0.0.0  port: 80
1142:	/usr/apache/bin/httpd
	sockname: AF_INET 0.0.0.0  port: 80
1144:	/usr/apache/bin/httpd
	sockname: AF_INET 0.0.0.0  port: 80
1254:	/etc/opt/SUNWut/jre/bin/java -client auth.utauthd.utauthd
	sockname: AF_INET6 ::ffff:192.168.175.19  port: 32791
	peername: AF_INET6 ::ffff:192.168.175.19  port: 7012
	sockname: AF_INET 0.0.0.0  port: 7010
	sockname: AF_INET 0.0.0.0  port: 32793
	sockname: AF_INET 127.0.0.1  port: 7010
	peername: AF_INET 127.0.0.1  port: 40265
	sockname: AF_INET 0.0.0.0  port: 7009
	sockname: AF_INET 0.0.0.0  port: 7009
6752:	/usr/apache/bin/httpd
	sockname: AF_INET 0.0.0.0  port: 80
1350:	/opt/SUNWut/lib/utsessiond -r -c /etc/opt/SUNWut/auth.permit
	sockname: AF_INET 0.0.0.0  port: 7007
1351:	/opt/SUNWut/lib/utdevmgrd -r -c /etc/opt/SUNWut/auth.permit
	sockname: AF_INET 0.0.0.0  port: 7011
	sockname: AF_INET 127.0.0.1  port: 40265
	peername: AF_INET 127.0.0.1  port: 7010
1481:	/etc/opt/SUNWut/jre/bin/java -server -Djava.security.manager -Djava.se
	sockname: AF_INET 0.0.0.0  port: 1660
	sockname: AF_INET 0.0.0.0  port: 32798
	sockname: AF_INET 0.0.0.0  port: 1661
	sockname: AF_INET 127.0.0.1  port: 50505
1376:	/usr/java/bin/java -server -Xmx128m -XX:+BackgroundCompilation -XX:Per
	sockname: AF_INET 127.0.0.1  port: 6788
	sockname: AF_INET 0.0.0.0  port: 32796
	sockname: AF_INET 127.0.0.1  port: 6789
	sockname: AF_INET 127.0.0.1  port: 32787
6767:	/usr/apache/bin/httpd
	sockname: AF_INET 0.0.0.0  port: 80
6751:	/usr/apache/bin/httpd
	sockname: AF_INET 0.0.0.0  port: 80
10230:	dtpad -server
	sockname: AF_INET6 ::ffff:192.168.175.19  port: 38933
	peername: AF_INET6 ::ffff:192.168.175.19  port: 6000
10210:	/export/home/firefox/firefox-bin
	sockname: AF_INET 127.0.0.1  port: 38851
	sockname: AF_INET 192.168.175.19  port: 39698
	peername: AF_INET 209.85.135.100  port: 80
	sockname: AF_INET 192.168.175.19  port: 39699
	peername: AF_INET 212.188.7.19  port: 80
	sockname: AF_INET 192.168.175.19  port: 39700
	peername: AF_INET 212.188.7.19  port: 80
	sockname: AF_INET 192.168.175.19  port: 39701
	peername: AF_INET 209.85.135.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39702
	peername: AF_INET 209.85.135.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39703
	peername: AF_INET 209.85.135.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39704
	peername: AF_INET 209.85.135.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39705
	peername: AF_INET 209.85.135.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39706
	peername: AF_INET 209.85.135.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39707
	peername: AF_INET 209.85.135.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39708
	peername: AF_INET 209.85.135.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39709
	peername: AF_INET 74.125.43.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39710
	peername: AF_INET 74.125.43.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39716
	peername: AF_INET 92.123.155.10  port: 80
	sockname: AF_INET 192.168.175.19  port: 39712
	peername: AF_INET 74.125.43.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39713
	peername: AF_INET 74.125.43.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39714
	peername: AF_INET 74.125.43.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39719
	peername: AF_INET 92.123.155.10  port: 80
#
 
$ ./psocket
10212:	/usr/lib/gconfd-2 15
	sockname: AF_INET 127.0.0.1  port: 38848
10405:	/usr/local/bin/xmms
	sockname: AF_INET 192.168.175.19  port: 39720
	peername: AF_INET 91.121.113.72  port: 9068
10230:	dtpad -server
	sockname: AF_INET6 ::ffff:192.168.175.19  port: 38933
	peername: AF_INET6 ::ffff:192.168.175.19  port: 6000
10210:	/export/home/firefox/firefox-bin
	sockname: AF_INET 127.0.0.1  port: 38851
	sockname: AF_INET 192.168.175.19  port: 39698
	peername: AF_INET 209.85.135.100  port: 80
	sockname: AF_INET 192.168.175.19  port: 39701
	peername: AF_INET 209.85.135.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39702
	peername: AF_INET 209.85.135.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39703
	peername: AF_INET 209.85.135.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39704
	peername: AF_INET 209.85.135.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39705
	peername: AF_INET 209.85.135.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39706
	peername: AF_INET 209.85.135.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39707
	peername: AF_INET 209.85.135.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39708
	peername: AF_INET 209.85.135.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39709
	peername: AF_INET 74.125.43.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39710
	peername: AF_INET 74.125.43.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39716
	peername: AF_INET 92.123.155.10  port: 80
	sockname: AF_INET 192.168.175.19  port: 39712
	peername: AF_INET 74.125.43.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39713
	peername: AF_INET 74.125.43.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39714
	peername: AF_INET 74.125.43.118  port: 80
	sockname: AF_INET 192.168.175.19  port: 39719
	peername: AF_INET 92.123.155.10  port: 80
$ 

This page last updated on Oct 5, 2009. Copyright © 2009, Vitaly Filatov, Moscow, Russia
Webmaster