Webalizer lags two days

Discussion in 'General' started by TKoos, Nov 18, 2012.

  1. TKoos

    TKoos New Member

    Hi,

    I've a problem with Webalizer. The cron runs every night at 00:30. AFAIK that should mean that the current /stats always would include the day before.

    Mine does not. :-/ Today is 18 of nov. The stats however only counts up to the 16:th.

    Am I wrong, is this the expected behaviour?


    This is the webalizer part of cron_daily.php:

    Code:
    #######################################################################################################
    // Create webalizer statistics
    #######################################################################################################
    
    function setConfigVar( $filename, $varName, $varValue ) {
            if($lines = @file($filename)) {
                    $out = '';
                    $found = 0;
                    foreach($lines as $line) {
                            @list($key, $value) = preg_split('/[\t= ]+/', $line, 2);
                            if($key == $varName) {
                                    $out .= $varName.' '.$varValue."\n";
                                    $found = 1;
                            } else {
                                    $out .= $line;
                            }
                    }
                    if($found == 0) {
                            //* add \n if the last line does not end with \n or \r
                            if(substr($out,-1) != "\n" && substr($out,-1) != "\r") $out .= "\n";
                            //* add the new line at the end of the file
                            if($append == 1) $out .= $varName.' '.$varValue."\n";
                    }
    
                    file_put_contents($filename,$out);
            }
    }
    
    
    $sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE stats_type = 'webalizer' AND server_id = ".$conf['server_id'];
    $records = $app->db->queryAllRecords($sql);
    
    foreach($records as $rec) {
            //$yesterday = date('Ymd',time() - 86400);
            $yesterday = date('Ymd',strtotime("-1 day", time()));
            $logfile = escapeshellcmd($rec['document_root'].'/log/'.$yesterday.'-access.log');
            if(!@is_file($logfile)) {
                    $logfile = escapeshellcmd($rec['document_root'].'/log/'.$yesterday.'-access.log.gz');
                    if(!@is_file($logfile)) {
                            continue;
                    }
            }
    
            $domain = escapeshellcmd($rec['domain']);
            $statsdir = escapeshellcmd($rec['document_root'].'/web/stats');
            $webalizer = '/usr/bin/webalizer';
            $webalizer_conf_main = '/etc/webalizer/webalizer.conf';
            $webalizer_conf = escapeshellcmd($rec['document_root'].'/log/webalizer.conf');
    
            if(is_file($statsdir.'/index.php')) unlink($statsdir.'/index.php');
    
            if(!@is_file($webalizer_conf)) {
                    copy($webalizer_conf_main,$webalizer_conf);
            }
    
            if(@is_file($webalizer_conf)) {
                    setConfigVar($webalizer_conf, 'Incremental', 'yes');
                    setConfigVar($webalizer_conf, 'IncrementalName', $statsdir.'/webalizer.current');
                    setConfigVar($webalizer_conf, 'HistoryName', $statsdir.'/webalizer.hist');
            }
    
    
            if(!@is_dir($statsdir)) mkdir($statsdir);
            exec("$webalizer -c $webalizer_conf -n $domain -s $domain -r $domain -q -T -p -o $statsdir $logfile");
    }
    
     
  2. till

    till Super Moderator

    Most likely the timezone setting in /usr/local/ispconfig/server/lib/config.inc.php is wrong. Change it to match your timezone.
     
  3. TKoos

    TKoos New Member

    Hi! Thanks for your answer.

    When I accessed the correct server I found the TimeZone settings. :)

    However changing 'UTC' to 'UTC+1' was wrong, how should it be written?

    changed row:
    $conf['timezone'] = 'UTC+1';

    error message:
    PHP Notice: date_default_timezone_set(): Timezone ID 'UTC+1' is invalid in /usr/local/ispconfig/server/lib/app.inc.php on line 32
    finished.


    Best regards,

    TKoos


     
    Last edited: Nov 19, 2012
  4. till

    till Super Moderator

    The config.inc.php file contains a link to the timezone list in the comment of this setting were the names of all timezones available in php are listed.
     
  5. TKoos

    TKoos New Member

    Great! Now I've got it right.

    If anyone else has the same problem there is a list of the availble timezones here:
    http://www.php.net/manual/en/timezones.europe.php
     
  6. miguelal

    miguelal New Member

    Thanks for sharing. I had the same problem.

    But now how do I force webalizer to get up-to-date without waiting until tomorrow?
     
  7. orasis

    orasis New Member

    In my case I first used awstats for a site, then switched it to webalizer and it didn't like it, I had 'Internal Server Error' so I suspected it was an issue with the .htaccess file. Then I wiped out the /stats/ directory contents and recreated a password for the stats, having set 'webalizer'. It created the .htaccess and .htpasswd but not any index.php or index.html so I though, ok I will wait until tomorrow.

    Today is the tomorrow and nothing yet although I visited the site :D
    I think webalizer is problematic itself ?

    By the way, any chance of changing the default username from 'admin' to a custom one for the /stats/ directory without hacks ?
    I would also like the ability to move, choose a name for this directory, or disable stats completely in future versions if possible.
    cheers
     
    Last edited: Nov 6, 2013
  8. miguelal

    miguelal New Member

    In ISPConfig 2 there were 2 php scripts you ran to have the stats updated.

    Webalizer is a very solid and stable product. I've used it for a decade now. In fact I remember "back in the days" when I administered a single domain on a dedicated server without ISPConfig I did do a webalizer stat update through the command line. I suppose I'll Google-it.

    If I find something I'll post here.
     
  9. orasis

    orasis New Member

    you mean to force update huh ?

    hm ... I jsut tested again and I still get
    Code:
    Forbidden
    
    You don't have permission to access /stats/ on this server.
    
    .. cause it finds no index file inside... maybe I just broke it compeltely by deleting the directory contents !
     
    Last edited: Nov 6, 2013
  10. Croydon

    Croydon HowtoForge Supporter

    I think the index.php is generated when ispconfig runs it's daily cron.
    I'm not completely sure, but did the daily ispconfig cron already run since you deleted the directory?
     
  11. miguelal

    miguelal New Member

    You can delete the entire stats folder after that go into ISPConfig > Sites > Choose domain > redefine statistics password > Save. Wait a couple of minutes for the stats folder to be created.

    The stats folder will be created with appropriate permissions and at the next cron job exec it will fill with the desired stats.

    If you go to <domain>/stats BEFORE the cron job executes you will get a 403 error, because there is no index.html file - the stats folder is empty. Whenever I type a wrong password I get the internal error 500.
     
  12. orasis

    orasis New Member

    yes I believe the same too.
    please tell me which log should I check for this process ? I never used those stats before in ispconfig.
     
    Last edited: Nov 6, 2013
  13. orasis

    orasis New Member

    yeap and that is the correct setting for better security instead of displaying the directory listing.

    That was what was happening to me and I wiped the directory cause I suspected that switching back/forth from awstats to webalizer messed the files or the .htaccess or .passwd and indeed since I wiped it I can try wrong password and there is no error 500, I just get the 403 now :D

    that's some kind of progress isn't it ?
     

Share This Page