root/alternc-awstats/tags/REL_0_3/alternc-awstats

Revision 1057, 1.9 kB (checked in by anonymous, 4 years ago)

faute remplacement de ` par "

  • 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
3 # Appelé seul, lance les stats AWStats du jour.
4 # Appelé avec "all" lance les stats avec tous les fichiers .gz situés dans /var/log/apache
5 # Appelé avec un nom de domaine en paramètre, rescanne tous les fichiers .gz pour ce domaine uniquement.
6
7
8 . /etc/alternc/local.sh
9
10 # This file specify a different ACCESSLOG when there is apachemerge in the server.
11 if [ -e /etc/alternc/webalizer.conf ]
12 then
13     . /etc/alternc/webalizer.conf
14 fi
15
16 if [ -z "$1" ]
17     then
18     if [ -z "$ACCESSLOG" ]
19         then
20         ACCESSLOG="/var/log/apache/access.log.1"
21     fi
22 else
23     ACCESSLOG="/var/log/apache/access.log"
24     MAXLOG=`ls -rt /var/log/apache/access.log.* | head -1 | sed -e 's/[^0-9]*\([0-9]*\).gz/\1/'`
25 fi
26
27 # Regenerate the awstat etc cache files :
28 if [ -x ./awstats.cache.php ]
29 then
30     ./awstats.cache.php
31 fi
32
33 if [ -z "$MYSQL_HOST" ]
34 then
35     MYSQL_HOST="localhost"
36 fi
37
38 CACHEDIR="/var/cache/awstats"
39 TMPLOG="/tmp/awstats.access.log"
40
41 mkdir -p $CACHEDIR
42 trap cleanup 1 2 15
43
44 function cleanup {
45     rm -f $TMPLOG
46 }
47
48 function dostatgz {
49     read DOM
50     while [ "$DOM" ]
51       do
52       echo "processing $DOM (for $MAXLOG access files)"
53        rm -f $TMPLOG
54       for i in `seq $MAXLOG 2`
55         do
56         zgrep -h " $DOM$" $ACCESSLOG.$i.gz >>$TMPLOG 2>/dev/null
57         echo -n "$i."
58       done
59       /usr/lib/cgi-bin/awstats.pl -config=$DOM
60       read DOM
61     done
62 }
63
64 function dostat {
65     read DOM
66     while [ "$DOM" ]
67     do   
68       echo "processing $DOM"
69       grep -h " $DOM$" $ACCESSLOG >$TMPLOG 2>/dev/null
70       /usr/lib/cgi-bin/awstats.pl -config=$DOM
71       read DOM
72     done
73 }
74
75 if [ -z "$1" ]
76     then
77     mysql -h"$MYSQL_HOST" -p"$MYSQL_PASS" -u"$MYSQL_USER" "$MYSQL_DATABASE" -B -e "SELECT hostname FROM aws" |grep -v "^hostname" | dostat
78 else
79     if [ "$1" = "all" ]
80         then
81         mysql -h"$MYSQL_HOST" -p"$MYSQL_PASS" -u"$MYSQL_USER" "$MYSQL_DATABASE" -B -e "SELECT hostname FROM aws" |grep -v "^hostname" | dostatgz
82     else
83         echo "$1" | dostatgz
84     fi
85 fi
86
87 cleanup
Note: See TracBrowser for help on using the browser.