Originally posted by: SystemAdmin
This utility can be obtained from the Linux Toolkit for AIX CD, The AIX toolbox for Linux on the web at
http://www-1.ibm.com/servers/aix/products/aixos/linux/ , or from ftp://vic.cc.purdue.edu/pub/
With this utility you can get process information for any open file and the ports are treated by UNIX as open files. To look at the process information for say port
lsof -i | grep 5901
Xvnc 33152 jwtesch 6u IPv4 0x7006d1f0 0t0 TCP *:5901 (LISTEN)
This can be useful if you find a port with a lot of network traffic that may be hurting the performance, but don't know the process that is using the port.
For a complete list of all the processes that are using the network you can use the following script.
Shell script source
#!/bin/ksh
#script title=/tmp/port-process.ksh
netstat -a|grep LISTEN|awk '{print $4}'>/tmp/port.list
for PORT in `cat /tmp/port.list`
do
/usr/sbin/lsof -i | grep $PORT
done
echo "script exection $0 completed"
Sample Output
inetd 12540 root 11u IPv4 0x701ef9f0 0t0 TCP *:daytime (LISTEN)
inetd 12540 root 14u IPv4 0x701e8400 0t0 UDP *:daytime
inetd 12540 root 4u IPv6 0x7006e9f0 0t0 TCP *:ftp (LISTEN)
sshd 10944 root 3u IPv4 0x7006ddf0 0t0 TCP *:ssh (LISTEN)
inetd 12540 root 5u IPv6 0x701ecdf0 0t0 TCP *:telnet (LISTEN)
sendmail 33648 root 9u IPv4 0x704159f0 0t0 TCP *:smtp (LISTEN)
inetd 12540 root 12u IPv4 0x701ef5f0 0t0 TCP *:time (LISTEN)
inetd 12540 root 15u IPv4 0x701e8700 0t0 UDP *:time
#AIX-Forum