Re: pg error log file monitor

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <isabella(dot)ghiurea(at)nrc-cnrc(dot)gc(dot)ca>,<pgsql-admin(at)postgresql(dot)org>
Subject: Re: pg error log file monitor
Date: 2009-04-14 17:19:23
Message-ID: 49E47F4B.EE98.0025.0@wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

>>> Isabella Ghiurea <isabella(dot)ghiurea(at)nrc-cnrc(dot)gc(dot)ca> wrote:
> I'm looking if some has a script to monitor the PG database error log

> (*.log) , if ther are any new messages/errors written to this file
to
> get an email or kind of notification.

This is something which was thrown together in a hurry years ago, and
never since touched because it works well enough, so it's hardly a
shining model of best practice; but maybe it will help some.

datestring=$(date '+%F')*
echo "date: $(date +%F_%H%M)" > emailfile
echo "to: dbagroup(at)wicourts(dot)gov" >> emailfile
echo "subject: Server Vacuum Analyze information " >> emailfile
echo " " >> emailfile
echo "Free space required information " >> emailfile
echo "---------------------------" >> emailfile

grep -Ew2 VACUUM /home/ccsa/vacuum-analyze-bigbird.out >>emailfile
echo "---------------------------" >> emailfile
echo "Space information on Tables " >> emailfile
echo "---------------------------" >> emailfile
grep -E -B3 '^([0-9]{6,12}|[5-9][0-9]{4}) pages contain useful free
space' /home/ccsa/vacuum-analyze-bigbird.out >> emailfile
echo " " >> emailfile
echo "---------------------------" >> emailfile
echo "Information from pg_logs " >> emailfile
echo "---------------------------" >> emailfile

echo Number of Canceling statements due to user request >> emailfile
grep -iE error /var/pgsql/data/cc/pg_log/postgresql-$datestring|grep
-iEc "canceling" >> emailfile
grep -iE error /var/pgsql/data/cc/pg_log/postgresql-$datestring|grep
-iEv "canceling|storage sync" >> emailfile
echo "---------------------------" >> emailfile
echo "Information from server.log " >> emailfile
echo "---------------------------" >> emailfile
grep -iEb1 "memory|truncate" /opt/ccap/cc/cir/tran/log/server.log|grep
-iEb1 "$datestring" >> emailfile

/usr/sbin/sendmail -t < emailfile

-Kevin

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Anderson Valadares 2009-04-14 18:05:31 High consumns memory
Previous Message Tom Lane 2009-04-14 16:48:20 Re: Do the name of the WAL files matter?