Skip to content

Commit c25fd96

Browse files
committed
awstats support
1 parent 742dfbe commit c25fd96

File tree

6 files changed

+200
-35
lines changed

6 files changed

+200
-35
lines changed

bin/v_add_web_domain_stat

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,30 +54,29 @@ is_web_domain_key_empty '$STATS'
5454
# Action #
5555
#----------------------------------------------------------#
5656

57+
# Parse aliases
58+
aliases=$(get_web_domain_value '$ALIAS')
59+
aliases_idn=$(idn -t --quiet -a "$aliases")
60+
5761
# Adding statistic config
5862
cat $V_WEBTPL/$type.tpl |\
59-
sed -e "s/%ip%/$ip/g" | \
60-
sed -e "s/%port%/$port/g" | \
61-
sed -e "s/%domain_idn%/$domain_idn/g" | \
62-
sed -e "s/%domain%/$domain/g" | \
63-
sed -e "s/%user%/$user/g" | \
64-
sed -e "s/%home%/${V_HOME////\/}/g" | \
65-
sed -e "s/%alias%/$domain_aliases/g" \
66-
>$V_HOME/$user/conf/$type.$domain.conf
63+
sed -e "s/%ip%/$ip/g" \
64+
-e "s/%port%/$port/g" \
65+
-e "s/%domain_idn%/$domain_idn/g" \
66+
-e "s/%domain%/$domain/g" \
67+
-e "s/%user%/$user/g" \
68+
-e "s/%home%/${V_HOME////\/}/g" \
69+
-e "s/%alias%/${aliases//,/ }/g" \
70+
-e "s/%alias_idn%/${aliases_idn//,/ }/g" \
71+
> $V_HOME/$user/conf/$type.$domain.conf
6772

6873

6974
#----------------------------------------------------------#
7075
# Vesta #
7176
#----------------------------------------------------------#
7277

73-
# Switching on command string for pipe
74-
case $type in
75-
webalizer) command="webalizer -c $V_HOME/$user/conf/$type.$domain.conf";;
76-
awstats ) command="" # FIXME awstats command;;
77-
esac
78-
7978
# Adding command to pipe
80-
echo "$command" >> $V_QUEUE/stats.pipe
79+
echo "$V_BIN/v_upd_web_domain_stat $user $domain" >> $V_QUEUE/stats.pipe
8180

8281
# Adding stats in config
8382
update_web_domain_value '$STATS' "$type"

