Beispiel #1
0
function multi_status()
{
    if (!is_file("/etc/mysql-multi.cnf")) {
        die;
    }
    if (system_is_overloaded(basename(__FILE__))) {
        writelogs("Fatal: Overloaded system Load:{$GLOBALS["SYSTEM_INTERNAL_LOAD"]} Memory: {$GLOBALS["SYSTEM_INTERNAL_MEMM"]}MB ,die()", "MAIN", __FILE__, __LINE__);
        die;
    }
    $ini = new iniFrameWork("/etc/mysql-multi.cnf");
    $INSTANCES = array();
    while (list($key, $line) = each($ini->_params)) {
        if (preg_match("#^mysqld([0-9]+)#", $key, $re)) {
            $instance_id = $re[1];
            $INSTANCES[$instance_id] = true;
        }
    }
    if (count($INSTANCES) == 0) {
        die;
    }
    $unix = new unix();
    $mysqlversion = mysqld_version();
    while (list($instance_id, $line) = each($INSTANCES)) {
        $master_pid = multi_get_pid($instance_id);
        $l[] = "[ARTICA_MYSQL:{$instance_id}]";
        $l[] = "service_name=APP_MYSQL_ARTICA";
        $l[] = "master_version={$mysqlversion}";
        $l[] = "service_cmd=mysql:{$instance_id}";
        $l[] = "service_disabled=1";
        $l[] = "watchdog_features=1";
        $l[] = "family=system";
        $status = $unix->PROCESS_STATUS($master_pid);
        if ($GLOBALS["VERBOSE"]) {
            echo "Mysqld status = {$status}\n";
            print_r($status);
        }
        if (!$unix->process_exists($master_pid)) {
            multi_start($instance_id);
            $l[] = "running=0";
        } else {
            $l[] = "running=1";
            $l[] = $unix->GetMemoriesOf($master_pid);
            $l[] = "";
        }
    }
    echo @implode("\n", $l);
}
Beispiel #2
0
function roundcube_db()
{
    $RoundCubeMySQLServiceType = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("RoundCubeMySQLServiceType");
    if (!is_numeric($RoundCubeMySQLServiceType)) {
        $RoundCubeMySQLServiceType = 1;
    }
    $RoundCubeDedicateMySQLServer = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("RoundCubeDedicateMySQLServer");
    if (!is_numeric($RoundCubeDedicateMySQLServer)) {
        $RoundCubeDedicateMySQLServer = 0;
    }
    if ($RoundCubeDedicateMySQLServer == 0) {
        return;
    }
    $pid_path = "/var/run/roundcube-db.pid";
    $master_pid = trim(@file_get_contents($pid_path));
    $l[] = "[APP_ROUNDCUBE_DB]";
    $l[] = "service_name=APP_ROUNDCUBE_DB";
    $l[] = "master_version=" . mysqld_version();
    $l[] = "service_cmd=/etc/init.d/roundcube-db";
    $l[] = "service_disabled={$RoundCubeDedicateMySQLServer}";
    $l[] = "family=mailbox";
    $l[] = "pid_path={$pid_path}";
    $l[] = "watchdog_features=1";
    if ($RoundCubeDedicateMySQLServer == 0) {
        return implode("\n", $l);
        return;
    }
    if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) {
        $mysqld = $GLOBALS["CLASS_UNIX"]->find_program("mysqld");
        $master_pid = $GLOBALS["CLASS_UNIX"]->PIDOF_PATTERN("{$mysqld}.*?--pid-file={$pid_path}");
    }
    if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) {
        if (!$GLOBALS["DISABLE_WATCHDOG"]) {
            $cmd = trim("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} " . dirname(__FILE__) . "/exec.roundcube-db.php --start >/dev/null 2>&1");
            shell_exec2($cmd);
        }
        $l[] = "running=0\ninstalled=1";
        $l[] = "";
        return implode("\n", $l);
        return;
    }
    $l[] = "running=1";
    $l[] = GetMemoriesOf($master_pid);
    $l[] = "";
    shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} /usr/share/artica-postfix/exec.roundcube-db.php --databasesize >/dev/null 2>&1 &");
    return implode("\n", $l);
    return;
}