CVS User Account cvsuser
Fri May 19 13:43:50 PDT 2006
Log Message:
-----------
Added two scripts to help analyze the states of sets of Slony-I clusters.

With documentation...

Modified Files:
--------------
    slony1-engine/doc/adminguide:
        adminscripts.sgml (r1.32 -> r1.33)

Added Files:
-----------
    slony1-engine/tools:
        slony-cluster-analysis-mass.sh (r1.1)
        slony-cluster-analysis.sh (r1.1)

-------------- next part --------------
--- /dev/null
+++ tools/slony-cluster-analysis.sh
@@ -0,0 +1,40 @@
+#!/usr/bin/sh
+# $Id: slony-cluster-analysis.sh,v 1.1 2006/05/19 20:43:48 cbbrowne Exp $
+# Analyze Slony-I Configuration
+
+# This script pulls some overall configuration from a Slony-I cluster
+# and stows it in /opt/log/Slony-I/Configuration, doing a compare from
+# run to run to see if there have been changes.  If the set of nodes,
+# paths, sets, or tables changes, then an email will be sent to the
+# DBA user.
+
+# Requires some combination of PGDATA/PGHOST/PGPORT/... set up to
+# connect to a database
+
+CLUSTER=$1
+LOGDIR=/opt/logs/Slony-I/Configuration
+mkdir -p $LOGDIR
+TFILE=/tmp/temp_slony_state.${CLUSTER}.$$
+LASTSTATE=${LOGDIR}/${CLUSTER}.last
+RECIPIENT="cbbrowne at example.info"
+
+Q1="select no_id as \"node_id\", no_comment as \"node_description\" from \"_${CLUSTER}\".sl_node order by no_id; "
+Q2="select pa_server, pa_client, pa_conninfo from \"_${CLUSTER}\".sl_path order by pa_server, pa_client; "
+Q3="select set_id, set_origin, set_comment from \"_${CLUSTER}\".sl_set order by set_id; "
+Q4="select tab_id, tab_set, tab_nspname, tab_relname, tab_comment from \"_${CLUSTER}\".sl_table order by tab_id;"
+
+psql -c "$Q1" > $TFILE
+psql -c "$Q2" >> $TFILE
+psql -c "$Q3" >> $TFILE
+psql -c "$Q4" >> $TFILE
+
+if ( /usr/bin/cmp -s $TFILE $LASTSTATE ) ; then
+   # Do nothing
+   DO=0   # Non-Bash shells need a statement here...
+else
+    diff -c $LASTSTATE $TFILE | mail -s "Configuration changed for Slony-I cluster ${CLUSTER}" $RECIPIENT
+    TODAY=`date +"%Y-%m-%d"`
+    cp $LASTSTATE ${LOGDIR}/${CLUSTER}.changed_from_at.${TODAY}
+fi
+
+mv $TFILE $LASTSTATE
--- /dev/null
+++ tools/slony-cluster-analysis-mass.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/sh
+# $Id: slony-cluster-analysis-mass.sh,v 1.1 2006/05/19 20:43:48 cbbrowne Exp $
+# Do cluster analyses
+
+CLSCRHOME=/opt/dbs/scripts
+PGPORT=5433 PGHOST=hacluster-logdbs PGDATABASE=app1logs  PGUSER=slony ${CLSCRHOME}/slony-cluster-analysis.sh app1logs
+PGPORT=5433 PGHOST=hacluster-logdbs PGDATABASE=ap2logs   PGUSER=slony ${CLSCRHOME}/slony-cluster-analysis.sh ap2logs
+PGPORT=5433 PGHOST=hacluster-logdbs PGDATABASE=app3logs  PGUSER=slony ${CLSCRHOME}/slony-cluster-analysis.sh app3logs
+PGPORT=5432 PGHOST=hacluster-app1   PGDATABASE=sappapp1  PGUSER=slony ${CLSCRHOME}/slony-cluster-analysis.sh sappapp1
+PGPORT=5435 PGHOST=hacluster-app4   PGDATABASE=sappapp4  PGUSER=slony ${CLSCRHOME}/slony-cluster-analysis.sh app4
+PGPORT=5532 PGHOST=hacluster-ap2    PGDATABASE=sappap2   PGUSER=slony ${CLSCRHOME}/slony-cluster-analysis.sh sappap2
+PGPORT=5416 PGHOST=hacluster-app3   PGDATABASE=sappapp3  PGUSER=slony ${CLSCRHOME}/slony-cluster-analysis.sh sappapp3
+PGPORT=5747 PGHOST=hacluster-app5   PGDATABASE=sappapp5  PGUSER=slony ${CLSCRHOME}/slony-cluster-analysis.sh sappapp5
Index: adminscripts.sgml
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/doc/adminguide/adminscripts.sgml,v
retrieving revision 1.32
retrieving revision 1.33
diff -Ldoc/adminguide/adminscripts.sgml -Ldoc/adminguide/adminscripts.sgml -u -w -r1.32 -r1.33
--- doc/adminguide/adminscripts.sgml
+++ doc/adminguide/adminscripts.sgml
@@ -374,6 +374,46 @@
 <para> In effect, you could run this every five minutes, and it would
 launch any missing &lslon; processes. </para>
 
+<sect2><title> slony-cluster-analysis </title>
+
+<para> If you are running a lot of replicated databases, where there
+are numerous &slony1; clusters, it can get painful to track and
+document this.  The following tools may be of some assistance in this.</para>
+
+<para> <application>slony-cluster-analysis.sh</application> is a shell
+script intended to provide some over-time analysis of the
+configuration of a &slony1; cluster.  You pass in the usual
+<application>libpq</application> environment variables
+(<envar>PGHOST</envar>, <envar>PGPORT</envar>,
+<envar>PGDATABASE</envar>, and such) to connect to a member of a
+&slony1; cluster, and pass the name of the cluster as an argument.</para>
+
+<para> The script then does the following:</para>
+<itemizedlist>
+<listitem><para> Runs a series of queries against the &slony1; tables to get lists of nodes, paths, sets, and tables. </para> </listitem>
+<listitem><para> This is stowed in a temporary file in <filename>/tmp</filename> </para> </listitem>
+<listitem><para> A comparison is done between the present configuration and the configuration the last time the tool was run.  If the configuration differs, an email of the difference (generated using <application>diff</application>) is sent to a configurable email address. </para> </listitem>
+<listitem><para> If the configuration has changed, the old configuration file is renamed to indicate when the script noticed the change. </para></listitem>
+<listitem><para> Ultimately, the current configuration is stowed in <envar>LOGDIR</envar> in a filename like <filename>cluster.last </filename> </para> </listitem>
+</itemizedlist>
+
+<para> There is a sample <quote>wrapper</quote> script,
+<filename>slony-cluster-analysis-mass.sh</filename>, which sets things
+up to point to a whole bunch of &slony1; clusters.</para>
+
+<para> This should make it easier for a group of DBAs to keep track of
+two things: </para>
+
+<itemizedlist>
+
+<listitem><para> Documenting the current state of system
+configuration.  </para></listitem>
+
+<listitem><para> Noticing when configuration
+changes. </para></listitem>
+</itemizedlist>
+
+</sect2>
 </sect1>
 <!-- Keep this comment at the end of the file
 Local variables:



More information about the Slony1-commit mailing list