[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cobalt-users] Analog for site statistics - RaQ 3 - V1.1 :-)
- Subject: [cobalt-users] Analog for site statistics - RaQ 3 - V1.1 :-)
- From: "Michael Zimmermann" <zim@xxxxxxxx>
- Date: Sun Jul 16 23:38:10 2000
Hi all,
I mixed up where the old and the new binaries
are, so had to exchange /usr/local/sbin/analog
and /usr/local/bin/analog. The corrected version
follows.
Mike
==================================
Hi friends,
let me share how I do the web statistics using analog.
There might *well* be an error in this procedure
(the standard Cobalt-statistics might have gotten
broken on the way), please advice if you find it.
My goal was it to create site statistics automatically
with a cron job and put them into the web of each site.
======================================
Analog
-------
Analog is allready used for the normal statistics,
so i decided to have my own.
I got the sources for 4.11 from http://www.analog.cx
and compiled it out of the box.
The original analog was kept as it is (/usr/local/sbin/analog
using /etc/analog.cfg).
The new one is now in /usr/local/bin/analog
using the global config-file /usr/local/analog-4.11/analog.cfg.
When I start analog i also specify an additional individual
configfile to be added to the global one, but this is
described later.
General config-file: /usr/local/analog-4.11/analog.cfg
----------------------------------------------------
# Configuration file for analog 4.11
[...snip...]
LOGFILE ../../logs/web.log
OUTFILE index.html
# HOSTNAME "[my organisation]" <<< not set
DNSFILE /var/cache/analog.dns
DNS WRITE
[... and so on defining the standard reports I want in every site ...]
[... just use one of the standard examples ...]
======================================
Each site
---------
In each site, for which I want the reports to be generated
i create a sub-folder under the main web called 'log'
and place an individual 'analog.cfg' file there.
This is an indication for the procedures that an analog report
is to be generated for this website.
This 'log' directory is also going to receive the report-file
- which is named (guess) 'index.html', thus the final
report of each site can be seen in an browser at the url
http://sitename/log
To make it easy i also copied the complete 'images/'
subdirectory of the analog-distribution into the 'log' dir.
(I could have used some rewriting rules to a central
image-directory, but i'm lazy).
Of course the log is protected by an .htaccess file
with a separate .htpasswd- file in the websites
root directory (thus I avoid having to use the system
login + password).
Contents of /home/sites/sitename/web/log
.htaccess
analog.cfg
images/ >>> containing the analog report images
index.html <<< is generated by analog
.htaccess looks like
-------------------
# Access file
order allow,deny
allow from all
require valid-user
Authname Log-Report
> AuthPAM_Enabled off
Authtype Basic
> AuthUserFile /home/sites/sitename/.htpasswd
How to create the htpasswd-file?
Hint: http://webdevelopersjournal.com/articles/htpasswd.html
The individual analog.cfg file lookes like
----------------------------------------
HOSTNAME "sitename"
this is, it contains only the sitename, but may contain additional
reports (or switch some reports of) as the customer needs it.
I have not yet tried it out, but i think, all this stuff
can easily be included in the /etc/skel substructures,
so that it is set up automazically each time a new site
is created.
======================================
HOW TO RUN THE BEAST
Everything is set up in such a way, that you only
need
cd /home/sites/sitename/web/log
/usr/local/bin/analog +ganalog.cfg
Please observe, the global config file already
specified the input-log file as
LOGFILE ../../logs/web.log
(that's where 'split_logs' puts them)
And the +g switch tells analog to read the additional
analog.cfg file (from the current directory).
So I created a script <gee> called
/usr/local/sbin/create_analog_reports as follows
-------------------------------------
#! /bin/bash
for a in /home/sites/site*/web/log/analog.cfg;do (cd
${a%/analog.cfg};pwd;/usr/local/bin/analog +ganalog.cfg;)done
Hhhm. --- This script is going to be executed as root
that's the reason why i put it into /usr/local/sbin.
I'm getting old, it allways helps to help the brain.
Then i added this script to
/etc/cron.daily/logrotate which then looks like
------------------------
#!/bin/sh
/usr/sbin/logrotate /etc/logrotate.conf
/usr/local/sbin/create_analog_reports
Finally it's time to take care that the analog dns
cache is not going to eat up all my disk space.
Let logrotate do the job.
/etc/logrotate.d/analog
-----------------------
/var/cache/analog.dns {
missingok
rotate 1
compress
size 5M
postrotate
/usr/bin/tail -30000 /var/cache/analog.dns.1 >
/var/cache/analog.dns
endscript
}
The tail in the postrotate rule is keeping the
last (newest) 30.000 entries of the analog dns-cache.
Adjust size and count as appropriate for your
whole RaQ and depending on your dns-cache timeout
in the global analog.cfg (see analog docs).