Thu Nov 16 11:01:58 PST 2006
- Previous message: [Slony1-commit] By cbbrowne: More notes to explain the implications of upgrading from
- Next message: [Slony1-commit] By cbbrowne: Add a new tool script, search-logs.sh, which may be used to
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Log Message: ----------- Add a new tool script, search-logs.sh, which may be used to do an hourly search for error messages in slon logs. Includes admin guide documentation... Modified Files: -------------- slony1-engine/doc/adminguide: monitoring.sgml (r1.30 -> r1.31) adminscripts.sgml (r1.41 -> r1.42) Added Files: ----------- slony1-engine/tools: search-logs.sh (r1.1) -------------- next part -------------- Index: adminscripts.sgml =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/doc/adminguide/adminscripts.sgml,v retrieving revision 1.41 retrieving revision 1.42 diff -Ldoc/adminguide/adminscripts.sgml -Ldoc/adminguide/adminscripts.sgml -u -w -r1.41 -r1.42 --- doc/adminguide/adminscripts.sgml +++ doc/adminguide/adminscripts.sgml @@ -226,7 +226,7 @@ <para>This starts a slon daemon for the specified cluster and node, and uses slon_watchdog to keep it running.</para> </sect3> -<sect3><title>slon_watchdog</title> +<sect3 id="slonwatchdog"><title>slon_watchdog</title> <para>Used by <command>slon_start</command>.</para> Index: monitoring.sgml =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/doc/adminguide/monitoring.sgml,v retrieving revision 1.30 retrieving revision 1.31 diff -Ldoc/adminguide/monitoring.sgml -Ldoc/adminguide/monitoring.sgml -u -w -r1.30 -r1.31 --- doc/adminguide/monitoring.sgml +++ doc/adminguide/monitoring.sgml @@ -159,6 +159,23 @@ </sect2> +<sect2 id="search-logs"> <title> <command>search-logs.sh</command> </title> + +<para> This script is constructed to search for &slony1; log files at +a given path (<envar>LOGHOME</envar>), based both on the naming +conventions used by the <xref linkend="launchclusters"> and <xref +linkend="slonwatchdog"> systems used for launching &lslon; processes. + +<para> Errors, if found, are listed, by log file, and emailed to the +specified user (<ENVAR>LOGRECIPIENT</ENVAR>); if no email address is +specified, output goes to standard output. </para> + +<para> <ENVAR>LOGTIMESTAMP</envar> allows overriding what hour to +evaluate (rather than the last hour). </para> + +<para> An administrator might run this script once an hour to monitor +for replication problems. </para> + </sect1> <!-- Keep this comment at the end of the file Local variables: --- /dev/null +++ tools/search-logs.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# $Id: search-logs.sh,v 1.1 2006/11/16 19:01:56 cbbrowne Exp $ + +# Search logs for errors from the last hour +LOGHOME=${LOGHOME:-"/opt/logs"} # Directory to search +LOGRECIPIENT=${LOGRECIPIENT:-""} # Email recipient - if not set, use STDOUT +LOGTIMESTAMP=${LOGTIMESTAMP:-""} # Override time - format should be "YYYY-MM-DD HH" + +if [[ -z $LOGTIMESTAMP ]] ; then + HRRE=`date -d "1 hour ago" +"%Y-%m-%d %H:[0-9][0-9]:[0-9][0-9] ${TZ}"` +else + HRRE="${LOGTIMESTAMP}:[0-9][0-9]:[0-9][0-9] ${TZ}" +fi + +for log in `find ${LOGHOME} -name "*.log" -mmin -60 | egrep "/node[0-9]+/[^/]+.log"` ; do + egrep "${HRRE} (ERROR|FATAL)" $log > /tmp/slony-errors.$$ + if [[ -s /tmp/slony-errors.$$ ]] ; then + echo " +Errors in log ${log} +===============================================================" >> /tmp/slony-summary.$$ + cat /tmp/slony-errors.$$ >> /tmp/slony-summary.$$ + fi +done + +if [[ -s /tmp/slony-summary.$$ ]] ; then + if [[ -z $LOGRECIPIENT ]] ; then + echo "Errors found!" + cat /tmp/slony-summary.$$ + else + mail -s "Slony-I log errors for ${HRRE}" ${LOGRECIPIENT} < /tmp/slony-summary.$$ + fi +fi +rm -f /tmp/slony-errors.$$ /tmp/slony-summary.$$
- Previous message: [Slony1-commit] By cbbrowne: More notes to explain the implications of upgrading from
- Next message: [Slony1-commit] By cbbrowne: Add a new tool script, search-logs.sh, which may be used to
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list