Determining which users are logged onto the db - Mailing list pgsql-admin

From reina@nsi.edu (Tony Reina)
Subject Determining which users are logged onto the db
Date
Msg-id f40d3195.0107121616.13a0a9fb@posting.google.com
Whole thread Raw
List pgsql-admin
I have a few shell scripts that run when I log into the Postgres
administrator account on my db (i.e. user = 'postgres'). I'd like to
find a simple way to also list from the shell script which users are
currently querying the db.

I know I can see the db backends by using:

 database > ps ax | grep post

 1215 ?        S      0:00 /database/local/pgsql/bin/postmaster -D
/database/loc
 1381 pts/0    S      0:00 login -- postgres
 1412 ?        S      0:00 postgres: reina db01 xxx.xxx.xxx.xxx idle
 1413 ?        S      0:00 postgres: abs db01 xxx.xxx.xxx.xxx idle
 1414 ?        S      0:00 postgres: reina db01 xxx.xxx.xxx.xxx idle

Is there a way that I can parse out the user names 'reina' and 'abs'?
Perhaps a sed command?

-Tony

pgsql-admin by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Dump from Postgresql95
Next
From: Ricardo Maia
Date:
Subject: Error accessing PostgreSQL