source: trunk/alternc-awstats @ 1037

Revision 1037, 1.2 KB checked in by anonymous, 9 years ago (diff)

Suppression des inutiles
Corrections diverses dans le script (on n'EFFACE PAS le cache ...)

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1#!/bin/sh
2. /etc/alternc/local.sh
3
4#if [ -e /etc/alternc/webalizer.conf ]
5#then
6#    . /etc/alternc/webalizer.conf
7#fi
8
9if [ -z "$ACCESSLOG" ] 
10then
11    ACCESSLOG="/var/log/apache/access.log.1"
12fi
13
14if [ -z "$MYSQL_HOST" ] 
15then
16    MYSQL_HOST="localhost"
17fi
18
19CACHEDIR="/var/cache/awstats"
20TMPDNS=`mktemp -p /tmp`
21TMPLOG=`mktemp -p /tmp`
22mkdir -p $CACHEDIR
23trap cleanup 1 2 15
24
25function cleanup {
26    rm -f $TMPDNS
27    rm -f $TMPLOG
28#    rm -rf $CACHEDIR/*
29}
30
31function dostat {
32    read DOM
33    while [ "$DOM" ]
34    do   
35      #export LC_ALL="$LANG"
36      #export LC_MESSAGES="$LANG"
37      #export LANG
38      echo "processing $DOM"
39      # first run: resolve IPs in cache
40      #grep -h " $DOM$" $ACCESSLOG | /usr/bin/webalizer -c $CACHEDIR/$DOM.conf -N 5 -D $TMPDNS - &>/dev/null
41      # second run: process the stats
42      /usr/lib/cgi-bin/awstats.pl -config=$DOM 
43      read DOM
44    done
45}
46
47# Clear the cache dir
48# DONT do it ! it looses all previously computed data !
49#rm -rf $CACHEDIR/*
50# Fill the cache dir (/etc dir)
51# not required: m_aws.php build it properly
52# /usr/lib/alternc/awstats.cache.php
53
54# Launch the stat
55mysql -h"$MYSQL_HOST" -p"$MYSQL_PASS" -u"$MYSQL_USER" "$MYSQL_DATABASE" -B -e "SELECT hostname FROM aws" |grep -v "^hostname" | dostat
56
57cleanup
Note: See TracBrowser for help on using the repository browser.