bin/v_upd_web_domain_stat

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/bin/bash
2+
# info: updating domain web statistics
3+
4+
#----------------------------------------------------------#
5+
# Variable&Function #
6+
#----------------------------------------------------------#
7+
8+
# Argument defenition
9+
user="$1"
10+
domain=$(idn -t --quiet -u "$2" )
11+
domain_idn=$(idn -t --quiet -a "$domain")
12+
13+
# Importing variables
14+
source $VESTA/conf/vars.conf
15+
source $V_FUNC/shared_func.sh
16+
source $V_FUNC/domain_func.sh
17+
18+
19+
#----------------------------------------------------------#
20+
# Verifications #
21+
#----------------------------------------------------------#
22+
23+
# Checking arg number
24+
check_args '2' "$#" 'user domain'
25+
26+
# Checking argument format
27+
format_validation 'user' 'domain'
28+
29+
# Checking web system is enabled
30+
is_system_enabled 'web'
31+
32+
# Checking user
33+
is_user_valid
34+
35+
# Checking domain exist
36+
is_web_domain_valid
37+
38+
# Checking domain is not suspened
39+
is_domain_suspended 'web'
40+
41+
# Checking stats enabled
42+
is_web_domain_value_exist '$STATS'
43+
44+
45+
#----------------------------------------------------------#
46+
# Action #
47+
#----------------------------------------------------------#
48+
49+
stats=$(get_web_domain_value '$STATS')
50+
51+
# Checking config
52+
config="$V_HOME/$user/conf/$stats.$domain.conf"
53+
if [ ! -e "$config" ]; then
54+
echo "Error: Parsing error"
55+
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
56+
exit $E_PARSE_ERROR
57+
fi
58+
59+
# Checking statistics directory
60+
dir="$V_HOME/$user/web/$domain/stats"
61+
if [ ! -e "$dir" ]; then
62+
mkdir -p $dir
63+
fi
64+
65+
# Defining functions
66+
build_webalizer() {
67+
/usr/bin/webalizer -c $config
68+
}
69+
70+
build_awstats() {
71+
awstats="/var/www/awstats"
72+
awstats_options="-config=$config -staticlinks -update -output"
73+
month=$(date "+%Y-%m")
74+
output='alldomains allhosts lasthosts unknownip allrobots lastrobots
75+
session urldetail urlentry urlexit osdetail unknownos
76+
browserdetail unknownbrowser refererse refererpages keyphrases
77+
keywords errors404'
78+
79+
# Checking statistics directory
80+
if [ ! -e "$dir/$month" ]; then
81+
mkdir -p $dir/$month
82+
fi
83+
84+
# Icon directory check
85+
if [ ! -e "$dir/icon" ]; then
86+
cp -r $awstats/icon $dir/
87+
fi
88+
89+
# Creating main awstats page
90+
$awstats/awstats.pl $awstats_options |\
91+
sed -e "s%awstats.$config.%%g" > $dir/$month/index.html
92+
93+
# Creating suplemental awstats pages
94+
for format in $output; do
95+
$awstats/awstats.pl $awstats_options=$format |\
96+
sed -e "s%awstats.$config.%%g" > $dir/$month/$format.html
97+
done
98+
99+
# Creating index page
100+
cat $V_WEBTPL/awstats_index.tpl | sed -e "s/%month%/$month/g" \
101+
> $dir/index.html
102+
103+
# Creating navigation page
104+
months=$(find $dir -type d | sed -e "s%$dir/%%g" -e "s%$dir%%g" |\
105+
grep -v icon | sort -r )
106+
for link in $months; do
107+
select_m="$select_m\t <option value=\"$link\">$link<\/option>\n"
108+
done
109+
cat $V_WEBTPL/awstats_nav.tpl | sed -e "s/%select_month%/$select_m/" \
110+
> $dir/nav.html
111+
112+
}
113+
114+
# Switching on statistics type
115+
case $stats in
116+
webalizer) build_webalizer ;;
117+
awstats) build_awstats ;;
118+
esac
119+
120+
# Chown
121+
chown -R $user:$(groups $user| cut -f 3 -d ' ') $dir
122+
123+
124+
#----------------------------------------------------------#
125+
# Vesta #
126+
#----------------------------------------------------------#
127+
128+
# Logging
129+
log_event 'system' "$V_EVENT"
130+
131+
exit $OK

