#!/bin/sh # Name: mybin/apache/from-iserver Author: js-cgi@inwap.com 06-Feb-2002 # Purpose: Pull Apache logs from a Verio iServer # Normally produces no output. Use "sum-log -v" for verbose mode. # Server access logs expected in www/logs/access_log and www/logs/access_log*gz # Server error logs expected in www/logs/error_log and www/logs/error_log*gz # Programs used: (see http://www.inwap.com/mybin/ for sources) # mv-web-logs Moves compressed log files, runs logresolve on access_log # rm-same Delete files on web server if MD5 checksums match # # Files used: # access_log access_log.?.gz Apache logs (without DNS lookups) # error_log error_log.?.gz Apache error log # $LOGDIR/yyyy/mmdd-acc.gz Archived access logs (with names for IP addrs) LOGDIR=$HOME/weblogs # Where to put the results BINDIR=$HOME/mybin # Parent of dirs of other progs PATH=$BINDIR/miscunix:$BINDIR/apache:$PATH start=`date +%T` if [ x$1 = x-v ]; then v=-v ; shift # Use -v for verbose mode fi WEBSERVER=$1 if [ $WEBSERVER: = : ]; then cat <&2 Usage: $0 [-v] www.iserver.com This script uses rsync and ssh to fetch www/logs from a Verio iServer. Use the -v option for verbose mode. EOM exit 1; fi [ x$v = x-v ] && set -v # Pull updated files from the web server # Fetch ftp/anon/incoming, users/*/mail, www/logs/*log, www/htdocs/*.count cd $HOME rsync -e ssh -au $v $WEBSERVER:'{bin,www}' . | egrep -v '/$' # Remove old log files after verifying checksums rm-same $WEBSERVER www/logs/access_log.?.gz www/logs/error_log.?.gz # Do DNS lookups via logresolve, save logs into a yearly subdirectory start2=`date +%T` mv-web-logs $v www/logs/access_log.?.gz www/logs/error_log.?.gz $LOGDIR if [ x$v = x-v ]; then du $LOGDIR/20[0-9][0-9] # Disk usage by year echo "Times: $start, $start2," `date +%T` fi # End of mybin/apache/from-iserver