connection logging dtrace probe - Mailing list pgsql-hackers

From Robert Treat
Subject connection logging dtrace probe
Date
Msg-id 200902121743.08659.xzilla@users.sourceforge.net
Whole thread Raw
Responses Re: connection logging dtrace probe
List pgsql-hackers
I whipped up a quick dtrace probe for one of our servers to monitor connection 
attempts.  My goal was to monitor for any connection attempts from a specific 
role within the database.  Unfortunatly you can't set logging of connections 
for a specific user, and logging all connections on that machine would be 
quite the logfile bloater... enter dtrace. With the probe, I can do something 
like this:

-bash-3.00$ /opt/csw/bin/sudo dtrace -n 'postgresql*:::connection 
{printf("connection attempt: %s@%s\n",copyinstr(arg0),copyinstr(arg1)) }' | 
grep robert
dtrace: description 'postgresql*:::connection ' matched 5 probes 2  18984            ServerLoop:connection connection
attempt:robert@robert 2  16222            ServerLoop:connection connection attempt: robert@robert 1  16876
ServerLoop:connectionconnection attempt: robert@pagila
 

which can be piped to logfile or whatever. I'm attaching a patch against 8.4 
as an idea of what I've implemented (actual implementation was against a 
custom build) but should be close to working (don't have a working pg repo on 
any solaris machines atm). Any feedback appreciated (mostly wondering about 
probe name or location). TIA

-- 
Robert Treat
Conjecture: http://www.xzilla.net
Consulting: http://www.omniti.com

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [ADMIN] database corruption help
Next
From: Matteo Beccati
Date:
Subject: Re: DISCARD ALL failing to acquire locks on pg_listen