Logging and summarizing squid usage

I need to create a monthly summary of the web usage of a particular IP through our proxy server.
We are using squid, but do not wish to log the entire month's usage for our entire customer base!
My current plan is to run tail -f /usr/local/squid/logs/access.log |grep <ip> >> /usr/local/squid/logs/access.ip.log
 constantly in the background and have a cron job that will take this log, and run calamari on it monthly to generate
the report. This does not seem too elegant, but with limited C and Perl knowledge, can anyone reccomend a better way?
apophisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jacekfCommented:
Maybe you should use tcpdump. For example
tcpdump ip src <ip_number> >> access.ip.log
0
LarsGCommented:
Tcpdump won't cut it unless you enjoy really large dumps of network traffic.

Many distributions come with log rotation. If you have a RedHat install, you'll have a file called /etc/logrotate.d/squid. If you have a different distribution, look through the crontab(s) and see if you can find a reference to logrotate.

Make a script that greps the log for the appropriate ip address and pipe the result to calamari. Then add the following lines to the squid logrotate configuration file (/etc/logrotate.d/squid or similar):

prerotate
  your_script
end

I don't have the man page for logrotate here at the moment, so I'm not 100% sure about the syntax.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.