3

Actually , I am running four daemon program. It makes postgres connection, and it disconnects once through with the stuffs. But When I am putting ps aux , there are lot of postgres idle process being run in my system. I just want to know , originator of the each idle postres process. So, that I could find out which process does not close postgres connection properly.

Thanks in Advance .

0

4 Answers 4

4

Use following command

netstat -ntp

It will show the process id and process name of postgres connector creator.

Sign up to request clarification or add additional context in comments.

Comments

2

If you are using postgresql 9.0, set the "application name" property when you connect so that you can distinguish which client process each server process is talking to. For example (Perl):

$dbh = DBI->connect("dbi:Pg:application_name=test/$$", undef, undef)

This will include the client PID in the application name, which is ugly but effective.

If you are connecting over TCP/IP, then pg_stat_activity includes the client port which you can use with lsof (or netstat -p) to find the client process.

Comments

0

See How can you get the active users connected to a postgreSQL database via SQL?

that can get the pid and uid of the connected processes

2 Comments

I think , table shows me the process id of the postres, not the originator of the postgres process id.
stackoverflow.com/questions/464623/… seems to say what your asking for
0

you can use these commands to check the idle process and it's details

sudo su postgres
psql
connect to your database
\c db_name;
select * from pg_stat_activity where status='idle';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.