Pg_autovacuum script. - Mailing list pgsql-admin

From Theo Galanakis
Subject Pg_autovacuum script.
Date
Msg-id D1444817B78AB546BF2896C2B70E7F04371FED@ganesh.au.lpint.net
Whole thread Raw
Responses Re: Pg_autovacuum script.
Re: Pg_autovacuum script.
List pgsql-admin

Since I could not locate anything similar on the net, I have written a script to automatically start and stop the autovacuum daemon. This should be added to the existing postgresql script.

Please let me know if you can see any shortcomings. I have taken into consideration that more than one postmaster may be running on the same machine, so I have stored the pg_autovacuum pid into a file, which is referenced when bringing down the postmaster instance. I have not gone to the effort of including all the pg_autovacuum parameters, you can add them at will.

One issue I can foresee is maintainability, where you will have to update the postgresql script file with the snippets below, every postgres upgrade.

Here are the snippets :

This goes where all the other init scripts are located.
# Initialize pg_autovacuum defaults. Theo Galanakis 11/04/2005
PGAUTO_LOGFILE=/var/lib/pg_autovacuum.log
PGAUTO_SLEEP=60

Added to the end of the Start function.
 # Start pg_autovacuum. Theo Galanakis 11/05/2005
        PAUTO_START=$"Starting pg_autovacuum service: "
        echo -n "$PAUTO_START"
        pg_autovacuum -D -s ${PGAUTO_SLEEP} -p ${PGPORT} -U postgres -L ${PGAUTO_LOGFILE}
        pg_autovacuum_pid=`pidof -s $PGENGINE/pg_autovacuum`
        if [ $pg_autovacuum_pid ]
        then
           success "$PAUTO_START"
           echo $pg_autovacuum_pid > /var/run/pg_autovacuum.${PGPORT}.pid
           echo
        else
           failure "$PAUTO_START"
           echo
        fi

Added to the end of the Stop function.
# Stop pg_autovaccum. Theo Galanakis 11/04/2005
        echo -n $"Stopping pg_autovacuum service: "
        pg_autovacuum_pid=`head -n 1 /var/run/pg_autovacuum.${PGPORT}.pid`
        kill -TERM $pg_autovacuum_pid
        ret=`ps --no-heading ${pg_autovacuum_pid}`
        if [ -z "$ret" ]
        then
                echo_success
        else
                echo_failure
        fi
        echo
        rm -f /var/run/pg_autovacuum.${PGPORT}.pid

______________________________________________________________________
This email, including attachments, is intended only for the addressee
and may be confidential, privileged and subject to copyright. If you
have received this email in error, please advise the sender and delete
it. If you are not the intended recipient of this email, you must not
use, copy or disclose its content to anyone. You must not copy or
communicate to others content that is confidential or subject to
copyright, unless you have the consent of the content owner.

pgsql-admin by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: Problems recovering sequences from a backup done with pg_dump
Next
From: Bruce Momjian
Date:
Subject: Re: Automatically updating pg_hba.conf