Mrz 30

Auswertung von Logfiles mit awstats

Tag: Allgemeinadmin @ 16:56

AWStats ist ein Logfile-Analyzer der in perl geschrieben ist und einige Auswertungen hat.
- Besuche
- unterschiedliche Besucher
- Seiten, Zugriffe (Hits)
- Transfervolumen
- Jahresübersicht
- Monatsübersicht
- Wochentage
- Tageszeit
- Domains/Länder
- Rechner
- Robots/Spider
- Aufenthaltsdauer
- Dateitypen
- Seiten (URL)
- Betriebssysteme
- Browser
- Referrer
- Suchmaschinen
- Suchbegriffe
- HTTP-Fehlercodes
Es ist vor allem zur Echtzeitanalyse gedacht, aber bietet auch die Möglichkeit, statische HTML Seiten zu erzeugen. Genau das habe ich vor und daher (und weil es Open Source ist) habe ich mich für awstats entschieden.
Ich lade mir also das RPM Paket herunter und installiere es wie folgt.
rpm -i awstats-6.95-1.noarch.rpm
—– AWStats 6.95 - Laurent Destailleur —–
AWStats files have been installed in /usr/local/awstats
If first install, follow instructions in documentation
(/usr/local/awstats/docs/index.html) to setup AWStats in 3 steps:
Step 1 : Install and Setup with awstats_configure.pl (or manually)
Step 2 : Build/Update Statistics with awstats.pl
Step 3 : Read Statistics
Setup:
1. /usr/local/awstats/tools/awstats_configure.pl

—– AWStats awstats_configure 1.0 (build 1.8) (c) Laurent Destailleur —–
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to ‘understand’ all possible ways to use AWStats…
Read the AWStats documentation (docs/index.html).

—–> Running OS detected: Linux, BSD or Unix
Warning: AWStats standard directory on Linux OS is ‘/usr/local/awstats’.
If you want to use standard directory, you should first move all content
of AWStats distribution from current directory:
/root
to standard directory:
/usr/local/awstats
And then, run configure.pl from this location.
Do you want to continue setup from this NON standard directory [yN] ?

cd /usr/local/awstats

./tools/awstats_configure.pl

—– AWStats awstats_configure 1.0 (build 1.8) (c) Laurent Destailleur —–
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to ‘understand’ all possible ways to use AWStats…
Read the AWStats documentation (docs/index.html).

—–> Running OS detected: Linux, BSD or Unix

—–> Check for web server install

Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path (’none’ to skip web server setup):

> /opt/lampp/etc/httpd.conf

—–> Check and complete web server config file ‘/opt/lampp/etc/httpd.conf’
Warning: You Apache config file contains directives to write ‘common’ log files
This means that some features can’t work (os, browsers and keywords detection).
Do you want me to setup Apache to write ‘combined’ log files [y/N] ? N
Add ‘Alias /awstatsclasses “/usr/local/awstats/wwwroot/classes/”‘
Add ‘Alias /awstatscss “/usr/local/awstats/wwwroot/css/”‘
Add ‘Alias /awstatsicons “/usr/local/awstats/wwwroot/icon/”‘
Add ‘ScriptAlias /awstats/ “/usr/local/awstats/wwwroot/cgi-bin/”‘
Add ‘‘ directive
AWStats directives added to Apache config file.

—–> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ? y

—–> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> Exif-Viewer

—–> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
> /etc/awstats

—–> Create config file ‘/etc/awstats/awstats.Exif-Viewer.conf’
Error: Failed to open ‘/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf’ for read.

Ende der Installation. Leider ohne Erfolg :-(. OK, die Datei awstats.model.conf aus dem Internet besorgt, an die entsprechende Stelle kopiert und weiter im Installationsprozess :-).
……..
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
> /etc/awstats

—–> Create config file ‘/etc/awstats/awstats.Exif-Viewer.conf’
Config file /etc/awstats/awstats.Exif-Viewer.conf created.

