Loading ...
Sorry, an error occurred while loading the content.
 

sorting log files

Expand Messages
  • DAN-BOUZOUA ALI
    I found in the faq below how to sort log file. I want to use the shell script below but i don t know how to pass the log file an have it sorted. Thank for your
    Message 1 of 1 , Apr 18, 2002
      I found in the faq below how to sort log file.
      I want to use the shell script below but i don't know how to pass the log
      file an have it sorted.
      Thank for your help.



      http://www.mrunix.net/webalizer/faq.html
      16. How can I process multiple logs from a server farm?
      Q: I have multiple load-balanced servers (or I'm using DNS round-robin to
      accoplish the same thing) and I want to generate one webalizer report for
      the whole farm, but each server generates its own log file. When I run
      webalizer on each of the logfiles in turn, it ignores a lot of the records
      because it thinks they're out of order!
      A: You need to merge all of the logfiles together so that webalizer sees the
      records in chronological order. One good way to do that on the fly is with
      mergelog ( http://mergelog.sourceforge.net/) , a quick common logfile
      sorter. An example:

      mergelog .log .log .log | webalizer

      Another method is to simply combine your logs and then sort them into
      chronological order. Here is a simple shell script that uses the GNU sort
      utility to sort an already combined log file:



      #!/bin/sh
      if [ ! -f $1 ]; then
      echo "Usage: $0 "
      exit
      fi
      echo "Sorting $1"
      sort -t ' ' -k 4.9,4.12n -k 4.5,4.7M -k 4.2,4.3n -k 4.14,4.15n -k 4.17,4.18n
      -k 4.20,4.21n $1 > $1.sorted



      _________________________________________________________________
      Chat with friends online, try MSN Messenger: http://messenger.msn.com
    Your message has been successfully submitted and would be delivered to recipients shortly.