| From: | Robert Treat <xzilla(at)users(dot)sourceforge(dot)net> |
|---|---|
| To: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | connection logging dtrace probe |
| Date: | 2009-02-12 22:43:08 |
| Message-ID: | 200902121743.08659.xzilla@users.sourceforge.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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(at)%s\n",copyinstr(arg0),copyinstr(arg1)) }' |
grep robert
dtrace: description 'postgresql*:::connection ' matched 5 probes
2 18984 ServerLoop:connection connection attempt: robert(at)robert
2 16222 ServerLoop:connection connection attempt: robert(at)robert
1 16876 ServerLoop:connection connection attempt: robert(at)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
| Attachment | Content-Type | Size |
|---|---|---|
| connection_probe.diff | text/x-diff | 1.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Matteo Beccati | 2009-02-12 22:48:19 | Re: DISCARD ALL failing to acquire locks on pg_listen |
| Previous Message | Mark Roberts | 2009-02-12 22:19:01 | Re: Good Delimiter for copy command |