mirror of
https://github.com/myvesta/vesta
synced 2025-07-16 10:03:23 -07:00
awstats support
This commit is contained in:
parent
742dfbec28
commit
c25fd964e1
6 changed files with 200 additions and 35 deletions
|
@ -54,30 +54,29 @@ is_web_domain_key_empty '$STATS'
|
|||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Parse aliases
|
||||
aliases=$(get_web_domain_value '$ALIAS')
|
||||
aliases_idn=$(idn -t --quiet -a "$aliases")
|
||||
|
||||
# Adding statistic config
|
||||
cat $V_WEBTPL/$type.tpl |\
|
||||
sed -e "s/%ip%/$ip/g" | \
|
||||
sed -e "s/%port%/$port/g" | \
|
||||
sed -e "s/%domain_idn%/$domain_idn/g" | \
|
||||
sed -e "s/%domain%/$domain/g" | \
|
||||
sed -e "s/%user%/$user/g" | \
|
||||
sed -e "s/%home%/${V_HOME////\/}/g" | \
|
||||
sed -e "s/%alias%/$domain_aliases/g" \
|
||||
>$V_HOME/$user/conf/$type.$domain.conf
|
||||
sed -e "s/%ip%/$ip/g" \
|
||||
-e "s/%port%/$port/g" \
|
||||
-e "s/%domain_idn%/$domain_idn/g" \
|
||||
-e "s/%domain%/$domain/g" \
|
||||
-e "s/%user%/$user/g" \
|
||||
-e "s/%home%/${V_HOME////\/}/g" \
|
||||
-e "s/%alias%/${aliases//,/ }/g" \
|
||||
-e "s/%alias_idn%/${aliases_idn//,/ }/g" \
|
||||
> $V_HOME/$user/conf/$type.$domain.conf
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Switching on command string for pipe
|
||||
case $type in
|
||||
webalizer) command="webalizer -c $V_HOME/$user/conf/$type.$domain.conf";;
|
||||
awstats ) command="" # FIXME awstats command;;
|
||||
esac
|
||||
|
||||
# Adding command to pipe
|
||||
echo "$command" >> $V_QUEUE/stats.pipe
|
||||
echo "$V_BIN/v_upd_web_domain_stat $user $domain" >> $V_QUEUE/stats.pipe
|
||||
|
||||
# Adding stats in config
|
||||
update_web_domain_value '$STATS' "$type"
|
||||
|
|
131
bin/v_upd_web_domain_stat
Executable file
131
bin/v_upd_web_domain_stat
Executable file
|
@ -0,0 +1,131 @@
|
|||
#!/bin/bash
|
||||
# info: updating domain web statistics
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
source $V_FUNC/domain_func.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Checking arg number
|
||||
check_args '2' "$#" 'user domain'
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'user' 'domain'
|
||||
|
||||
# Checking web system is enabled
|
||||
is_system_enabled 'web'
|
||||
|
||||
# Checking user
|
||||
is_user_valid
|
||||
|
||||
# Checking domain exist
|
||||
is_web_domain_valid
|
||||
|
||||
# Checking domain is not suspened
|
||||
is_domain_suspended 'web'
|
||||
|
||||
# Checking stats enabled
|
||||
is_web_domain_value_exist '$STATS'
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
stats=$(get_web_domain_value '$STATS')
|
||||
|
||||
# Checking config
|
||||
config="$V_HOME/$user/conf/$stats.$domain.conf"
|
||||
if [ ! -e "$config" ]; then
|
||||
echo "Error: Parsing error"
|
||||
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
|
||||
exit $E_PARSE_ERROR
|
||||
fi
|
||||
|
||||
# Checking statistics directory
|
||||
dir="$V_HOME/$user/web/$domain/stats"
|
||||
if [ ! -e "$dir" ]; then
|
||||
mkdir -p $dir
|
||||
fi
|
||||
|
||||
# Defining functions
|
||||
build_webalizer() {
|
||||
/usr/bin/webalizer -c $config
|
||||
}
|
||||
|
||||
build_awstats() {
|
||||
awstats="/var/www/awstats"
|
||||
awstats_options="-config=$config -staticlinks -update -output"
|
||||
month=$(date "+%Y-%m")
|
||||
output='alldomains allhosts lasthosts unknownip allrobots lastrobots
|
||||
session urldetail urlentry urlexit osdetail unknownos
|
||||
browserdetail unknownbrowser refererse refererpages keyphrases
|
||||
keywords errors404'
|
||||
|
||||
# Checking statistics directory
|
||||
if [ ! -e "$dir/$month" ]; then
|
||||
mkdir -p $dir/$month
|
||||
fi
|
||||
|
||||
# Icon directory check
|
||||
if [ ! -e "$dir/icon" ]; then
|
||||
cp -r $awstats/icon $dir/
|
||||
fi
|
||||
|
||||
# Creating main awstats page
|
||||
$awstats/awstats.pl $awstats_options |\
|
||||
sed -e "s%awstats.$config.%%g" > $dir/$month/index.html
|
||||
|
||||
# Creating suplemental awstats pages
|
||||
for format in $output; do
|
||||
$awstats/awstats.pl $awstats_options=$format |\
|
||||
sed -e "s%awstats.$config.%%g" > $dir/$month/$format.html
|
||||
done
|
||||
|
||||
# Creating index page
|
||||
cat $V_WEBTPL/awstats_index.tpl | sed -e "s/%month%/$month/g" \
|
||||
> $dir/index.html
|
||||
|
||||
# Creating navigation page
|
||||
months=$(find $dir -type d | sed -e "s%$dir/%%g" -e "s%$dir%%g" |\
|
||||
grep -v icon | sort -r )
|
||||
for link in $months; do
|
||||
select_m="$select_m\t <option value=\"$link\">$link<\/option>\n"
|
||||
done
|
||||
cat $V_WEBTPL/awstats_nav.tpl | sed -e "s/%select_month%/$select_m/" \
|
||||
> $dir/nav.html
|
||||
|
||||
}
|
||||
|
||||
# Switching on statistics type
|
||||
case $stats in
|
||||
webalizer) build_webalizer ;;
|
||||
awstats) build_awstats ;;
|
||||
esac
|
||||
|
||||
# Chown
|
||||
chown -R $user:$(groups $user| cut -f 3 -d ' ') $dir
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
|
@ -1,16 +1,15 @@
|
|||
LogFile="/var/log/httpd/domains/%domain%.log"
|
||||
LogType="W"
|
||||
LogFormat="1"
|
||||
LogType=W
|
||||
LogFormat=1
|
||||
LogSeparator=" "
|
||||
SiteDomain="%domain%"
|
||||
HostAliases="%alias%"
|
||||
DNSLookup="2"
|
||||
DirData="%home%/%user%/web/%domain%/stats/"
|
||||
DirCgi="/awstats"
|
||||
DirIcons="/awstatsicons"
|
||||
AllowToUpdateStatsFromBrowser="0"
|
||||
AllowFullYearView="3"
|
||||
EnableLockForUpdate=0
|
||||
SiteDomain="%domain_idn%"
|
||||
HostAliases="%alias_idn%"
|
||||
DirData="%home%/%user%/web/%domain%/stats"
|
||||
DirCgi="/stats"
|
||||
DirIcons="/stats/icon"
|
||||
AllowToUpdateStatsFromBrowser=0
|
||||
AllowFullYearView=2
|
||||
EnableLockForUpdate=1
|
||||
DNSStaticCacheFile="dnscache.txt"
|
||||
DNSLastUpdateCacheFile="dnscachelastupdate.txt"
|
||||
SkipDNSLookupFor=""
|
||||
|
@ -23,16 +22,17 @@ BuildReportFormat=html
|
|||
SaveDatabaseFilesWithPermissionsForEveryone=0
|
||||
PurgeLogFile=0
|
||||
ArchiveLogRecords=0
|
||||
KeepBackupOfHistoricFiles=0
|
||||
DefaultFile="index.html"
|
||||
SkipHosts=""
|
||||
KeepBackupOfHistoricFiles=1
|
||||
DefaultFile="index.php index.html"
|
||||
SkipHosts="127.0.0.1
|
||||
SkipUserAgents=""
|
||||
SkipFiles=""
|
||||
SkipReferrersBlackList=""
|
||||
OnlyHosts=""
|
||||
OnlyUserAgents=""
|
||||
OnlyUsers=""
|
||||
OnlyFiles=""
|
||||
NotPageList="css js class gif jpg jpeg png bmp ico swf"
|
||||
NotPageList="css js class gif jpg jpeg png bmp ico rss xml swf"
|
||||
ValidHTTPCodes="200 304"
|
||||
ValidSMTPCodes="1 250"
|
||||
AuthenticatedUsersNotCaseSensitive=0
|
||||
|
@ -52,7 +52,7 @@ DecodeUA=0
|
|||
MiscTrackerUrl="/js/awstats_misc_tracker.js"
|
||||
UseFramesWhenCGI=1
|
||||
DetailedReportsOnNewWindows=1
|
||||
Expires=0
|
||||
Expires=3600
|
||||
MaxRowsInHTMLOutput=1000
|
||||
Lang="auto"
|
||||
DirLang="./lang"
|
||||
|
@ -73,6 +73,7 @@ ShowSessionsStats=1
|
|||
ShowPagesStats=PBEX
|
||||
ShowFileTypesStats=HB
|
||||
ShowFileSizesStats=0
|
||||
ShowDownloadsStats=HB
|
||||
ShowOSStats=1
|
||||
ShowBrowsersStats=1
|
||||
ShowScreenSizeStats=0
|
||||
|
@ -96,6 +97,8 @@ MaxNbOfLoginShown = 10
|
|||
MinHitLogin = 1
|
||||
MaxNbOfRobotShown = 10
|
||||
MinHitRobot = 1
|
||||
MaxNbOfDownloadsShown = 10
|
||||
MinHitDownloads = 1
|
||||
MaxNbOfPageShown = 10
|
||||
MinHitFile = 1
|
||||
MaxNbOfOsShown = 10
|
||||
|
@ -114,18 +117,17 @@ MaxNbOfKeywordsShown = 10
|
|||
MinHitKeyword = 1
|
||||
MaxNbOfEMailsShown = 20
|
||||
MinHitEMail = 1
|
||||
FirstDayOfWeek=1
|
||||
FirstDayOfWeek=0
|
||||
ShowFlagLinks=""
|
||||
ShowLinksOnUrl=1
|
||||
UseHTTPSLinkForUrl=""
|
||||
MaxLengthOfShownURL=64
|
||||
HTMLHeadSection=""
|
||||
HTMLEndSection=""
|
||||
MetaRobot=0
|
||||
Logo="awstats_logo6.png"
|
||||
LogoLink="http://awstats.sourceforge.net"
|
||||
BarWidth = 260
|
||||
BarHeight = 90
|
||||
StyleSheet=""
|
||||
ExtraTrackedRowsLimit=500
|
||||
create_mode="from_scratch"
|
||||
file_to_copy=""
|
||||
|
|
10
data/templates/awstats_index.tpl
Normal file
10
data/templates/awstats_index.tpl
Normal file
|
@ -0,0 +1,10 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Awstats log analyzer </title>
|
||||
</head>
|
||||
<frameset rows="48,*" cols="*">
|
||||
<frame src="nav.html" name="nav" scrolling="no" noresize>
|
||||
<frame src="%month%/index.html" name="stats">
|
||||
</frameset>
|
||||
</html>
|
23
data/templates/awstats_nav.tpl
Normal file
23
data/templates/awstats_nav.tpl
Normal file
|
@ -0,0 +1,23 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Awstats navigation</title>
|
||||
<script language="javascript">
|
||||
function change() {
|
||||
top.stats.location= document.period.select.value + '/';
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td><img src="http://vestacp.com/i/logo.png" alt="vesta"></td>
|
||||
<td><form name="period" action="" method="get">
|
||||
<select name="select" ONCHANGE="change()">
|
||||
%select_month%
|
||||
</select>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
|
@ -3,7 +3,7 @@ LogFile /var/log/httpd/domains/%domain%.log
|
|||
OutputDir %home%/%user%/web/%domain%/stats
|
||||
HistoryName %home%/%user%/web/%domain%/stats/%domain%.hist
|
||||
Incremental yes
|
||||
IncrementalName %home%/%user%/domains/%domain%/stats/%domain%.current
|
||||
IncrementalName %home%/%user%/web/%domain%/stats/%domain%.current
|
||||
PageType htm*
|
||||
PageType cgi
|
||||
PageType php
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue