The hook itself is a small python script, which hooks into ‘Whostmgr:: Accounts:: Create’, reads the data from stdin to get information from the accounts getting created in cpanel, it generates a awstats config file in the users home directory, which will get loaded for that specific user.
By default cpanel doesn’t allow custom configuration for awstats, which means you need to log into WHM, go to ‘Statistics Software Configuration’ and enable ‘Awstats include file’.
When using cpanel as a control panel for shared hosting, you’re by default forced to use Apache. So I’ll show you how to make nginx support for cpanel awstats. The reason is that the normal awstats works perfectly, but because the stats for the domains is depending on how awstats and cpanel work together, cpanel have come up with a pretty bad way to handle the main configuration file for awstats.
The reason behind this is that it’s the most common webserver, but Apache is often using a lot of memory when you could lower this. Which results in, that it’s not possible to add your own log format in the main config, so it will work for all your domains.
Install AWStats Launch the AWStats setup file by double clicking on the executable that just has been downloaded. If you’re not using the Windows installer, you can find the script in the AWStats tools directory.
To execute it use (if location of is within your path environment):perl awstats_This is what the script does/asks (you can do all these steps manually instead of running awstats_(automatically launch by Windows installer) if you prefer): A) awstats_tries to determine your current log format from your Apache web server configuration file (it asks for the path if not found).
If you use a common log, awstats_will suggest changing it to the NCSA combined/XLF/ELF format (you can use your own custom log format but this predefined log format is often the best choice and makes setup easier).
Since we’re running nginx in front of Apache this means, it’s only the time spend in the proxy itself, so all dynamic processing will still be handled by apache. The code below is the hook you need to save to /opt/makeawstats/makeawstats.py: #!
/usr/bin/python import sys, os raw Data = sys.stdin.readlines() hookdata = eval(raw Data.replace(':null', ': None')) data = hookdata['data'] username = data['user'] if not exists('/home/%s/tmp/awstats' % username): os.makedirs('/home/%s/tmp/awstats' % username) f = open('/home/%s/tmp/awstats/include' % username, 'w') f.write('Log Format="%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot %extra1"\n') f.write('Extra Section Name1="Time to serve requests (seconds)"\n') f.write('Extra Section Code Filter1=""\n') f.write('Extra Section First Column Title1="Number of seconds to serve the request"\n') f.write('Extra Section First Column Values1="extra1,(.*)"\n') f.write('Extra Section Stat Types1="H"\n') f.write('Extra Tracked Rows Limit=100000\n') f.close() if exists('/home/%s/tmp/awstats' % username): os.system('chown -R %s:%s /home/%s/tmp/awstats' % (username, username, username)) The code reads stdin, replaces :null with : None.
Even a workaround would be an option to write a script that fetches all the users and their domains subdomains to I can execute awstats_with that script. Well, quick and dirty solution : add /usr/local/directadmin/scripts/awstats_USER DOMAIN to the daily cron job for each domain where it is important. is there a way to debut why the tally doesn't work and the manual awstat input works ?