—–> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=Exif-Viewer
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue…
A SIMPLE config file has been created: /etc/awstats/awstats.Exif-Viewer.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for ‘Exif-Viewer’ with command:
> perl awstats.pl -update -config=Exif-Viewer
You can also read your statistics for ‘Exif-Viewer’ with URL:
> http://localhost/awstats/awstats.pl?config=Exif-Viewer
Press ENTER to finish…
Nun ist die Installation also beendet und ich kann meine Logfiles analysieren und die Auswertung im Browser betrachten … Naja, mal sehen, was wirklich passiert.
cd /usr/local/awstats/wwwroot/cgi-bin
perl awstats.pl -update -config=Exif-Viewer
Error: AWStats database directory defined in config file by ‘DirData’ parameter (/var/lib/awstats) does not exist or is not writable.
Setup (’/etc/awstats/awstats.Exif-Viewer.conf’ file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in ‘docs’ directory).
Ja, das habe ich mir schon gedacht, so einfach ist das nicht. Mein Server ist halt anders als die meisten anderen Server… OK, dann werde ich mir erst mal meine awstats Konfiguration ansehen.
Als Logfile ist hier tatsächlich “/var/log/httpd/mylog.log” eingetragen. Wie kommt awstats darauf, dass hier mein Logfile liegen könnte? Egal, ich trage erst mal die korrekte Datei ein.
Der nächste lustige Eintrag ist “HostAliases”. Hier finde ich folgenden Eintrag.
HostAliases=”exif-viewer www.exif-viewer 127.0.0.1 localhost”
Hier fehlt die TLD und ich will weder 127.0.0.1 noch localhost sehen. Also auch diesen Eintrag anpassen und weiter. Als nächstes finde ich [DirData="/var/lib/awstats"]. Das Verzeichnis existiert nicht auf meinem Server und ich entscheide, dass ich den Kram lieber an einer anderen Stelle haben möchte und ändere auch diesen Eintrag.
So weit so gut. Jetzt kommt noch eine ganze Menge anderes Zeug in der Konfigurationsdatei. Aber das sieht eher nach der Konfiguration für den Webserver aus. Ich prüfe also erst mal, ob awstats.pl lauffähig ist.
perl awstats.pl -update -config=Exif-Viewer
Create/Update database for config “/etc/awstats/awstats.Exif-Viewer.conf” by AWStats version 6.95 (build 1.943)
From data in log file “/opt/lampp/logs/exif-viewer.de-access_log”…
Phase 1 : First bypass old records, searching new record…
Searching new records from beginning of log file…
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)…
Jumped lines in file: 0
Parsed lines in file: 8057
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 8057 new qualified records.
Na das sieht doch schon mal ganz gut aus. In dem von mir ausgewählten Verzeichnis wird eine Datei mit dem Namen “awstats032010.Exif-Viewer.txt” erstellt. Kurz den vi angeworfen und mal einen Blick riskiert … na das passt. Fast ärgere ich mich ein wenig, dass ich erst vor kurzem alle meine Logfiles gelöscht habe :-(. Aber das wird schon noch. Die wachsen ja wieder :-).
OK, aber mit der Textdatei kann ich nur wenig anfangen. Ich will das ja im Browser betrachten können. Also rufe ich erst mal awstats.pl auf um zu sehen, was man den noch so für Möglichkeiten hat.
perl awstats.pl
—– awstats 6.95 (build 1.943) (c) 2000-2009 Laurent Destailleur —–
AWStats is a free web server logfile analyzer to show you advanced web
statistics.
AWStats comes with ABSOLUTELY NO WARRANTY. It’s a free software distributed
with a GNU General Public License (See LICENSE file for details).
Syntax: awstats.pl -config=virtualhostname [options]
This runs awstats in command line to update statistics (-update option) of a
web site, from the log file defined in AWStats config file, or build a HTML
report (-output option).
First, awstats tries to read awstats.virtualhostname.conf as the config file.
If not found, awstats tries to read awstats.conf
Note 1: Config files (awstats.virtualhostname.conf or awstats.conf) must be
in /etc/awstats, /usr/local/etc/awstats, /etc or same directory than
awstats.pl script file.
Note 2: If AWSTATS_FORCE_CONFIG environment variable is defined, AWStats will
use it as the “config” value, whatever is the value on command line or URL.
See AWStats documentation for all setup instrutions.
Options to update statistics:
-update to update statistics (default)
-showsteps to add benchmark information every 8192 lines processed
-showcorrupted to add output for each corrupted lines found, with reason
-showdropped to add output for each dropped lines found, with reason
-showunknownorigin to output referer when it can’t be parsed
-showdirectorigin to output log line when origin is a direct access
-updatefor=n to stop the update process after parsing n lines
-LogFile=x to change log to analyze whatever is ‘LogFile’ in config file
Be care to process log files in chronological order when updating statistics.
Options to show statistics:
-output to output main HTML report (no update made except with -update)
-output=x to output other report pages where x is:
alldomains to build page of all domains/countries
allhosts to build page of all hosts
lasthosts to build page of last hits for hosts
unknownip to build page of all unresolved IP
allemails to build page of all email senders (maillog)
lastemails to build page of last email senders (maillog)
allemailr to build page of all email receivers (maillog)
lastemailr to build page of last email receivers (maillog)
alllogins to build page of all logins used
lastlogins to build page of last hits for logins
allrobots to build page of all robots/spider visits
lastrobots to build page of last hits for robots
urldetail to list most often viewed pages
urldetail:filter to list most often viewed pages matching filter
urlentry to list entry pages
urlentry:filter to list entry pages matching filter
urlexit to list exit pages
urlexit:filter to list exit pages matching filter
osdetail to build page with os detailed versions
browserdetail to build page with browsers detailed versions
unknownbrowser to list ‘User Agents’ with unknown browser
unknownos to list ‘User Agents’ with unknown OS
refererse to build page of all refering search engines
refererpages to build page of all refering pages
keyphrases to list all keyphrases used on search engines
keywords to list all keywords used on search engines
errors404 to list ‘Referers’ for 404 errors
allextraX to build page of all values for ExtraSection X
-staticlinks to have static links in HTML report page
-staticlinksext=xxx to have static links with .xxx extension instead of .html
-lang=LL to output a HTML report in language LL (en,de,es,fr,it,nl,…)
-month=MM to output a HTML report for an old month MM
-year=YYYY to output a HTML report for an old year YYYY
Those ‘date’ options doesn’t allow you to process old log file. They only
allow you to see a past report for a chosen month/year period instead of
current month/year.
Other options:
-debug=X to add debug informations lesser than level X (speed reduced)
Now supports/detects:
Web/Ftp/Mail/streaming server log analyzis (and load balanced log files)
Reverse DNS lookup (IPv4 and IPv6) and GeoIP lookup
Number of visits, number of unique visitors
Visits duration and list of last visits
Authenticated users
Days of week and rush hours
Hosts list and unresolved IP addresses list
Most viewed, entry and exit pages
Files type and Web compression (mod_gzip, mod_deflate stats)
Screen size
Ratio of Browsers with support of: Java, Flash, RealG2 reader,
Quicktime reader, WMA reader, PDF reader
Configurable personalized reports
274 domains/countries
642 robots
5 worm’s families
71 operating systems
208 browsers (592 with phone browsers database)
228 search engines (and keyphrases/keywords used from them)
All HTTP errors with last referrer
Report by day/month/year
Dynamic or static HTML or XHTML reports, static PDF reports
Indexed text or XML monthly database
And a lot of other advanced features and options…
New versions and FAQ at http://awstats.sourceforge.net
Wow, das ist ja eine ganze Menge. Nach einem kurzen Blick in die Liste der Einstellungsmöglichkeiten entscheide ich mich für folgenden Aufruf:

