The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

awstats not working (FIX IS HERE)

Discussion in 'General Discussion' started by vwiley1, Dec 11, 2004.

  1. vwiley1

    vwiley1 Well-Known Member

    Joined:
    Oct 4, 2003
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    6
    SECOND UPDATE: Ok.. I have FINALLY FIXED THE STATS PROBLEM!!!!! Here is a BIG shout out to the idiots at CPanel who didn't feel the need to let everyone know that STATS now have to be turned on. I don't know if this is for PRO only, so it may not of affected everyone. Anyhow..... I am sticking with the changes I made in both of my posts...because things are working now. Here is what probably did it for me though, and probably did not even need the changes below:
    In WHM, scroll all the way down to the bottom of the list on the left. Click on the link that says "Configure Statistics Software". Turn this feature ON....and then select all the stats to be ran...not just webalizer.

    EDIT: This post will not fix the stats that run automatically every 24 hours. The changes listed only make it so if you run ./scripts/runweblogs username and everything gets updated. I was really hoping that the below would fix the stats running every 24 hours, and to the best of my knowledge they should, but they don't. If anyone wants to dive even deeper into this mess, feel free... I am done for now though. For anyone wishing to try harder to get the problem fixed.... here is some extra info: While watching TOP when the stats are supposed to be auto updated I see webalizer run, then logrunner, then cpanellogd. Even though the code below fixes cpanellogd, awstats and analog are still not ran...webalizer is not even running from cpanellogd, webalizer runs before cpanellogd even does. Does anyone know the script that goes around checking to see how long it's been since stats have last been run? If someone tells me that I will look into that script to see how it's calling weblizer, and possibly write some code for everybody with problems so it runs awstats and analog from the same place..
    END OF EDIT

    Hi,

    This is not going to be very informative, but this should give you enough info on how to fix this yourself. If not, hopefully the nice people at CPanel will fix it, or someone on this board will write it out in clearer step by step instructions.

    Alright, Let's get started.. I have been drilling at this all day.

    First, the script "/script/runweblogs username" calls an external script called cpanellogd. However the script: /usr/local/cpanel/cpanellogd is broken :(


    This section of code is where the problem lies:

    if (!$skipawstats) {
    if (lc($LOG_CONF{"AWSTATS-".uc($domain)}) eq 'yes') {
    buildawconf($domain,$homedir,$waccess_log,$domain,@ALLDOMAINS);
    if ($statsloglevel >= 5) { print STLOG "[awstats] $user\n"; }
    $ENV{"AWSTATS_CONFIG"} = "$domain";
    logsystem("$root/bin/logrunner ${cpunum}.0 $root/3rdparty/bin/awstats.pl -config=${domain} -update 2>&1");
    delete $ENV{"AWSTATS_CONFIG"};
    }

    I am not exactly sure.... but I think this is checking to see if the AWSTATS configuration files exists. If it exists, then it executes the code to process the logfile for your domain.

    There are 4 problems though..

    1. I believe the filename it's checking for is WRONG, so it will never equal yes, therefore AWSTATS won't run.

    2. Why would you want to build the awstats configuration file if it already exists?

    3. There is no ELSE statement to run AWSTATS if the file doesn't exist.

    4. In the ELSE statement (that doesn't exist) it should build the configuration file and run AWSTATS.


    There are probably several fixes to the problem, I don't have the time to do CPanel's job though, so I found something that works for now. I am sure my way is not the best way, and I am hoping that somebody will come up with something better. Preferably CPanel, but if not hopefully someone on this board.

    Here are some possible fixes, further down you will find my fix:

    1. Make it check for the right file.
    2. Create an else statement so it knows what to do if the file doesn't exist.

    Ok now here's my fix, I only changed 2 letters in the code:

    if (lc($LOG_CONF{"AWSTATS-".uc($domain)}) eq 'yes') {

    Change this line to:

    if (lc($LOG_CONF{"AWSTATS-".uc($domain)}) ne 'yes') {

    What does that do??? In plain english, it's saying: If the configuration file does not exist, then run the code.

    My ANALOG stats also stopped the same day as my AWSTATS. And even with the above fix, AWSTATS won't run on sub-domains. I should have time within the next 24 hours to try and fix those problems as well.

    AGAIN... MY FIXES ARE NOT THE BEST METHOD. THE BEST METHOD WOULD BE CHECKING FOR THE RIGHT FILE, NOT BUILDING A NEW FILE IF ONE ALREADY EXISTS, AND CREATING AN ELSE STATEMENT IN CASE THE FILE DOESN'T EXIST.

    Someone want to write that?? CPanel Devs? Forum Members? I already did all the hard work of tracing down the problem, your job should be easy if your fluent in perl/cgi.

    Thanks for reading, hope this helps,

    Vince
     
    #1 vwiley1, Dec 11, 2004
    Last edited: Dec 12, 2004
  2. vwiley1

    vwiley1 Well-Known Member

    Joined:
    Oct 4, 2003
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    6
    SECOND UPDATE: Ok.. I have FINALLY FIXED THE STATS PROBLEM!!!!! Here is a BIG shout out to the idiots at CPanel who didn't feel the need to let everyone know that STATS now have to be turned on. I don't know if this is for PRO only, so it may not of affected everyone. Anyhow..... I am sticking with the changes I made in both of my posts...because things are working now. Here is what probably did it for me though, and probably did not even need the changes below:
    In WHM, scroll all the way down to the bottom of the list on the left. Click on the link that says "Configure Statistics Software". Turn this feature ON....and then select all the stats to be ran...not just webalizer.

    EDIT: This post will not fix the stats that run automatically every 24 hours. The changes listed only make it so if you run ./scripts/runweblogs username and everything gets updated. I was really hoping that the below would fix the stats running every 24 hours, and to the best of my knowledge they should, but they don't. If anyone wants to dive even deeper into this mess, feel free... I am done for now though. For anyone wishing to try harder to get the problem fixed.... here is some extra info: While watching TOP when the stats are supposed to be auto updated I see webalizer run, then logrunner, then cpanellogd. Even though the code below fixes cpanellogd, awstats and analog are still not ran...webalizer is not even running from cpanellogd, webalizer runs before cpanellogd even does. Does anyone know the script that goes around checking to see how long it's been since stats have last been run? If someone tells me that I will look into that script to see how it's calling weblizer, and possibly write some code for everybody with problems so it runs awstats and analog from the same place..
    END OF EDIT

    SUBDOMAIN & ADD-ON DOMAIN AWSTATS AND CHANGE IN THEORY

    Alright, I got my sub-domain AWSTATS working again! However, something weird is going on here. The code below uses the same if statement as the code in my previous post did. It looks for a configuration file "in the same format that the regular domain code does". However the problem is reversed.

    Here is the desired result of the code:
    The sub-domain/add-on domain code should loop through each domain on your account, and run stats for each one.

    Here is the code:

    foreach $ddomain (@ALLDOMAINS) {
    next if (lc($LOG_CONF{"AWSTATS-".uc($ddomain)}) ne 'yes'); # User config per domain..
    my($dwaccess_log) = find_wwwaccesslog($ddomain);
    if (-e $dwaccess_log) {
    if ($statsloglevel >= 5) { print STLOG "[awstats] $user [$ddomain]\n"; }
    if (! -e "$homedir/tmp/analog/${ddomain}") {
    mkdir("$homedir/tmp/analog/${ddomain}",0700);
    }
    buildawconf($ddomain,$homedir,$dwaccess_log,$ddomain,@ALLDOMAINS);
    $ENV{"AWSTATS_CONFIG"} = "$ddomain";
    logsystem("$root/bin/logrunner ${cpunum}.0 $root/3rdparty/bin/awstats.pl -config=${ddomain} -update 2>&1");
    delete $ENV{"AWSTATS_CONFIG"};
    }
    }

    What this code does, is checks to see if the configuration DOES NOT exist, if it does NOT exist then it does some useless stuff with ANALOG STATS???? (What are the devs thinking, this is the AWSTATS code) Then it builds a configuration file and runs the stats.

    Well that's all fine and dandy if the configuration file DOES NOT exist, but unfourtuantly almost everybody should already have the configuration file, and if they don't, after the stats run ONE TIME, the file will exist.

    Let's look at the problems with this code:

    1. First, it checks to see if the conf file DOES NOT exist... There is no ELSE statement to run the STATS if it DOES EXIST. In 99.9999% of all cases, the configuration file WILL exist (AND SHOULD EXIST) so sub-domain and add-on domain stats never run!!!

    2. What's the deal with adding code for ANALOG STATS in the AWSTATS code??

    3. The above code says if the file does exist, recreate it, and then run stats. What is the point of recreating this file if it's already there?

    4. Why is the IF statement actually working for the addtional domains code, and not the regular domain code in my previous post?

    For those of you who haven't figured it out yet.... This post kind of contradicts the previous post.

    For some reason, the line of code that has the If statement checking to see if the conf file exists or not actually works with the additional domain code, but not the main domain code in my previous post.

    My previous post shows the code for the main domain checks to see if the configuration file DOES Exist. But for some reason, with the previous post code, it can't seem to tell if this file really exists or not, so stats never ran. In this post though, for the sub-domain stat code, it checks to see if the file exists, and actually finds that it does, so it doesn't run stats.

    My question is WHY? I studied the code and the variables used in the code, and if ONE works, so should the other. This is definantly weird.

    Anyhow, I should be done rambling about this now, and if you are confused at this point just read what I did to fix it.


    First though, here is a warning: My fix is probably not the right way of doing things, in fact I know it's not.... but hey it works now, and it didn't before :) Hopefully someone will come along and write what you REALLY should do to fix this the proper way.

    Here's the fix:

    next if (lc($LOG_CONF{"AWSTATS-".uc($ddomain)}) ne 'yes');

    CHANGE THE ABOVE LINE OF CODE TO:

    next if (lc($LOG_CONF{"AWSTATS-".uc($ddomain)}) eq 'yes');


    What this little change does in plain english:
    It says If the configuration file DOES EXIST then to recreate the file??? and run the stats :)

    There is still one problem though.....what if the file DOES NOT EXIST. There is no ELSE statement that says create the file and run the stats. However..... this file should exist for all additional domains, except possibly if you were to add a new one. I don't know if this file is automatically created when a new domain or sub-domain is added to your cpanel account, if it's not, then stats won't run for those new add-ons or sub-domains :(

    As I said in my previous post... I already did the hard work of tracking this problem down, now would someone be so kind to write the proper fix for this?

    Thanks,

    Vince
     
    #2 vwiley1, Dec 11, 2004
    Last edited: Dec 12, 2004
  3. damainman

    damainman Well-Known Member

    Joined:
    Nov 13, 2003
    Messages:
    515
    Likes Received:
    0
    Trophy Points:
    16
    maybe you should open up a enhancement request or something in bugzilla and show this to cpanel ;)
     
  4. vwiley1

    vwiley1 Well-Known Member

    Joined:
    Oct 4, 2003
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    6
    If you have the Configure Stats link in your root WHM. (It will be the last link at the very bottom of the page) You can enable stats and they will start working again. It just pisses me off that they changed something I was using on my server without notifying me. I went through all the trouble of analyzing the scripts to figure out what was wrong, and I really didn't have to.

    Vince
     
  5. GOT

    GOT Get Proactive!

    Joined:
    Apr 8, 2003
    Messages:
    900
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Norfolk, VA
    cPanel Access Level:
    DataCenter Provider
    This is only an issue if you installed the stats select addon. If you install an addon, you should probably take a moment to look to see what needs configuring on it.
     
  6. vwiley1

    vwiley1 Well-Known Member

    Joined:
    Oct 4, 2003
    Messages:
    87
    Likes Received:
    0
    Trophy Points:
    6
    I have never installed this add-on that I remember.

    And Bailey, Just a Note, I don't know if my changes to the cpanellogd file had an effect on whether the stats selector works or not. I have not reversed my changes, and everything is working good.

    You might give it a try.
     
  7. tAzMaNiAc

    tAzMaNiAc Well-Known Member

    Joined:
    Feb 16, 2003
    Messages:
    559
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Sachse, TX
    Yall could have just installed AWStats externally. Pretty easy IMHO.

    AWStats i found to be having wrong statistics too as well, too low compared to the log file I perused. So I installed external and found out the hard way.

    I do not know what cpanel does differently, but I have the same version, and nearly same config file and my external awstats works better.

    One possible reason is:

    awstats usually needs the www. for the config file.

    awstats.www.yourdomain.com.conf

    cpanel makes them without the www. My external awstats does it with the www. and then the custom line for hostAliases:

    HostAliases="HostAliases="localhost 127.0.0.1 REGEX[yourdomain\.com$]""

    The HostAliases seemed to be missing for ours. weird.


    Brenden
     
    #7 tAzMaNiAc, Dec 14, 2004
    Last edited: Dec 14, 2004
Loading...

Share This Page