Determine which process is listening at a specific TCP port on AIX
Software developers are ignorant, lazy, and sometimes evil.
What I mean is, they often giving astoundingly detailed - yet useless - error messages when conditions for their code to run aren’t right. Like this gem from an IBM WebSphere log:
Caused by: java.sql.SQLException: Unable to connect: The application could not log on to the server “myserver.domain.com:123456”. The user ID “XXXX” or the password is incorrect. DSRA0010E: SQL State = null, Error Code = 0
Now, apparently, some webapp is trying to connect to a SQL db. Which webapp? Which db? Why not show the actual userid (those XXXX’s were original to the log)?
So, I’ve got to go on a little scavenger hunt.
I have two pieces of information with which to work:
- the server’s hostname
- the port number used for authentication to the SQL db
Let’s get started.
First of all, I need to get information about that TCP port:
# netstat -Aan | grep 123456
f100050003308bb8 tcp 0 0 *.123456 *.* LISTEN
Note the little “a” option after the big “A” for netstat. That’s important because it gets the socket identifier we need for the next step:
# rmsock f100050003308bb8 tcpcb
The socket 0xf100050003308808 is being held by proccess 987654 (foobar).
# ps -eaf | grep 987654
UID PID PPID C STIME TTY TIME CMDrogue 987654 11335577 0 Nov 03 - 0:14 /some/rdbms/start.sh -option1 -option2 -etc
Alright, now I know where to go and what to solve.
