#!/bin/awk # rsync_log_massage.awk # Twiddle the rsync log format to make it work for the webalizer. # # The webalizer (www.webalizer.org) analyzes logs and puts the results # onto a page. It asserts that it supports common log format. To get # it to like the output of my rsync I did the following. # (1) I made my rsync.conf have these lines: # log file = /var/log/rsyncd # log format = %a - - [%t] "GET %f" - %l "" "" # (The extra quotes arise from the webalizer README file which says # The Webalizer supports CLF log formats, which should work for just # about everyone. If you want User Agent or Referrer information, you # need to make sure your web server supplies this information in it's # log file, and in a format that the Webalizer can understand. While # The Webalizer will try to handle many of the subtle variations in # log formats, some will not work at all. Most web servers output # CLF format logs by default. For Apache, in order to produce the # proper log format, add the following to the httpd.conf file: # # LogFormat "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"" # # This instructs the Apache web server to produce a 'combined' log # that includes the referrer and user agent information on the end of # each record, enclosed in quotes (This is the standard recommended # by both Apache and NCSA). # . I couldn't get webalizer to shut up about `truncating the long referrer # field' otherwise.) # (2) I installed this awk script to run after the logs are rotated. # (3) I set webalizer to run weekly on the post-massaged log file. # # 2002-Mar-01 Jim Hefferon ftpmaint@tug.ctan.org # BEGIN {months[1]="Jan" months[2]="Feb" months[3]="Mar" months[4]="Apr" months[5]="May" months[6]="Jun" months[7]="Jul" months[8]="Aug" months[9]="Sep" months[10]="Oct" months[11]="Nov" months[12]="Dec"} $6~/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ { year=substr($9,2,4); month=substr($9,7,2); day=substr($9,10,2); hour=substr($10,1,2); mins=substr($10,4,2); secs=substr($10,7,2); mon=months[month+0]; for (i=6; i<=8; i++) printf("%s ",$i); printf(" [%s/%s/%s:%s:%s:%s +0000] ",day,mon,year,hour,mins,secs); printf("") for (i=11; i<=NF; i++) printf("%s ",$i); printf("\n") }