Squid Proxy – Converting Log File Date/Time

The time in the logfiles in for squid are impossible to figure out. They are in epoch time. To convert the times in the log to an understandable format you can use a script. I found this on the squid users mailing list…

http://www.squid-cache.org/mail-archive/squid-users/200608/0043.html

Save the two lines in that message to a file somewhere and make it executable…

#!/bin/sh
perl -p -e 's/^([0-9]*)/"[".localtime($1)."]"/e'

Then make it executable…

chmod 755 squidtime.sh

First you should get the information that you are looking for in a squid log into a file like this…

cat /var/log/squid/access.log | grep -i "whatIamLookingFor" >whatIamLookingFor.log

Then…

cat whatIamLookingFor.log | perl squidtime.sh >Reformatted.log
Advertisements

About Craig Szymanski

Systems Administrator Photography Enthusiast
This entry was posted in Linux, Network Administration, Squid Proxy. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s