perl awstats.pl -config=Exif-Viewer -output

Siehe da, eine HTML Ausgabe wird erzeigt, die ich erst mal in einer Datei schreiben lasse.

perl awstats.pl -config=Exif-Viewer -output > awstats.exif-viewer.html

Die Datei kann man dann mit w3m betrachten.

w3m awstats.exif-viewer.html

Allerdings sind eine Menge Bilder eingebettet, die w3m natürlich nicht darstellen kann. Aber selbst wenn ich die Datei nun an eine bestimmte Stelle auf meinen Webserver kopieren würde, müsste ich dafür sorgen, dass die Bilder vorhanden sind. OK, die Bilder sind schnell gefunden. Eine Suche nach einer png Datei findet die Dateien schnell und einfach.

find . -name “vu.png” -print
./wwwroot/icon/flags/vu.png
./wwwroot/icon/other/vu.png

Die HTML Datei erwartet die Bilder unter den URL “/awstatsicons/other/vu.png”. OK, also kopiere ich den Ordner “icon” nach “/srv/www/vhosts/[das ist privat]/awstatsicons” und die generierte html Datei in einen Ordner, der für meine Statistiken vorgesehen ist.

cp -r icon /srv/www/vhosts/[das ist privat]/awstatsicons
cp awstats.exif-viewer.html /srv/www/vhosts/[das ist privat]/awstats

