Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Tips/Tricks/Mods

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 29th March 2009, 23:16
Mouton Mouton is offline
Junior Member
 
Join Date: Apr 2008
Posts: 10
Thanks: 0
Thanked 4 Times in 1 Post
Default ISPconfig 3 - awstats

I quickly wrote this small plugin to create awstats config file automatically (base on the ISPconfig 2 plugin)
It really needs improvement and automation but that's a start for whoever has time to write more about it...
Do not hesitate to improve or fix it....

PS: congrats for the 3.0.1 version !


Just paste the following code in a awstats_plugin.inc.php file in the plugins-available directory.


Code:
<?php

class awstats_plugin {

        var $plugin_name = 'awstats_plugin';
        var $class_name  = 'awstats_plugin';

        //* This function is called during ispconfig installation to determine
        //  if a symlink shall be created for this plugin.
        function onInstall() {
                global $conf;

                if(@$conf['services']['awstats'] == true) {
                        return true;
                } else {
                        return false;
                }

        }


        /*
                This function is called when the plugin is loaded
        */

        function onLoad() {
                global $app;

                /*
                Register for the events
                */

                //* Mail Domains
                $app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'domain_insert');
                $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'domain_update');
                $app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'domain_delete');
        }


        function user_insert($event_name,$data) {
                // TODO: handle users for awstats access
        }

        function user_update($event_name,$data) {
                // TODO: handle users for awstats access
        }

        function user_delete($event_name,$data) {
                // TODO: handle users for awstats access
        }

        function domain_update($event_name,$data) {
                global $app, $conf;

                $this->domain_insert($event_name, $data);
        }

        function domain_insert($event_name,$data) {
                global $app, $conf;

                if(!@is_file("/etc/awstats/awstats.".$data["new"]["domain"].".conf") || ($data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"])) {
                        if ( @is_file("/etc/awstats/awstats.".$data["old"]["domain"].".conf") )
                                 exec("rm -f /etc/awstats/awstats.".$data["old"]["domain"].".conf");

                        exec( "echo 'Include \"/etc/awstats/awstats.conf\"' > /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
                        exec( "echo 'LogFile=\"/var/log/ispconfig/httpd/".$data["new"]["domain"]."/access.log\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
                        exec( "echo 'SiteDomain=\"".$data["new"]["domain"]."\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf");
                        // exec( "echo 'AllowAccessFromWebToFollowingAuthenticatedUsers=\"".$ht_user_list."\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf");
                }

        }

        function domain_delete($event_name,$data) {
                global $app, $conf;

                if($data["old"]["domain"] != '' ) {
                        if ( @is_file("/etc/awstats/awstats.".$data["old"]["domain"].".conf") )
                                 exec("rm -f /etc/awstats/awstats.".$data["old"]["domain"].".conf");
                }
        }




} // end class
?>

Last edited by Mouton; 29th March 2009 at 23:19.
Reply With Quote
The Following 4 Users Say Thank You to Mouton For This Useful Post:
falko (30th March 2009), grungy (14th April 2009), Stown (7th July 2009), till (30th March 2009)
Sponsored Links
  #2  
Old 1st April 2009, 15:19
andypl andypl is offline
Member
 
Join Date: Mar 2006
Location: Radom, Poland
Posts: 93
Thanks: 1
Thanked 1 Time in 1 Post
Default

Ok i put this scripts in the plugins folder and how its works ?
I dont see any options on ISPConfig panel for awstats.
Reply With Quote
  #3  
Old 4th April 2009, 09:43
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,046
Thanks: 826
Thanked 5,389 Times in 4,234 Posts
Default

To enable the script you will have to create a symlink in the plugins-enabled folder to the plugin in the plugins-available folder like it is done for the other plugins. Afterwards you edit the file /usr/local/ispconfig/server/lib/config.inc.php and add the line:

$conf['services']['awstats'] = true;

Then the plugin should work. The author of the plugin may correct me if I missed an additional step as I did not tested the plugin yet. An of xourse the awstats package from your linux distribution has to be installed.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #4  
Old 5th April 2009, 22:42
Mouton Mouton is offline
Junior Member
 
Join Date: Apr 2008
Posts: 10
Thanks: 0
Thanked 4 Times in 1 Post
Default

Indeed, you'll need to install awstats first. Sadly, I do not have to to make any tutorial yet. I'll try but.

This plugin is only - for the moment -for generating awstats config for each ISPconfig 3 domain.

I'll work on the user htaccess restriction as soon as possible.
Reply With Quote
  #5  
Old 7th April 2009, 06:46
archerjd archerjd is offline
Member
 
Join Date: Dec 2006
Posts: 66
Thanks: 6
Thanked 6 Times in 6 Posts
Lightbulb

Quote:
Originally Posted by Mouton View Post
I'll work on the user htaccess restriction as soon as possible.
Hi Mounton,
It seems to me that the .htaccess file even though has been used for decades , is a little messy. Would mod-auth-mysql be a cleaner/better solution?

One thing we have to keep in mind is if a user account gets disabled for some oddball reason. The .htaccess file will have to be modified and then again when the account is re-enabled. I believe if my memory serves me right, mod-auth-mysql has a variable just for things like that and it gives you the ability to use the same user accounts within the dbispconfig database.

There are some conns to this. mod-auth-mysql requires basic authentication (plain text).
Also, you would have to add something like this to the vhost.conf.master file.
Code:
<tmpl_if name='awstats' op='==' value='y'
  <Directory <tmpl_var name='web_document_root_www'>/stats
    AuthBasicAuthoritative Off
    AuthUserFile /dev/null
    AuthMySQL On
    AuthName "AWstats Service"
    AuthType Basic
    Auth_MySQL_Host localhost
    Auth_MySQL_User ispconfig
    Auth_MySQL_Password <tmpl_var name='db_password'>
    AuthMySQL_DB dbispconfig
    AuthMySQL_Password_Table ftp_user
    Auth_MySQL_Username_Field username
    Auth_MySQL_Password_Field password
    Auth_MySQL_Group_Table ftp_user
    Auth_MySQL_Group_Field gid
    Auth_MySQL_Encryption_Types Crypt
    Auth_MySQL_Empty_Passwords Off
    Auth_MySQL_Authoritative On
    Auth_MySQL_Password_Clause " AND enabled=1"
    require group <tmpl_var name='system_group'>
  </Directory>
</tmpl_if>
__________________
The very powerful and the very stupid have one thing in common.
Instead of altering their views to fit the facts, they alter the facts
to fit their views ... which can be very uncomfortable if you happen to
be one of the facts that needs altering.

-- Doctor Who, "Face of Evil"

Last edited by archerjd; 7th April 2009 at 06:51.
Reply With Quote
  #6  
Old 7th April 2009, 16:01
Mouton Mouton is offline
Junior Member
 
Join Date: Apr 2008
Posts: 10
Thanks: 0
Thanked 4 Times in 1 Post
Default

Good idea.

I'm not sure, but mod-auth-mysql seems to have recent security issues as well as compatibility problems with apache 2.2 (not tested).
Maybe would it be better not to use a third party module but the mod_authn_dbd module ?
Reply With Quote
  #7  
Old 18th April 2009, 23:14
letezo letezo is offline
Junior Member
 
Join Date: Mar 2009
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Skype™ to letezo
Default Does anybody work on awstats support?

I've just installed the plugin. It creates the awstats config files for the domains, but it is far from working in its current state. Things need to do:
  • Cron task to update the statistics for each domain. The default cron script installed by the system uses only the awstats.conf file and hardwired to build stats from /var/log/apache/access.log only, so that is clearly not enough in our case.
  • Support for running awstats.pl without generally enabling CGI support for those domains. It can be protected by the same password as the Webalizer statistics. We have to provide a separate path for awstats. There should be a link from the Webalizer statistics to jump to awstats to help users.
  • New option for the Stats tab of the site in ISPConfig to enable/disable awstats for the domain.
  • Testing this on all the supported platforms.
Reply With Quote
  #8  
Old 18th April 2009, 23:51
letezo letezo is offline
Junior Member
 
Join Date: Mar 2009
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Skype™ to letezo
Default Updating statistics for multiple domains

I suggest moving the domain specific configuration files into a new directory like /etc/awstats/ispconfig or somewhere else. This directory should be created by the awstats plugin on installation or first use.

The Ubuntu 8.04 LTS distribution contains a script:
/usr/share/doc/awstats/awstats_updateall.pl

It can be configured (see the beginning of this file) to update the statistics for all the ISPConfig managed domains then.

Related topic, both for Webalizer and AWStats: We can enable GeoIP for them if we install the geoip-bin package and take care of downloading the free GeoIP Country database from MaxMind. I haven't tested this yet, however.
Reply With Quote
  #9  
Old 18th April 2009, 23:59
letezo letezo is offline
Junior Member
 
Join Date: Mar 2009
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Skype™ to letezo
Default

We have to place those config files directly under /etc/awstats, unfortunately. AWStats tries to load the config files for the virtual hosts from there.
Reply With Quote
  #10  
Old 19th April 2009, 00:19
letezo letezo is offline
Junior Member
 
Join Date: Mar 2009
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Skype™ to letezo
Default Perl warning

We have to avoid the following bug on Ubuntu 8.04 LTS:
http://www.mail-archive.com/debian-b...msg385558.html

Due to the above bug awstats.conf.local cannot be included from awstats.conf, since that would be a "nested" (three level deep) include. We can comment out the Include "/etc/awstats/awstats.conf.local" line at the end of awstats.conf and include that from each domain specific awstats config file. Or we can change awstats.conf directly, but that would be bad practice and might be nor so resilent to upgrades as we would want.
Reply With Quote
Reply

Bookmarks

Tags
awstats plugin

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ISPConfig 3.0.0.7 Beta released till General 78 24th December 2008 11:47
Cant update ispconfig and awstats install issue supervos Installation/Configuration 6 4th November 2007 10:12
ISPConfig 2.2.13 released till General 35 23rd July 2007 16:28
Another Awstats Configuration Thingy For ISPConfig asyadiqin Installation/Configuration 2 6th August 2006 13:20
SP-Server Setup - Ubuntu 5.10 "Breezy Badger" - Page 6 (changes) LuisC-SM HOWTO-Related Questions 0 21st April 2006 15:16


All times are GMT +2. The time now is 04:38.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.