From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Rajesh Kumar Mallah <mallah@trade-india.com>
Cc: PGSQL List (E-mail) <pgsql-admin@postgresql.org>
Subject: Re: fishing out LOG: duration lines from the logfile.
Date: Fri, 31 Oct 2003 16:24:54 -0500 (EST)
Message-ID: <200310312124.h9VLOs127219@candle.pha.pa.us> (raw)
In-Reply-To: <3FA473C5.3020509@trade-india.com>
Rajesh Kumar Mallah wrote:
>
> Hi,
>
> I think its not going to a trivial task to take out only the LOG duration
> lines from a PostgreSQL logfile. We need to extract the duration and
> the actual statement. I think i will put a custom delimeters around the
> statements for the time being so that the log parser can parse it
> unambigiously. Is there any better method?
Seeing that I was involved in implementing this behavior, I felt I
should write a script to pull out this information to see how hard it
would be. Here is an awk script:
awk ' BEGIN {in_statement = "N"}
{
while (getline > 0)
{
if ($1 == "LOG:" && $2 == "duration:" && $5 == "statement:")
{
print $0;
in_statement = "Y";
}
else if (in_statement == "Y" && $0 ~ /^ /) # <-- tab
{
print $0;
}
else
in_statement = "N";
}
}' "$@"
I tested this with the log file you included and it seeme to work fine,
though the email had some line wraps I had to remove.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: pgman@candle.pha.pa.us, mallah@trade-india.com
Subject: Re: fishing out LOG: duration lines from the logfile.
In-Reply-To: <200310312124.h9VLOs127219@candle.pha.pa.us>
References: <3FA473C5.3020509@trade-india.com> <200310312124.h9VLOs127219@candle.pha.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox