Register
It is currently Fri Oct 24, 2014 3:18 pm

Script for Squid access.log file


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Mon Apr 07, 2014 8:19 pm   

Joined: Mon Apr 07, 2014 8:05 pm
Posts: 2
Hi Everyone.

I would like to kindly ask for your help. I need a script that gets daily information (6AM to 10PM) from squid's access.log file. What I usually do is run this "tail -f /var/log/squid/access.log | perl -p -e 's/^([0-9]*)/"[".localtime($1)."]"/e' ".

Any form of help will be greatly appreciated.

Thanks ! :)


Top
 Profile  
 PostPosted: Mon Apr 07, 2014 11:00 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 550
hi,

what's the problem with what you "usually do" ?

could we have a representative sample of squid log? and the corresponding desired output?


Top
 Profile  
 PostPosted: Tue Apr 08, 2014 12:04 am   

Joined: Mon Apr 07, 2014 8:05 pm
Posts: 2
hi watael,

tnx for the reply. the problem with what I usually do is I would have to look at it all day to which I can't because I have other tasks. I think if I have a script that generates a text file of the access.log from 6am to 10pm Daily, then I can check it over the weekend to see which sites were and who accessed it.

The sample output of the squid's access.log using tail -f /var/log/squid/access.log | perl -p -e 's/^([0-9]*)/"[".localtime($1)."]"/e'

[Tue Apr 8 14:00:12 2014].544 2000 192.168.1.132 TCP_MISS/200 1128 POST http://safebrowsing.clients.google.com/ ... /downloads? - DIRECT/74.125.235.206 application/vnd.google.safebrowsing-update
[Tue Apr 8 14:00:13 2014].187 597 192.168.1.132 TCP_CLIENT_REFRESH_MISS/200 6118 GET http://safebrowsing-cache.google.com/sa ... 8yBW8NAgAP - DIRECT/203.208.40.131 application/vnd.google.safebrowsing-chunk

Actually, I like the output the way it is, I just want a script that generates a text file with daily information for monitoring purposes.

Thanks! :)


Top
 Profile  
 PostPosted: Tue Apr 08, 2014 6:11 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 550
i'd rather program a cron task to execute your perl statement on the log file (say at 10:30), without `tail -f' which probably uselessly consume resources.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP