Example #1
0
function scan()
{
    if (system_is_overloaded(basename(__FILE__))) {
        apache_admin_mysql(0, "Overloaded system, retry next time....", null, __FILE__, __LINE__);
        return;
    }
    $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pidFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    $pid = $unix->get_pid_from_file($pidFile);
    if ($unix->process_exists($pid)) {
        events("A process, {$pid} Already exists...");
        return;
    }
    $GLOBALS["MYHOSTNAME_PROXY"] = $unix->hostname_g();
    @file_put_contents($pidFile, getmypid());
    $time = $unix->file_time_min($pidtime);
    if (!$GLOBALS["VERBOSE"]) {
        if ($time < 5) {
            events("{$time}mn, require minimal 5mn");
            return;
        }
    }
    $q = new mysql_squid_builder();
    $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `dashboard_apache_sizes` ( `TIME` DATETIME,\n\t\t\t`zmd5` VARCHAR(90) NOT NULL PRIMARY KEY,\n\t\t\t`SITENAME` VARCHAR(128),\n\t\t\t`SIZE` BIGINT UNSIGNED, `RQS` BIGINT UNSIGNED,\n\t\t\tKEY `TIME` (`TIME`),\n\t\t\tKEY `SIZE` (`SIZE`),\n\t\t\tKEY `RQS` (`RQS`)\n\t\t\t) ENGINE=MYISAM;");
    if (!$q->ok) {
        apache_admin_mysql(0, "Fatal MySQL error", $q->mysql_error, __FILE__, __LINE__);
        return;
    }
    if (!is_file("/home/apache/artica-stats/requests.log")) {
        echo "/home/apache/artica-stats/requests.log no such file...\n";
        return;
    }
    @mkdir("/home/apache/artica-stats/works", 0755, true);
    if (is_file("/home/apache/artica-stats/works/apache.log")) {
        echo "Parse /home/apache/artica-stats/works/apache.log\n";
        Parse("/home/apache/artica-stats/works/apache.log");
        return;
    }
    if (!@copy("/home/apache/artica-stats/requests.log", "/home/apache/artica-stats/works/apache.log")) {
        echo "Copy failed\n";
        return;
    }
    if (!is_file("/home/apache/artica-stats/works/apache.log")) {
        echo "/home/apache/artica-stats/works/apache.log no such file...\n";
        return;
    }
    @unlink("/home/apache/artica-stats/requests.log");
    echo "Parse /home/apache/artica-stats/works/apache.log\n";
    Parse("/home/apache/artica-stats/works/apache.log");
    CLEAN_MYSQL();
}
function scan()
{
    $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pidFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    $pid = $unix->get_pid_from_file($pidFile);
    if ($unix->process_exists($pid)) {
        events("A process, {$pid} Already exists...");
        return;
    }
    $GLOBALS["MYHOSTNAME_PROXY"] = $unix->hostname_g();
    @file_put_contents($pidFile, getmypid());
    $time = $unix->file_time_min($pidtime);
    if (!$GLOBALS["VERBOSE"]) {
        if ($time < 5) {
            events("{$time}mn, require at lease 5mn");
            return;
        }
    }
    @chmod("/home/artica/squid/realtime-events", 0755);
    @chown("/home/artica/squid/realtime-events", "squid");
    @chgrp("/home/artica/squid/realtime-events", "squid");
    @file_put_contents($pidtime, time());
    events("Running MAIN_SIZE_BACKUP()");
    MAIN_SIZE_BACKUP();
    events("Running CACHED_BACKUP()");
    CACHED_BACKUP();
    events("Running NO_CACHED_BACKUP()");
    NO_CACHED_BACKUP();
    events("Running ACCESS_LOG_HOURLY_BACKUP()");
    ACCESS_LOG_HOURLY_BACKUP();
    events("Running UFDB_LOG_HOURLY_BACKUP()");
    UFDB_LOG_HOURLY_BACKUP();
    events("Running VOLUME_LOG_HOURLY_BACKUP()");
    VOLUME_LOG_HOURLY_BACKUP();
    events("Running ROTATE()");
    ROTATE();
    events("Running CLEAN_MYSQL()");
    CLEAN_MYSQL();
}