Hostinfo functionality for AWStats geoipfree plugin // update script
On the web servers I administer, I'm using AWStats for web statistics. I switched from 'geoipfree' to the 'geoip' plugin (using Perl's Geo::IP library) in 2007 because the country database for the Geo::IPFree library was too heavily outdated. And therefore giving too many 'Unkown Country' results in statistics.
Three weeks ago I discovered that the opposite was true nowadays... so I switched to 'geoipfree' again (installing the libgeo-ipfree-perl package from Debian testing.) And after I'd done so... I discovered that geoipfree had no 'Hostinfo' functionality to show countries in the hostname list
Since I don't want functionality downgrades (and I like staring at statistics so much), I ported that functionality from geoip to geoipfree.
I put an issue in the sourceforge tracker -- but judging the length of the queue (and the Debian bug queue, for that matter), it will never be included anymore. So I'll place the 2 patches on my own site too, in case I lose track of them.
Awstats update script
Now I'm busy anyway... let's post the latest revision of my update script here too, on the chance that someone finds it interesting. (I've never posted it anywhere and won't try to add it to the distribution, because there are so many already.)
It runs 'awstats.pl -update' for all configuration files in a directory - and as such is a replacement for the 'awstats_updateall.pl' scipt which is included in the official examples. It is meant to be run both from cron (very regularly) and just after logfile rotation. The last thing makes sure 'the last lines in a logfile' are always indexed. The script has some options added which enable one type of process to wait for the other (or back off) if necessary.
You can find how that works, in the below example configuration snippets from my system, combined with the script itself. These snippets assume the file is named 'awstats', not 'awstats.sh'.
/etc/cron.d/awstats:
3,13,23,33,43,53 * * * * www-data /usr/local/sbin/awstats-update -x logrotate -d >> /var/log/www/awstats-update.log
/etc/logrotate.d/nginx (the important directives - oh and this should be easily adjustable for apache):
(...) sharedscripts delaycompress prerotate /usr/local/sbin/awstats-update -w 3 -x endscript postrotate [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid` /bin/su -p -c '/usr/local/sbin/awstats-update -d -w 10 __LOGFILE__.1 >> /var/log/www/awstats-update.log' www-data endscript } # The postrotate/endscript assumes that ALL logfiles have been rotated, # because it processes ALL 'file.log.1' again. I guess it is the case for 'daily'. # The '-w' in the postrotate should be totally unnecessary, because the '-w' in the # prerotate script and the '-x logrotate' in /etc/cron.d/awstats make sure no # update runs during logrotate
Attachment | Size |
---|---|
geoipfree.pm_.patch | 2.75 KB |
awstats.pl_.patch | 431 bytes |
awstats-update.sh | 4.63 KB |
Recent comments
9 years 35 weeks ago
9 years 35 weeks ago
16 years 45 weeks ago
16 years 45 weeks ago
16 years 45 weeks ago