AWStats Plugin for DA [version 3.0+]

sullise

Verified User
Joined
Mar 4, 2004
Messages
519
New thread for my version of fusionctl's AWStats plugin updates.
---------------------------------------------------------------------------------

*** DISCONTINUED...NOW INCLUDED IN DIRECTADMIN ***

3.0.2 (1/8/2007)

- Added new script called movestats.php (in awstats/hooks directory). This is used when upgrading. Run this to move the awstats*.domain.tld.txt and dsncachelastupdate.domain.tld.txt files to the users /stats folder after running /hooks/alldomains.php.

- Fixed problem with users updating .htpasswd from their plugin options screen. Seems that .htpasswd was getting owned by root and uses couldn't update it. Now when awstats is turned on for a user, it will chown it to the user. For existing users, you'll need to go and fix this manually for now. I'll script it next update.

3.0.1

- Corrected url in /scripts/update.sh for retrieving current AWStats version (6.6). * minor update for new installs only *

3.0.0:

- Update.sh script grabs the latest AWStats build (currently 6.6) now instead of 6.5.

Previoiusly you had to edit the update script and make a change to the url, but I've permentantly fixed that

- Changed default location of users stats data.

It is now stored in /home/user/domains/domain.tld/stats folder. The config file will stay where it always has been in /etc/awstats. This means now that stats will count against your clients disk usage and on the plus side, be backed up by DA's normal processes. When moving a user to a new server, his stat data will follow him now. Only need to activate AWStats for that user on new server and do a normal AWStats install from the plugin in their User DA screen.

- Sets AllowToUpdateStatsFromBrowser=0 by default.

This prevents users from updating stats via web browser...more secure as this is one of the vuln that plagued AWS for a while in previous version.

- Set options that prevent users from displaying each others stats.

With previous versions you could use the "?config=domain.tld" parm to view other users stats, regardless if they had the directory password protected or not. Now the options are set to prevent his as long as the users /awstats directory is password protected. Thus the following was implimented.

- Automatically password protects users /awstats folder upon install.

Now when users do the install from the plugin, it will automatically password protect the folder and then prompt them to go change it in the tune stats option. It uses the same password for all new installs, but users are told to go change it. (I will probably modify this to create a random one in next version).

Upcoming changes:

- More options controls for both admin and user from within the plugin.
- Automatically update the directadmin_cron file to start collecting stats
- Automatically create the /usr/local/directadmin/scripts/custom/user_create_post.sh (if it does not exist)

Thus making it a one step install.

Let me know if their are any problems. And a big thanks to fusionicntl for his original work. I'm going to try and keep improving on his work and naturally, never a charge

INSTALL INSTRUCTIONS:
1) Install plugin via DA Plugin Manager:

http://www.capitalwebhost.net/daplugins/awstats.tar.gz

2) Install latest AWStats version:

> cd /usr/local/directadmin/plugins/awstats/update/
> ./update.sh


3) Setup to automatically add access for new accounts created in DA:

nano -w /usr/local/directadmin/scripts/custom/user_create_post.sh

insert the following:

#!/bin/sh
echo $username >> /usr/local/directadmin/plugins/awstats/hooks/permissions.txt

cntl-x to save

> chmod 755 /usr/local/directadmin/scripts/custom/user_create_post.sh


4) Add daily updates to Crontab:

nano -w /etc/cron.d/directadmin_cron

Replace :

10 0 * * * echo 'action=tally&value=all' >> /usr/local/directadmin/data/task.queue

With :

10 0 * * * root /usr/local/directadmin/plugins/awstats/hooks/cgi-bin/awstats_updateall.pl now -awstatsprog=/usr/local/directadmin/plugins/awstats/hooks/cgi-bin/awstats.pl && echo 'action=tally&value=all' >> /usr/local/directadmin/data/task.queue

cntl-x to save


5) Login to DA Admin panel and click on the AWSTATS plugin link and activate all existing users ( other then webadmin,admin, clamav, dovecot).

6) Optional:

This will install it on all users domains (without having to go into each acct and do it manually)

> cd /usr/local/directadmin/plugins/awstats/hooks
> ./alldomains.php

If you are usnig a version previous to 3.0.2, then run this:

> ./movestats.php

That will move all stats to the users /stats folders and be part of their normal backups for restore.
 
Last edited:
I have now cleaned up everything and installed this new plugin.
Again I get file not found error.

