My ongoing experiences with Ubuntu, and later Mythbuntu, as a media center with MythTV. I'm also using the system for a virtual machine server, a mediawiki server and a general all around home infrastructure base.

Sunday, February 1, 2009

apt-cacher report not updating

Update Mar 13, 2009: I've now fixed apt-cacher-report.pl

I noticed this morning the amounts of hits and data transferred in my apt-cacher report are not updating. See report below, the date has changed but the values in the 'cache efficiency' table have not since my original install. Something is broken some where, either I'm not using the cache or it's not reporting correctly.

Don't have time at this moment to investigate, but will update this post when I do...

Updated: I started by killing apt-cacher to verify the clients were using it...
# /etc/init.d/apt-cacher stop
Stopping Apt-Cacher: apt-cacher.
And, yes, this caused 'apt-get update' on my client to return all sorts of 'Count not connect...' errors, so I know my previous configuration was working:
# cat /etc/apt/apt.conf.d/90local-proxy
Acquire::http::Proxy "http://proxy-host:3142";

So I restarted apt-cacher ("/etc/init.d/apt-cacher start") and looked at the server side harder.

First, I checked to see if there was anything in the cache, and there was lots of stuff including new packages as of today, including wine, which is only on one of my clients and not the server, which would seem to indicate things are working as I should expect:
# grep cache_dir /etc/apt-cacher/apt-cacher.conf
# cache_dir is used to set the location of the local cache. This can
cache_dir=/var/cache/apt-cacher

# du -s /var/cache/apt-cacher
1966256 /var/cache/apt-cacher
# ls -lt /var/cache/apt-cacher/packages | head -3
total 1947272
-rw-r--r-- 2 www-data www-data 0 2009-02-01 09:05 wine.budgetdedicated.com_apt_dists_intrepid_main_binary-i386_Packages.gz
-rw-r--r-- 2 www-data www-data 0 2009-02-01 09:03 wine.budgetdedicated.com_apt_dists_intrepid_Release

Ok, the issue would seem to be reporting. I checked relevant options in apt-cacher.conf and didn't see any issue.

# grep generate_reports /etc/apt-cacher/apt-cacher.conf
generate_reports=1
So I started looking a little harder at the apt-cacher logs and the /usr/share/apt-cacher/apt-cacher-report.pl script that generates the reports, and noticed a problem. Here's what a line in my logfile looks like:

# head -1 /var/log/apt-cacher/access.log
Sun Feb 1 08:22:01 2009|15927|192.168.1.125|MISS||ppa.launchpad.net_network-manager_ubuntu_dists_intrepid_Release.gpg

And here is the section of the apt-cacher/apt-cacher-report.pl script that parses it:

$req_date = $line[0];
# $req_ip = $line[1];
$req_result = $line[2];
$req_bytes = 0;
$req_bytes = $line[3] if $line[3] =~ /^[0-9]+$/;
# $req_object = $line[4];

If you don't understand PERl, basically there is a mismatch. The script is looking for the result (HIT or MISS) in the third column (column 2 starting from 0), but the IP address is there. It expects the number of bytes in column 4, but they are in column 2. So this would seem to be the problem, but why this discrepancy?

Update: See a later post for the fix.


Current apt-cacher report output (made narrow to fit into blow):


summary

Item Value
Report generated 2009-02-01 09:02:18
Administrator root@localhost
First request Thu Oct 30 22:01:39 2008
Last request Sun Feb 1 08:22:05 2009
Total requests 27678
Total traffic 1980.17 MB

cache efficiency


Cache hitsCache missesTotal
Requests 2569 (9.28%)25109 (90.71%)27678
Transfers 955.718 MB (48.26%)1024.452 MB (51.73%)1980.17 MB

Post a Comment