Performance Tuning: Running Squid Graph on a Schedule
If you run Squid Graph on a Schedule, for example, daily, it is a good idea to cycle your logfiles. It does take Squid Graph some time to skip unnecessary lines in your log files so it is a good idea to schedule a cycle on your log files approximately a minute before Squid Graph runs to save your CPU and I/O time.
Performance Tuning: Old Logfiles
If your log files are more than a week old, it's really not a good idea to run Squid Graph on it. You might want to try the previous option of cycling the log file, but if your log is only 5mb huge it doesn't make sense either.
What you can do is to estimate the number of lines are generated in a day. How do you do this?
First, we do a wc -l
on the log file to see how many lines there are in
your log file.
$ wc -l access.log 109246 access.logTaking for example the log is a week old, we divide 109246 by 7 days, which gives us 15606 lines.
$ expr 109246 15606What we'd usually do is to over-estimate this by about 10 percent, so we'd just multiply that number by 1.1. expr can't take decimals, so let's try multiplying by 11 instead, then we divide the answer by 10.
$ expr 15606 \* 11 171666So, here we have it! 17166 lines. What do we do next? We simply pass the last 17166 lines into Squid by using the
tail
command.
$ tail -n 17166 access.log | ./squid-graph -o=/var/www/html/reports
Tricks: Monitoring Accesses to a Specific URL
Let's say for example you want to find out how the access patterns are for
the site microsoft.com
, simply do this
$ cat access.log | grep microsoft.com | ./squid-graph -o=/var/w...What about a specific URL?
$ cat access.log | grep "http://www.microsoft.com/windows " | ./squid-graph ...Or a specific type of file?
$ cat access.log | grep ".mp3 " | ./squid-graph -o=/var/ww...
Tricks: Monitoring Accesses of a Specific User
If you want to find out how much bandwidth a particular workstation in your office is utilizing, simply try this:
$ cat access.log | grep "192.168.0.213 " | ./squid-graph -o=/var/ww...
Tricks: Automating use of Old Logfiles
If you had a log file that's a day old, what you'd usually do is to
use the --start
option to get Squid Graph to analyze it at the correct
time frame, like this:
$ head access.log 991353612.900 113 50.238.1.113 TCP_HIT/200 3102 GET http://www... - NONE/- image/gif $ ./squid-graph --start=991353612 --output-dir=/var/www/html < access.log ...Well, that's a _little_ tedious. Here's a short-cut.
$ ./squid-graph -s=`head -n1 access.log | cut -f1 -d' '` -o=/var/www/html < access.log
Tricks: Logging to a Log File
If you would rather write the console logs to a log file, simply appened a >> logfile
at the
end of your whole statement.
$ ./squid-graph --output-dir=/var/www/html < access.log >> squid-graph.log
Enjoy!
![]() |
(c) 2001, SecurLogic <squid-graph@securlogic.com>
http://squid-graph.securlogic.com/ |