[root@server ~]# /usr/local/directadmin/plugins/awstats/update/update.sh
Checking for latest version<BR>
...
Updating to <BR>
Downloading <BR>
--23:58:06-- http://awstats.sourceforge.net/files/awstats-.tar.gz
=> `/usr/local/directadmin/plugins/awstats/update/awstats.tgz'
Resolving awstats.sourceforge.net... 66.35.250.209
Connecting to awstats.sourceforge.net|66.35.250.209|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
23:58:06 ERROR 404: Not Found.

Extracting<BR>

gzip: stdin: unexpected end of file
/bin/tar: Child returned status 1
/bin/tar: Error exit delayed from previous errors
Extracted.. now Updating<BR>
Awstats extracted in /usr/local/directadmin/plugins/awstats/update/awstats-<BR>
/usr/local/directadmin/plugins/awstats/update/update.sh: line 20: cd: /usr/local/directadmin/plugins/awstats/update/awstats-: No such file or directory
Copying awstas /usr/local/directadmin/plugins/awstats/update/awstats-/wwwroot/cgi-bin/awstats.pl to basedir
cp: cannot stat `/usr/local/directadmin/plugins/awstats/update/awstats-/wwwroot/cgi-bin/awstats.pl': No such file or directory

Warning: fopen(/usr/local/directadmin/plugins/awstats/hooks/cgi-bin/awstats.pl): failed to open stream: No such file or directory in /usr/local/directadmin/plugins/awstats/update/patch.php on line 3
<BR>ERROR can't open awstats.pl<BR>Patched..<BR>
cp: cannot stat `/usr/local/directadmin/plugins/awstats/update/awstats-/wwwroot/cgi-bin/lib': No such file or directory
cp: cannot stat `/usr/local/directadmin/plugins/awstats/update/awstats-/wwwroot/cgi-bin/lang': No such file or directory
cp: cannot stat `/usr/local/directadmin/plugins/awstats/update/awstats-/wwwroot/icon': No such file or directory
cp: cannot stat `/usr/local/directadmin/plugins/awstats/update/awstats-/wwwroot/cgi-bin/plugins': No such file or directory
Removing all temp. files<BR>
Updating all user files..<BR>

Done.. updated to <BR>
[root@server ~]#

I wonder why this is happening thanks.
 
Yeah I had the same, it doesn't get the correct version number...
 
Then you systems are not CentOS or Redhat..you running BFD?

[root@da01 update]# ./update.sh
Checking for latest version<BR>
...
Updating to 6.6<BR>
Downloading 6.6<BR>
--13:18:58-- http://awstats.sourceforge.net/files/awstats-6.6.tar.gz
=> `/usr/local/directadmin/plugins/awstats/update/awstats.tgz'
Resolving awstats.sourceforge.net... 66.35.250.209
Connecting to awstats.sourceforge.net|66.35.250.209|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1,084,101 (1.0M) [application/x-tar]

100%[======================================================================================================================>] 1,084,101 389.49K/s

13:19:01 (388.38 KB/s) - `/usr/local/directadmin/plugins/awstats/update/awstats.tgz' saved [1084101/1084101]

Try this from your root CLI and tell me what you get:

> wget http://awstats.sourceforge.net -Oawstats.ver -q

> echo `cat awstats.ver | egrep -e "http://prdownloads.sourceforge.net/awstats/awstats-(.){3,5}.tar.gz" -o | egrep -e "[0-9]{1,}\.[0-9]{1,}" -o`

It should return "6.6".
 
doh..nevermind...the url of the 6.6 changed and I never updated the package. *bangs head*

I'll repackage it today.

In the mean time in the /scripts/update.sh change:

VER=`cat awstats.ver | egrep -e "http://awstats.sourceforge.net/files/awstats-(.){3,5}.tar.gz" -o | egrep -e "[0-9]{1,}.[0-9]{1,}" -o`

to

VER=`cat awstats.ver | egrep -e "http://prdownloads.sourceforge.net/awstats/awstats-(.){3,5}.tar.gz" -o | egrep -e "[0-9]{1,}\.[0-9]{1,}" -o`

And rerun the script...

SOrry about that.
 
Hi Sean sorry for what :D

After all it was Christmas yesterday and you are helping us here.

take it easy and thanks for the fix. will install and let you know the result.

Thanks.
 
I should say WOW thank you. Installed and it works nicely.

@Sean I am on CentOS 4.4