Jetzt den URL zu der Datei awstats.exif-viewer.html im Browser aufrufen und tatsächlich sehe ich nun die awstats Statistik zu der Domain Exif-Viewer.de. Die Auswertung sieht auf den ersten Blick sehr gut aus. Im Kopfbereich der HTML Seite gibt es noch einen interaktiven Teil, mit dem man die “Reported period:” auswählen kann. Dieser funktioniert natürlich nicht, da ich ja nur statische HTML Seiten erzeuge und das perl Skript nicht direkt aufrufe. Unter der Überschrift “Pages-URL (Top 10)” werden mir Links zu den Top10 URLs angezeigt. Die Links funktionieren nicht, da hier in den URLs die TLD von exif-viewer.de fehlt und statt einem Link zu “http://exif-viewer.de/exif-thumbnail.php” wird ein Link zu “http://exif-viewer/exif-thumbnail.php” erzeugt. Das liegt wohl an einem Fehler in der Konfiguration um den ich mich aber erst später kümmern werde. Sonst sieht alles sehr gut aus.

Eine Winzigkeit ist da noch. An vielen Stellen wird auf weiterführende Dokumente verwiesen. So z.B. unter “HTTP Status codes” wird der HTTP Code “404 Document Not Found (hits on favicon excluded)” als Link dargestellt. Dieser Link funktioniert natürlich auch nicht, da er sich auf das Perl Skript “http://[dieser Teil ist privat]/awstats/awstats.pl?config=Exif-Viewer&output=errors404″ bezieht und mit dem statischen HTML nicht funktioniert. Damit werde ich wohl leben müssen, wenn ich bei den statischen HTML Seiten bleiben möchte. Das ist aber OK für mich, da ich mir nur ab und an mal einen Überblick verschaffen möchte und mich nicht in den Tiefen der Logfile Analyse verlieren will :-).

Fazit: Mit awstats habe ich ein neues Spielzeug, das von nun an einen permanenten Platz in meiner crontab hat ;-).

OK, alle die es geschaft haben, den Artikel bis hierher zu verfolgen dürfen einen Blick auf die awstats Statistik werfen, die ich beim Schreiben des Artikels erstellt habe :-).
Bitteschön

Share and Enjoy:
(No Ratings Yet)
 Loading ...

Dein Kommentar



 Plugin by MyNakedGirlfriend.de