Tuesday, January 25, 2011

Squid access.log export to excel

Is there a way to export the contents of access.log to excel spreadsheet so as to manipulate the data from there?

  • Easy enough with Perl, which has modules for working with Excel, but wouldn't a database be a more appropriate tool? Excel really seems like the wrong tool for this job. Sort of like using a lawnmower to pick flowers. Sure it will work but there are better ways.

    Farseeker : Best. Analogy. Ever.
  • Yeah, Excel can read CSV files, so your best bet would be to alter the log format such that it's comma separated (or perhaps some other delineation token). You can then open your CSV-formatted Squid log using Excel.

    See: http://wiki.squid-cache.org/Features/LogFormat

    Alternatively, if you don't care to alter the format, you can toss a script together to reformat to include the fields you need.

    From McJeff
  • The squid native log format is :

    time elapsed remotehost code/status bytes method URL rfc931 peerstatus/peerhost type

    In the fact, you can develop a simple parser using awk or maybe with perl or python, ... and delimit the data with a delimiter of your choice to get a CSV file. Somethink like this:

     awk '{ print $1","$2","$3","$4","$5","$6","$7","$8","$9","10 }' /var/log/squid/access.log
    
    For more information, please find here a small squid log viewer using python. http://github.com/mezgani/sqview

    From mezgani

0 comments:

Post a Comment