markus
Verified User
HowTo: Custom webalizer wrapper for DA v1.0.0
NOTE: Please, consider this a beta version.
DOWNLOAD:
http://www.phpmix.com/files/directadmin/webalizer
NOTE: Please, consider this a beta version.
DOWNLOAD:
http://www.phpmix.com/files/directadmin/webalizer
Code:
# ======================================================================
# Custom webalizer wrapper for DA - version 1.0.0 (2005-01-11)
#
# Upgrades and further information
# --------------------------------
#
# Please, check out the DirectAdmin (DA) How-To Guides forum:
# [url]http://www.directadmin.com/forum/forumdisplay.php?forumid=40[/url]
#
# History: See change log at the end of these notes.
#
#
# Short Description
# -----------------
#
# This script replaces the webalizer executable called by DA.
# By doing so, it allows you to:
#
# a) Use your own webalizer.conf, even using specific settings
# per domain (or even per subdomain), if you wish.
#
# b) Enable/Disable webalizer stats globally or per domain. This
# might be useful, for instance, if you're using some other Apache
# log analizer like AWStats, etc. for some or all your domains.
#
# In short, this script allows you to call the 'original' webalizer
# ONLY for the domains you want, the way you exactly want. :-)
#
#
# Compatibility
# -------------
#
# As of now (see version and date on top), this script supports:
#
# - DirectAdmin 1.23.3
# - Webalizer 2.01
# - Red Hat Linux Enterprise 3
#
# Please, confirm if you can make it run on other systems. Thanks
#
# ======================================================================
# 1. README
# ======================================================================
#
# 1.1. How current DirectAdmin allows you to customize Webalizer?
# ----------------------------------------------------------------
#
# Quoted from here:
# [url]http://help.directadmin.com/item.php?id=27[/url]
#
# DirectAdmin uses the default webalizer settings by not specifying a
# webalizer.conf file at all. If you want to adjust the settings for
# webalizer, you can create your own basic webalizer.conf file for DA
# to use. This file must be domain independant because this one file
# will be used for all domains without any modifications to it.
#
# This file should be stored here:
# /usr/local/directadmin/data/template/custom/webalizer.conf
#
#
# 1.2. When DirectAdmin calls Webalizer?
# --------------------------------------
#
# DirectAdmin calls webalizer as part of the tally process which is
# triggered by a daily cron task.
#
# You can manually trigger this procedure by executing the following
# command:
#
# echo 'action=tally&value=all' >> /usr/local/directadmin/data/task.queue
#
# Please, read this for further information:
# [url]http://help.directadmin.com/item.php?id=48[/url]
#
#
# 1.3. How DirectAdmin calls Webalizer?
# -------------------------------------
#
# DirectAdmin uses the root user to call webalizer for each domain and
# subdomain as follows:
#
# webalizer -p -n HOSTNAME -o OUTPUT_DIR INPUT_LOG
#
# where:
#
# HOSTNAME - Might either be domain.tld or subdomain.domain.tld
# OUTPUT_DIR - This is the directory where the webalizer results
# will be stored (HTML and PNG files, etc.)
# INPUT_LOG - This is the input log file that will be processed.
#
# examples (*):
#
# webalizer -p -n example.com \
# -o /home/user1/domains/example.com/stats \
# /var/log/httpd/domains/example.com.log
#
# webalizer -p -n subdom.example.com \
# -o /home/user1/domains/example.com/stats/subdom \
# /var/log/httpd/domains/example.com.subdom.log
#
# (*) Note the \ symbol means the command continues in the next line ;-)
#
#
# 1.4. DirectAdmin limitations regarding Webalizer?
# -------------------------------------------------
#
# a) DA does not allow you to use domain specific tokens in the
# webalizer.conf custom template (see 1.1 above).
#
# b) DA runs the webalizer for all domains and subdomains defined in
# the system. But, what if you want to use a different Apache log
# analizer like AWStats, etc.?
#
#
# 1.5. What can we do?
# --------------------
#
# Well, meanwhile DA does not directly support more features related to
# webalizer... we can replace the webalizer executable with a little
# script, so that we can parse the command line and then:
#
# a) Decide if we really want to run webalizer for this domain. This is
# useful if, instead, you want to run another Apache log analizer.
#
# b) Use a custom webalizer.conf with the ability to use hostname
# related parameters.
#
# c) Use the same webalizer.conf for all domains or use different .conf
# files per domain (or even per subdomain). This also allows your own
# users to create the webalizer.conf file the way they wish.
#
#
# ======================================================================
# 2. INSTALLATION
# ======================================================================
#
# This installation procedure assumes you're logged in as root !!!
#
# 2.1. Create the file we will use to specify the domains we want to
# allow or deny using webalizer.
#
# cd /etc/virtual
# touch webalizer_domains
# chmod 660 webalizer_domains
#
# You should manually edit this file to add or remove domains.
#
# The syntax of the webalizer_domains file is pretty simple. You can
# specify a domain in each line. Blank lines are ignored. You can
# even use comments with the symbol #.
#
# You can customize the 'meaning' of the webalizer_domains file using
# the WEBALIZER_DEFAULT parameter in the custom webalizer script.
#
# WEBALIZER_DEFAULT="allow" means allow webalizer by default. So, you
# just use the webalizer_domains file to specify the domains that you
# want to deny from using webalizer.
#
# WEBALIZER_DEFAULT="deny" means deny webalizer by default. So, you
# just use the webalizer_domains file to specify the domains that you
# want to allow to use webalizer.
#
#
# 2.2. Replace the webalizer executable with this script.
#
# cd /usr/bin
# mv webalizer webalizer-orig
# wget [url]http://files.phpmix.com/directadmin/webalizer[/url]
# chmod 750 webalizer
# chown webalizer:root webalizer
#
#
# 2.3. Customize the custom webalizer script (this script).
#
# * Please, check out the 'Configuration Section'.
# * Specially the WEBALIZER_DEFAULT parameter.
#
#
# 2.4. Install the logrotate script for the new webalizer logs.
#
# cd /etc/logrotate.d
# wget -O webalizer [url]http://files.phpmix.com/directadmin/webalizer.logrotate[/url]
#
#
# 2.5. Customize your webalizer.conf files. Any of the following
# files is optional. It will be used only if it exists.
#
# The GLOBAL configuration file should be created here:
# /usr/local/directadmin/data/templates/webalizer.conf
#
# DOMAIN configuration files should be created here:
# /home/$USER/domains/$DOMAIN/stats/webalizer.conf
#
# SUBDOMAIN configuration files should be created here:
# /home/$USER/domains/$DOMAIN/stats/$SUBDOMAIN/webalizer.conf
#
# Note, you should replace $USER $DOMAIN and $SUBDOMAIN with valid
# values for your installation.
#
# In those .conf files you can use any of the following tokens:
# |HOSTNAME|
# |DOMAIN|
# |USER|
#
#
# And you're done!
#
# Please, check the chapter 1.3 in README section on how to execute
# webalizer to test the installation.
#
# Remember to check the webalizer_log if something seems to fail.
#
# ----------------------------------------------------------------------
#
# Copyright (c) 2005 Markus, phpmix.com
#
# Note that me nor phpmix.com have any affiliation with DirectAdmin.
#
# This script is released under the GNU GPL v2. You can find a copy of
# the license here: [url]http://www.gnu.org/copyleft/gpl.html[/url]
#
# THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTIES OR CONDITIONS
# OF ANY KIND, WHETHER ORAL OR WRITTEN, EXPRESS OR IMPLIED.
#
# ======================================================================
# CHANGELOG:
#
# version 1.0.0 (2005-01-11)
# - Added support for subdomains.
# - Added more and better documentation.
# - Added more information messages to the log (troubleshooting).
#
# version 0.0.1 (2005-01-08)
# - First attempt.
# - It does not support subdomains (yet).
# - It needs better documentation.
# - The idea sounds promising, though. ;-)
#
# ======================================================================
Last edited: