Disable Webalizer on certain accounts

This can not be done through DirectAdmin. You would have to setup webalizer which domains to process and which to not process. By default it does them all.
 
techmonkey said:
Do you know how I would disable webalizer completely?
*this could/will break DA possibly*
Just edit the template your customers are using, than also delete the /home/<user>/stats dir ;). That way, you're sure it can't run, although it will most likely break DA.
(I'm not responsible if you actually delete the stats dir, but you could modify the skin to hide webalizer stats).
 
I'm fairly sure that eliminating the directory would NOT break DA.

But it wouldn't stop Webalizer from spending resources on updating the stats; it would just keep them from being output anywhere.

Jeff
 
So, any other suggestions to disable Webalizer? It's a waste of resources when we use a different stats package =/
 
Just an idea:

Rename the webalizer executable:

cd /usr/bin
mv webalizer webalizer-orig


Then create a special webalizer script that will parse the command line to get the domain name, and depending on if you want webalizer stats for the specified domain: a) exit b) call webalizer-orig

The new /usr/bin/webalizer script could look like:
Code:
#! /bin/bash

#
# Parse the command line to get the domain...
#
DOMAIN=""
while [ $# -ge 1 ]; do
        if [ "$1" = "-n" ]; then
                shift
                DOMAIN="$1"
        fi
        shift
done
if [ "$DOMAIN" = "" ]; then
        DOMAIN=`hostname`
fi

#
# If we don't want webalizer stats for this domain, just exit...
#
if [ "$DOMAIN" = "example1.com" ]; then
        exit 0
fi

#
# Finally, run the original webalizer executable...
#
/usr/bin/webalizer-orig $*
...or something like that.
 
markus said:
...or something like that.
Is webalizer now called domain by domain?

Wouldn't this require a rather complex script to determine for which domains webalizer is called?

Wouldn't we be better with a file somewhere (see, for example, how I created files to select spamblocking by exim.conf) of the domains we wanted webalizer run for, and use your control script to run webalizer just for those domains?

Why don't you try your code and tell us how it works :) .

Jeff
 
Jeff, do you like this idea?

Create two files under /etc/virtual with the following names: webalizer_allow and webalizer_deny

So, one can enter lines like this:

vi webalizer_allow
i
*
:x

That would mean all domains are allowed to process the webalizer script.

vi webalizer_deny
i
example1.com
example2.com
:x

That would mean we do not want to process the webalizer process for domains listed. example1.com and example2.com in this case.

The files webalizer_allow and webalizer_deny would have to be manually maintained, though.

Then, the "new custom" webalizer script just have to parse those files to apply the rules and exit or proceed by calling webalizer-orig.

Is there an easier way to deal with that?
 
I'd think the easiest way would be to use only one, whether it be webmail_allow or webmail_deny (or something similar); I don't see any reason to have both.

Have you or anyone tested the script? Do you know that it will work as intended?

Jeff
 
Yes, I do.

This is what I'm already running without problems:

Code:
#! /bin/bash

# As of v 1.23.3 DirectAdmin calls this script as follows:
# webalizer -p \
#	-n |DOMAIN| \
#	-o /home/|USER|/domains/|DOMAIN|/stats  \
#	/var/log/httpd/domains/|DOMAIN|.log
#
# we get the args from $* and get the current domain from there.
#
# we also generate our webalizer.conf on the fly :-)
#
# The argument --extra-args could be used to include new commands to
# our own custom webalizer.conf (useful only for testing).
#

#
# Parse command line arguments...
#
DOMAIN=""
DA_ARGS=""
EXTRA_ARGS=""
while [ $# -ge 1 ]; do
	if [ "$1" = "-n" ]; then
		shift
		DOMAIN="$1"
		DA_ARGS="$DA_ARGS -n $1"
	elif [ "$1" = "--extra-arg" ]; then
		shift
		EXTRA_ARGS="$EXTRA_ARGS
$1"
	else
		DA_ARGS="$DA_ARGS $1"
	fi
	shift
done
if [ "$DOMAIN" = "" ]; then
	DOMAIN=`hostname`
fi

#
# Create a temporary configuration file...
#
TMP_CONF_FILE="/tmp/webalizer.$DOMAIN"

cat > $TMP_CONF_FILE <<END_OF_TEXT
GMTTime		yes
VisitTimeout	1800
DNSCache	/var/www/usage/dns_cache.db
DNSChildren	10

PageType	htm*
PageType	cgi
PageType	txt
PageType	*html
PageType	php*
PageType	asp*
PageType	pl

HideURL		*.gif
HideURL		*.GIF
HideURL		*.jpg
HideURL		*.JPG
HideURL		*.png
HideURL		*.PNG
HideURL		*.ra

TopAgents	30
AllAgents		yes
TopCountries	30
TopReferrers	30
AllReferrers	yes
TopSites		30
TopKSites		20
AllSites		yes
TopURLs		30
TopKURLs		20
AllURLs		yes
TopEntry		30
TopExit		30
TopSearch	20
AllSearchStr	yes
TopUsers		0
AllUsers		no

IgnoreSite	*$DOMAIN
IgnoreSite	localhost
IgnoreReferrer	*$DOMAIN/*
HideReferrer	Direct Request
$EXTRA_ARGS
END_OF_TEXT
#
# Launch the 'real' webalizer. Please, check out the webalizer's README ;-)
#
/usr/bin/webalizer-orig -c $TMP_CONF_FILE $DA_ARGS

#
# Remove the temporary configuration file...
#
if [ -f $TMP_CONF_FILE ]; then
#	cat $TMP_CONF_FILE
	rm -f $TMP_CONF_FILE
fi

I have modified the format of the homedir.log to combined (it was a custom DA format called homedir). That way I'm also able to run the 00webalizer cronjob against the default website on the server. My 00webalizer cron looks like this:
Code:
#! /bin/bash
# update access statistics for the web site

if [ -s /var/log/httpd/homedir.log ] ; then
	/usr/bin/webalizer -p -n server.example.com -o /var/www/usage /var/log/httpd/homedir.log
fi

exit 0

I've been thinking to also add the ability to use different webalizer.conf files per domain. It would work like this: It will check if exists the file /home/|USER|/domains/|DOMAIN|/stats/webalizer.conf, if so use it. If not, then use the default (built in the custom webalizer script itself, like the above example).

I'll try to add the ability to allow/deny domains too and post a new topic in the HowTo forum.
 
Back
Top