log files, rotation and emailing them

Discussion in 'General' started by hairydog2, Nov 25, 2005.

  1. hairydog2

    hairydog2 Member

    Will do, but I can't do it till this evening. Thanks for your help.
     
  2. hairydog2

    hairydog2 Member

    Well, I seem to have found a problem: it is something to do with the localhost directory.

    Localhost is a directory, not a symlink, and I've tried renaming it to web0 and then putting a symlink called localhost, but that failed.

    I've tried removing the localhost directory, but it comes back again.

    The script goes through dozens of lines, then gets to

    /home/www/localhost
    Warning: readlink(): Invalid argument in /root/ispconfig/scripts/shell/logs.php on line 126
     
  3. falko

    falko Super Moderator Howtoforge Staff

    Do you need the localhost directory? If not, remove it or move it to another directory.
     
  4. falko

    falko Super Moderator Howtoforge Staff

    I've just seen this... Can you identify the process/program/application that creates this localhost directory?
     
  5. hairydog2

    hairydog2 Member

    I'm pretty sure it is Apache2.

    At the top of
    /etc/apache2/vhosts/Vhosts_ispconfig.conf

    there is an entry that says:
    NameVirtualHost 80.68.93.11:80
    <VirtualHost 80.68.93.11:80>
    ServerName localhost
    ServerAdmin root@localhost
    DocumentRoot /var/www/sharedip
    </VirtualHost>

    I tried remming it out with # marks, then restarting Apache, but my # marks got wiped out again.
     
  6. hairydog2

    hairydog2 Member

    It was apache2. I shut it down and then deleted the directory localhost. Then I made a directory called web0 and then did

    ln -s web0 localhost

    Restarted apache2 and tried running the script - and it didn't fail!

    Of course, when the second (webalyzer) script runs, it throws loads of errors to do wth there being no group for web0.

    Now all I need to do is to stop ispconfig putting the localhost entry into the config file
     
    Last edited: Jan 25, 2006
  7. hairydog2

    hairydog2 Member

    Hmm. Although webalyzer did run, it threw an error.

    Warning: array_merge(): Argument #1 is not an array in /root/ispconfig/scripts/shell/webalizer.php on line 1
    61


    and sometimes

    Warning: array_merge(): Argument #2 is not an array in /root/ispconfig/scripts/shell/webalizer.php on line 1
    61


    This seemed to be repeated for each website. Line 161 of that file says

    if (is_dir($dir."/".$filename)) $directory_array = array_merge($directory_array, dir_array($dir."/".$filename));

    I notice that one site, which is set "Options | Logsize: 40" still has a big log file. It is currently at "432M" according to ISPConfig Stats, and 440914KB according to my ftp program.

    I really do need thse logs to be trimmed each day!
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    ISPConfig is not creating a localhost directory, I've never seen this directory in any ISPConfig installation before. Did you create localhost as website or Co-Domain in ISPConfig?

    To you logsize problem. If the log and webalizer script cant run until the end, the logfiles wont get trimmed.
     
  9. hairydog2

    hairydog2 Member

    I'm getting nearer the answer. All the entries in the log for localhost are hacking attempts: the usual stuff, but I've now realised that the directory is being created by the log splitting script - because there are failed attempts to access "localhost" in the log.

    I'm not sure how to get round this.

    Workaround I'm trying as I type:

    1. Create a directory called web0 containing log/2006/01
    2. Create a symlink called localhost
    3. Run the logs.psp script
    4. Delete the step 1 and 2 objects
    5. Run the webalize.php script

    So far, it is working.
     
    Last edited: Jan 25, 2006
  10. hairydog2

    hairydog2 Member

    No, it still failed. Lots of:

    Warning: array_merge(): Argument #1 is not an array in /root/ispconfig/scripts/shell/webalizer.php on line 161

    Warning: array_merge(): Argument #1 is not an array in /root/ispconfig/scripts/shell/webalizer.php on line 161

    Warning: array_merge(): Argument #1 is not an array in /root/ispconfig/scripts/shell/webalizer.php on line 161

    Warning: array_merge(): Argument #2 is not an array in /root/ispconfig/scripts/shell/webalizer.php on line 161


    errors on the console. Still no sign of the localhost directory reappearing.

    :confused:
     
  11. falko

    falko Super Moderator Howtoforge Staff

    Please put this right before line 161 in the webalizer.php script:
    PHP:
    print_r($directory_array)."\n";
    print_r(dir_array($dir."/".$filename))."\n";
    so it reads:

    PHP:
    ...
    function 
    dir_array($dir){
      if (
    $dirstream = @opendir($dir)) {
        while (
    false !== ($filename readdir($dirstream))) {
          if (
    $filename!="." && $filename!=".."){
            if (
    is_file($dir."/".$filename) && !is_link($dir."/".$filename)){
              
    $directory_array[$dir."/".$filename] = filemtime($dir."/".$filename);
            }
            
    print_r($directory_array)."\n";
            
    print_r(dir_array($dir."/".$filename))."\n";
            if (
    is_dir($dir."/".$filename)) $directory_array array_merge($directory_arraydir_array($dir."/".$filename));
          }
        }
      }
      
    closedir($dirstream);
      
    clearstatcache();
      return 
    $directory_array;
    }
    ...
    Then run the script again. What's the output?
     
  12. hairydog2

    hairydog2 Member

    Ran it once, and got loads of errors. I ran it again, this time after removing the localhost link and web0 directory, and got far fewer errors:

    [/home/www/web49/log/2006/01/web.log] => 1138299739
    )

    Warning: closedir(): supplied argument is not a valid Directory resource in /root/ispconfig/scripts/shell/webalizer.php on line 167

    Warning: array_merge(): Argument #1 is not an array in /root/ispconfig/scripts/shell/webalizer.php on line 163

    Warning: array_merge(): Argument #1 is not an array in /root/ispconfig/scripts/shell/webalizer.php on line 163

    Warning: array_merge(): Argument #2 is not an array in /root/ispconfig/scripts/shell/webalizer.php on line 163


    But the log files are still much bigger than they should be, so it isn't trimming them.
     
    Last edited: Jan 28, 2006
  13. hairydog2

    hairydog2 Member

    Any ideas?
     
  14. falko

    falko Super Moderator Howtoforge Staff

    Can you find out which arguments are given to the array_merge function in /root/ispconfig/scripts/shell/webalizer.php on line 163? You can do this by using print_r() statements.
     
  15. hairydog2

    hairydog2 Member

    I'm not sure that I can.

    Line 163 is what was line 161 before I put in the two lines you suggested. I'd have thought that these would have already told us the arguments, but they don't seem to do that.

    If there is another print_r() line I could usefully add, I'm happy to try it!
     
  16. hairydog2

    hairydog2 Member

    With luck, this will now be less of an urgent issue. I can delete all the January logs, so I'll get some space back.
     
  17. ddelbia

    ddelbia Member

    I have the same problem, I had to gzip January log to free space.
    I defined log size with a maximum of 30%, as default.
     
  18. hairydog2

    hairydog2 Member

    I'm using logrotate and cron to try and keep logs under control. I deleted January manually.
     
  19. Ovidiu

    Ovidiu Active Member

    I tried modifying the webalizer.php like described above and here are the more detailed errors:

    any ideas what I can do to recover / process those logs?
     
  20. hairydog2

    hairydog2 Member

    As far as I recall, the basic problem I was having was that requests for unknown domains were beng split out to a localhost log directory. I think I got round this by creating a localhost directory that isn't under the www directory tree and putting a symlink to that instead of the localhost directory.

    That means that the logfile splitting process has somewhere to put the logs, but the webalizer process doesn't look at the results. It seems to work for me, but I can't access the site from where I am today, so I'm writing from hazy memory.
     

Share This Page