Now the file downloads and installs flawlessly when update.sh is run from shell.

Thank you very much for this plugin.
 
Hi.
My system is CentOS 3.8

When a user is installing AwStats on his domain, this error show up:
-----------------------------------------------
Now (re-)creating your configuration file.
Warning: fopen(/etc/awstats/awstats.site.com.conf): failed to open stream: Permission denied in /usr/local/directadmin/plugins/awstats/user/index.html on line 109 Warning: fwrite(): supplied argument is not a valid stream resource in /usr/local/directadmin/plugins/awstats/user/index.html on line 117 Warning: fclose(): supplied argument is not a valid stream resource in /usr/local/directadmin/plugins/awstats/user/index.html on line 118
------------------------------------------------
 
Works nice now!

I wonder if you still have to add awstats to a cronjob or is this done automaticly?

"update now" isn't there anymore? How can I update the stats manually?
 
Cybex said:
Works nice now!

I wonder if you still have to add awstats to a cronjob or is this done automaticly?

"update now" isn't there anymore? How can I update the stats manually?

Yes, you still have to add it to the crontab to update. There is also a reason for Update from Web being disabled....it's a major security hole. The whole point of this install it to make AWStats (well know for being exploited) as secure as possible.

My normal install steps for new installations:

1) Install plugin via DA Plugin Manager:
Plugin url: http://www.capitalwebhost.net/daplugins/awstats.tar.gz


2) Install latest AWStats version:
cd /usr/local/directadmin/plugins/awstats/update/
./update.sh



3) Setup to automatically add access to new accounts:
nano -w /usr/local/directadmin/scripts/custom/user_create_post.sh
insert :
#!/bin/sh
echo $username >> /usr/local/directadmin/plugins/awstats/hooks/permissions.txt
cntl-x to save
chmod 755 /usr/local/directadmin/scripts/custom/user_create_post.sh
Note: You can also SCP an edited version from another server to speed up multi-server installs



4) Add daily updates to Crontab:
nano -w /etc/cron.d/directadmin_cron
Replace :
10 0 * * * echo 'action=tally&value=all' >> /usr/local/directadmin/data/task.queue
With :
10 0 * * * root /usr/local/directadmin/plugins/awstats/hooks/cgi-bin/awstats_updateall.pl now -awstatsprog=/usr/local/directadmin/plugins/awstats/hooks/cgi-bin/awstats.pl && echo 'action=tally&value=all' >> /usr/local/directadmin/data/task.queue
cntl-x to save


5) Login to DA Admin panel and click on the AWSTATS plugin link and activate all existing users ( other then webadmin,admin, clamav, dovecot).

If you really want to turn on Update from Web...before activating this for any users in step 5, do this.

nano -w /usr/local/directadmin/plugins/awstats/hooks/cgi-bin/awstats.none.conf

Cntl-\

change: AllowToUpdateStatsFromBrowser=0
to: AllowToUpdateStatsFromBrowser=1

Cntl-x to save

If you want to turn on Web Update for specific users...edit /etc/awstats/awstats.domain.tld.conf and do same. But I'd suggest that you make darn sure they have thier stats directory password protected at a minimum.
 
I have some problem with awstats cron, followed Sean's instructions exactly as said. I also confirm that crond is running(checked cron log as DA admin and cron is performing all other tasks except this awstats)

My DA cron file is as below.

update

I have solved the cron problem by going through the file byte by byte there was an extracharecter $ to awstats.pl$ I think the $sign was added due to my cutting and pasting the longer line in nano editor in putty :)

This problem has nothing to do with this plugin and it works great.

Thanks.
 
Last edited:
the change password function does not appear to be working on my test box.
 
Installed according the install instructions..

First removed 2.19 then installed 3.01..

Working like a charm.
 
can someone post the solution for "Error: Couldn't open server log file..." during stats update from web...3.0.1
 
LetsFly said:
can someone post the solution for "Error: Couldn't open server log file..." during stats update from web...3.0.1

Since 3.0.1 has that feature disabled, that means you must have either modified the config files or attempting to do something that is outside the normal install procedures.

3.0.1 is specifically designed NOT to allow Update From Web for obvious security reasons...it's the most exploitable feature of AWStats.

- Proper security of AWStats includes turning that feature off and password protecting the AWStats directory. If anyone disables those features, well, don't cry to me if you get exploited. ;)
 
Back
Top