root/alternc-awstats/tags/v0/alternc-awstats

Revision 1030, 1.1 kB (checked in by anonymous, 4 years ago)

Initial revision

  • 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
9 if [ -z "$ACCESSLOG" ]
10 then
11     ACCESSLOG="/var/log/apache/access.log.1"
12 fi
13
14 if [ -z "$MYSQL_HOST" ]
15 then
16     MYSQL_HOST="localhost"
17 fi
18
19 CACHEDIR="/var/cache/alternc-webalizer"
20 TMPDNS=`mktemp -p /tmp`
21 TMPLOG=`mktemp -p /tmp`
22 mkdir -p $CACHEDIR
23 trap cleanup 1 2 15
24
25 function cleanup {
26     rm -f $TMPDNS
27     rm -f $TMPLOG
28     rm -rf $CACHEDIR/*
29 }
30
31 function dostat {
32     read LANG DOM
33     while [ "$DOM" ]
34     do   
35       export LC_ALL="$LANG"
36       export LC_MESSAGES="$LANG"
37       export LANG
38
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/bin/webalizer -c $CACHEDIR/$DOM.conf -N 0 -D $TMPDNS - 2>/dev/null
43       read LANG DOM
44     done
45 }
46
47 # Clear the cache dir
48 rm -rf $CACHEDIR/*
49 # Fill the cache dir
50 /usr/lib/alternc/webalizer.cache.php
51
52 # Launch the stat
53 mysql -h"$MYSQL_HOST" -p"$MYSQL_PASS" -u"$MYSQL_USER" "$MYSQL_DATABASE" -B -e "SELECT lang,hostname FROM stats" |grep -v "^lang" | dostat
54
55 cleanup
Note: See TracBrowser for help on using the browser.