data/templates/awstats.tpl

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
LogFile="/var/log/httpd/domains/%domain%.log"
2-
LogType="W"
3-
LogFormat="1"
2+
LogType=W
3+
LogFormat=1
44
LogSeparator=" "
5-
SiteDomain="%domain%"
6-
HostAliases="%alias%"
7-
DNSLookup="2"
8-
DirData="%home%/%user%/web/%domain%/stats/"
9-
DirCgi="/awstats"
10-
DirIcons="/awstatsicons"
11-
AllowToUpdateStatsFromBrowser="0"
12-
AllowFullYearView="3"
13-
EnableLockForUpdate=0
5+
SiteDomain="%domain_idn%"
6+
HostAliases="%alias_idn%"
7+
DirData="%home%/%user%/web/%domain%/stats"
8+
DirCgi="/stats"
9+
DirIcons="/stats/icon"
10+
AllowToUpdateStatsFromBrowser=0
11+
AllowFullYearView=2
12+
EnableLockForUpdate=1
1413
DNSStaticCacheFile="dnscache.txt"
1514
DNSLastUpdateCacheFile="dnscachelastupdate.txt"
1615
SkipDNSLookupFor=""
@@ -23,16 +22,17 @@ BuildReportFormat=html
2322
SaveDatabaseFilesWithPermissionsForEveryone=0
2423
PurgeLogFile=0
2524
ArchiveLogRecords=0
26-
KeepBackupOfHistoricFiles=0
27-
DefaultFile="index.html"
28-
SkipHosts=""
25+
KeepBackupOfHistoricFiles=1
26+
DefaultFile="index.php index.html"
27+
SkipHosts="127.0.0.1
2928
SkipUserAgents=""
3029
SkipFiles=""
3130
SkipReferrersBlackList=""
3231
OnlyHosts=""
3332
OnlyUserAgents=""
33+
OnlyUsers=""
3434
OnlyFiles=""
35-
NotPageList="css js class gif jpg jpeg png bmp ico swf"
35+
NotPageList="css js class gif jpg jpeg png bmp ico rss xml swf"
3636
ValidHTTPCodes="200 304"
3737
ValidSMTPCodes="1 250"
3838
AuthenticatedUsersNotCaseSensitive=0
@@ -52,7 +52,7 @@ DecodeUA=0
5252
MiscTrackerUrl="/js/awstats_misc_tracker.js"
5353
UseFramesWhenCGI=1
5454
DetailedReportsOnNewWindows=1
55-
Expires=0
55+
Expires=3600
5656
MaxRowsInHTMLOutput=1000
5757
Lang="auto"
5858
DirLang="./lang"
@@ -73,6 +73,7 @@ ShowSessionsStats=1
7373
ShowPagesStats=PBEX
7474
ShowFileTypesStats=HB
7575
ShowFileSizesStats=0
76+
ShowDownloadsStats=HB
7677
ShowOSStats=1
7778
ShowBrowsersStats=1
7879
ShowScreenSizeStats=0
@@ -96,6 +97,8 @@ MaxNbOfLoginShown = 10
9697
MinHitLogin = 1
9798
MaxNbOfRobotShown = 10
9899
MinHitRobot = 1
100+
MaxNbOfDownloadsShown = 10
101+
MinHitDownloads = 1
99102
MaxNbOfPageShown = 10
100103
MinHitFile = 1
101104
MaxNbOfOsShown = 10
@@ -114,18 +117,17 @@ MaxNbOfKeywordsShown = 10
114117
MinHitKeyword = 1
115118
MaxNbOfEMailsShown = 20
116119
MinHitEMail = 1
117-
FirstDayOfWeek=1
120+
FirstDayOfWeek=0
118121
ShowFlagLinks=""
119122
ShowLinksOnUrl=1
120123
UseHTTPSLinkForUrl=""
121124
MaxLengthOfShownURL=64
122125
HTMLHeadSection=""
123126
HTMLEndSection=""
127+
MetaRobot=0
124128
Logo="awstats_logo6.png"
125129
LogoLink="http://awstats.sourceforge.net"
126130
BarWidth = 260
127131
BarHeight = 90
128132
StyleSheet=""
129133
ExtraTrackedRowsLimit=500
130-
create_mode="from_scratch"
131-
file_to_copy=""

data/templates/awstats_index.tpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<html>
2+
<head>
3+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
4+
<title>Awstats log analyzer </title>
5+
</head>
6+
<frameset rows="48,*" cols="*">
7+
<frame src="nav.html" name="nav" scrolling="no" noresize>
8+
<frame src="%month%/index.html" name="stats">
9+
</frameset>
10+
</html>

data/templates/awstats_nav.tpl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<html>
2+
<head>
3+
<title>Awstats navigation</title>
4+
<script language="javascript">
5+
function change() {
6+
top.stats.location= document.period.select.value + '/';
7+
}
8+
</script>
9+
</head>
10+
<body>
11+
<table width="100%" border="0" cellspacing="0" cellpadding="0">
12+
<tr>
13+
<td><img src="http://vestacp.com/i/logo.png" alt="vesta"></td>
14+
<td><form name="period" action="" method="get">
15+
<select name="select" ONCHANGE="change()">
16+
%select_month%
17+
</select>
18+
</form>
19+
</td>
20+
</tr>
21+
</table>
22+
</body>
23+
</html>

data/templates/webalizer.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ LogFile /var/log/httpd/domains/%domain%.log
33
OutputDir %home%/%user%/web/%domain%/stats
44
HistoryName %home%/%user%/web/%domain%/stats/%domain%.hist
55
Incremental yes
6-
IncrementalName %home%/%user%/domains/%domain%/stats/%domain%.current
6+
IncrementalName %home%/%user%/web/%domain%/stats/%domain%.current
77
PageType htm*
88
PageType cgi
99
PageType php

0 commit comments

Comments
 (0)