Len Morgan writes:
>> My question is this: Is there a way to identify on the line
>> which starts up the backends, which host is starting it? In other
>> words, if I do ps -ax on the server, can I have an ip address or host
>> name show up to let me know which host is connected to which backend?
Hackers, if anyone does something with setting the backend process title,
this seems like a good idea to me.
However, a feature that may or may not show up in 6.4 is not going to
help Len with his immediate problem. Len, I'd suggest a couple of
things you can do today:
1. netstat on your server will show open TCP connections. Look for
connections to port 5432 at your end. If you have a lot of users
it might be hard to spot the culprit --- but I suspect that looking
for the machine that shows a number of open connections, not just
one, will do it.
2. If that doesn't work, but you can identify a backend process that's
been laying around for awhile, you can use "lsof" to find out
which network connection leads to that process. For example,
I use ps to find that process 21309 is a backend, then:
$ lsof -p 21309
COMMAND PID USER FD TYPE DEVICE SIZE/OFF INODE NAME
postgres 21309 postgres 3u inet 0x0d2d1b00 0t0 TCP *:5432 (LISTEN)
postgres 21309 postgres 5u inet 0x0d749000 0t302 TCP localhost:5432->localhost:2325 (ESTABLISHED)
postgres 21309 postgres 6u inet 0x0d749000 0t302 TCP localhost:5432->localhost:2325 (ESTABLISHED)
(lots of non-inet open files for this process snipped)
So I see the client connected to this server is at port 2325 on
localhost.
lsof (list open files) might already be installed on your machine,
if not see http://www-rcd.cc.purdue.edu/abe/. It's an invaluable
tool for debugging all sorts of Unix problems, well worth having
in your sysadmin kit.
regards, tom lane