[Techtalk] $ who issue

Anne Wainwright anotheranne at fables.co.za
Fri Jul 16 21:56:54 UTC 2010


Hello, Daniel, Wim,

The psql \du returns the postgresql 'users' and not who is logged on.
Maybe I need to study the manual a bit, but I could find no suitable
command. Wim, the --command option I did not know about, that looks
very easy & useful so will investigate a bit further.

The ps output suitably grepped does show which machines are connected
to postgresql, so thanks for this tip, Daniel. 

$ ps axwww | grep databasename

gives the needed output, grep puts out only the lines with
'databasename' in them so no need for me to pipe the grep output through
head (at least on my setup).

I see I you used three or four 'w's , the manual only indicates a need
for 1 or 2. I'll experiment and see what gives. I see this is a complex
command and the manual deserves an evening's read and play.

thanks for helping me nail this one, now I don't have to ask everyone
who is still connected when i want to switch off the server at five
minutes to 5 o'clock.

Anne


On Wed, 14 Jul 2010 18:07:02 +1000
Daniel Pittman <daniel at rimspace.net> wrote:

> Wim De Smet <kromagg at gmail.com> writes:
> > On Wed, Jul 14, 2010 at 1:13 AM, Anne Wainwright
> > <anotheranne at fables.co.za> wrote:
> >>
> >> Hello, Anne,
> >>
> >> You are a klutz. Check this problem out again, what happens is not
> >> exactly as described.
> >
> > Now Anne, I think you're being too hard on Anne. ;-)
> 
> I would, personally, agree.
> 
> [...]
> 
> >> Without logging on as a postgresql user and issuing the psql
> >> command '\du' is there any way of detecting someone so connected
> >> to that server?
> >
> > I don't think so.
> 
> 'ps axwwww' or equivalent should do it on most platforms: PostgreSQL
> forks a process for every client connection, and that shows the user,
> where they are connected from, and what they are doing:
> 
> ps axwww | grep postgres | head -n 2
> 30996 ?        SNs    0:00 postgres: websurvey_enrollment
> websurvey_enrollment 192.168.10.106(52289) idle 31779 ?        SNs
> 0:00 postgres: sd_cec_icuclab sd_cec_icuclab 192.168.10.79(57683) idle
> 
> That isn't much better than using psql to ask, however.
> 
> Regards,
>         Daniel


More information about the Techtalk mailing list