Some minor scripts that may be useful.

From: Neil Murray <>
Date: Thu, 29 Jan 1998 21:47:21 +1100

        Its a bit late now but below is a script that walks through the squid
log file and reports the average object size. The awk line comes from someone
else on the squid list who I cannot remember. I think the rest of the script
is my invention but if not will the author(s) email me please.

        For interest the average I got was avg_object_size: 12767.8 bytes.
When I last ran this, around Jan 1997, the average size was just under
20Kbytes (1987?.? from memory).

        If this is of use, it could be included in the contrib directory
of squid or on the analysis scripts web page.

        The second script is quite handy. While I have cachemgr.cgi set up
often I just want to check on something quickly and my browser window is
showing something that I dont want to change at the moment. I use to manually
type in (on my proxy) 'client -p <port> cache_object://a/info | less'.
This was tiring so I made a small script as a wrapper around it.

        If it is run without an argument you get the following;

proxy. examine
 To extract information from squid

info server_list
client_list parameter
stats/ipcache stats/vm_objects
stats/dns stats/redirector
stats/utilization stats/io
stats/reply_headers stats/filedescriptors


        To use try 'examine info'

{Squid Object Cache: Version 1.1.10+2}
{Start Time: Fri, 23 Jan 1998 06:15:57 GMT}
{Current Time: Thu, 29 Jan 1998 10:21:43 GMT}
{Connection information for squid:}
{ Number of TCP connections: 6622467}
{ Number of UDP connections: 5382423}
{ Connections per hour: 81061.5}
{ Select loop called: 60348257 times, 8.834 ms avg}
{Cache information for squid:}

        Note some of the possible requests arenot useful. Try 'examine
stats/utilization' to see what I mean. Some can load your proxy noticably
stats/objects which I deliberately left out of the list (it can be immense).

        Personally I find the 'info', 'stats/filedescriptors', 'server_list'
to be the most useful.

        I have given this script to non-technical people and to mostly NT shops
where the one Unix box in the place is running squid (you try running
cachemgr.cgi under NT). This seems to satisfy them.

        I have a variant version that I keep on my main login machine that
includes the '-h' addition so I can do an examine
remotely. Of course this implies that your ACL rules allow this.

        Wishlist time:
                Could some NT programming whiz take the cachemgr.cgi source and
bang it into shape so it runs on an NT web server please. Its doable but I
dont have the prerequisite NT skills. If you achieve it, send me a copy


# the squid configuration file - change it to your settings

# find the swap log file
LOGFILE=`cat $CONF | grep "^cache_swap_log" | cut -d' ' -f2`

# if it is not set then the swap log resides in the first cache_dir entry
if [ "${LOGFILE}" = "" ]; then
        CACHEDIR=`cat $CONF | grep "^cache_dir" | cut -d' ' -f2 | head -1`

# do the calculation
awk ' BEGIN { a=0; } { a=a+$5 } END { print "avg_object_size:",a/NR, "bytes" } ' $LOGFILE

        examine (or squidexamine if you prefer)

# Examine
# Crude but it will serve. Retrieve information from squid.
CLIENT="/usr/local/bin/client -p 80 cache_object://a"
if [ $# -eq 1 ] ; then
        ${CLIENT}/$1 | $PAGER
        echo " To extract information from squid"
        echo ""
        echo "info server_list"
        echo "client_list parameter"
        echo "stats/ipcache stats/vm_objects"
        echo "stats/dns stats/redirector"
        echo "stats/utilization stats/io"
        echo "stats/reply_headers stats/filedescriptors"
        echo ""


Neil Murray                              Email:
Access One Pty. Ltd.           
41 Malcolm Rd., Braeside                 Phone:  +61 3 9239 1444
Victoria, Australia  3195                Fax:    +61 3 9587 3954
Received on Thu Jan 29 1998 - 02:55:14 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:38:34 MST