Exemple #1
0
 static function getweb_usage($name, $customer_name, $oldtime, $newtime, $d)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $web_home = "{$sgbl->__path_httpd_root}";
     $log_path = "{$web_home}/{$name}/stats";
     $processedir = "{$sgbl->__path_customer_root}/{$customer_name}/__processed_stats/";
     lxfile_mkdir($processedir);
     $dir1 = "{$log_path}/";
     $files = lscandir_without_dot($dir1);
     $total = 0;
     foreach ($files as $file) {
         if (!strstr($file, "gz")) {
             $total += self::getEachwebfilequota("{$dir1}/{$file}", $oldtime, $newtime);
             $stat = stat("{$dir1}/{$file}");
             if ($stat['size'] >= 50 * 1024 * 1024) {
                 if (isOn($d->remove_processed_stats)) {
                     lxfile_rm("{$dir1}/{$file}");
                 } else {
                     lxfile_mv("{$dir1}/{$file}", getNotexistingFile($processedir, $file));
                 }
             }
         }
     }
     return $total;
 }
Exemple #2
0
function fixlogdir_main()
{
    global $gbl, $sgbl, $login, $ghtml;
    $progname = $sgbl->__var_program_name;
    $logl = lscandir_without_dot("../log");
    lxfile_mkdir("../processed_log");
    @lunlink("../log/access_log");
    @lunlink("/usr/local/lxlabs/ext/php/error.log");
    $dir = getNotexistingFile("../processed_log", "proccessed");
    system("mv ../log ../processed_log/{$dir}");
    mkdir("../log");
    $list = lscandir_without_dot("../processed_log");
    foreach ($list as $l) {
        remove_directory_if_older_than_a_day("../processed_log/{$l}", 6);
    }
    foreach ($logl as $l) {
        lxfile_touch("../log/{$l}");
    }
    lxfile_generic_chown_rec("../log", "lxlabs:lxlabs");
    //
    // Related to Issue #15
    //
    lxfile_generic_chmod_rec("../log", "0640");
    lxfile_generic_chmod_rec("../processed_log", "0640");
    lxfile_generic_chmod("../log", "0700");
    lxfile_generic_chmod("../processed_log", "0700");
    lxfile_generic_chmod("../log/lighttpd_error.log", "0644");
    lxfile_generic_chmod("../log/access_log", "0644");
    lxfile_generic_chown("../log/lighttpd_error.log", "lxlabs:root");
    lxfile_generic_chown("../log/access_log", "lxlabs:root");
    //
    os_restart_program();
}
 static function findTotalQuota($list, $oldtime, $newtime)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if (!isset($oldtime)) {
         return null;
     }
     $processfile = '/var/log/kloxo/pureftpd.log';
     $processedir = "/var/log/kloxo";
     foreach ($list as $d) {
         $tlist[$d] = self::getftp_usage($processfile, $d, $oldtime, $newtime);
     }
     $stat = stat($processfile);
     if ($stat['size'] >= 25 * 1024 * 1024) {
         lxfile_mv($processfile, getNotexistingFile($processedir, basename($processfile)));
     }
     return $tlist;
 }
 static function findTotaltrafficUsage($list, $oldtime, $newtime)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if (!isset($oldtime)) {
         return null;
     }
     $file = '/var/log/lxiptraffic.log';
     $processedir = "/var/log/";
     $processfile = $file;
     lxshell_return("__path_php_path", "../bin/sisinfoc.php");
     foreach ($list as $d) {
         $tlist[$d->nname] = self::get_usage($processfile, $d->vpsid, $oldtime, $newtime);
     }
     self::iptables_delete();
     self::iptables_delete();
     self::iptables_create();
     $stat = stat($file);
     if ($stat['size'] >= 10 * 1024 * 1024) {
         lxfile_mv($file, getNotexistingFile($processedir, basename($file)));
     }
     return $tlist;
 }
 static function findTotaltrafficUsage($list, $oldtime, $newtime)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if (!isset($oldtime)) {
         return null;
     }
     $file = '/var/log/lxinterfacetraffic.log';
     $processedir = "/var/log/";
     $processfile = $file;
     lxshell_return("__path_php_path", "../bin/common/iptraffic.php");
     $globaliplist = null;
     foreach ($list as $d) {
         foreach ($d->viflist as $iface) {
             $tlist[$d->nname] = self::get_usage($processfile, $iface, $oldtime, $newtime);
             $globalifacelist[] = $iface;
         }
     }
     lfile_put_contents("__path_program_etc/xeninterface.list", implode("\n", $globalifacelist));
     $stat = stat($file);
     if ($stat['size'] >= 10 * 1024 * 1024) {
         lxfile_mv($file, getNotexistingFile($processedir, basename($file)));
     }
     return $tlist;
 }
Exemple #6
0
 static function fixErrorLogbad($list)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $file = "/home/kloxo/httpd/lighttpd/error.log";
     $fp = lfopen($file);
     if (!$fp) {
         return;
     }
     while (!feof($fp)) {
         $s = fgets($fp);
         foreach ($list as $l) {
             if (csa($s, $l)) {
                 $out[$l] .= $s;
             }
         }
     }
     foreach ($out as $k => $v) {
         lfile_put_contents("/home/httpd/{$k}/stats/{$k}-error_log", $v, FILE_APPEND);
     }
     fclose($fp);
     $fp = getNotexistingFile(dirname($file), $file);
     lxfile_mv($file, $nfile);
 }
Exemple #7
0
 static function rotateLog($processedir, $file)
 {
     $stat = stat($file);
     if ($stat['size'] >= 10 * 1024 * 1024) {
         lxfile_mv($file, getNotexistingFile($processedir, basename($file)));
         createRestartFile("syslog");
     }
     $list = lscandir_without_dot($processedir);
     foreach ($list as $k) {
         $file = "{$processedir}/{$k}";
         $stat = stat($file);
         if ($stat['mtime'] < time() - 10 * 24 * 3600) {
             dprint("deleting old log {$file}\n");
             lxfile_rm($file);
         }
     }
 }