Beispiel #1
0
function CLIENT_REMOUNT_FOLDERS()
{
    $unix = new unix();
    $mount = $unix->find_program("umount");
    $glfs = new gluster_client();
    $array = $glfs->get_mounted();
    if (is_array($array)) {
        while (list($index, $volfile) = each($array)) {
            echo "Stopping Gluster client......: " . $volfile . "\n";
            shell_exec("umount -l {$volfile}");
        }
    } else {
        echo "Stopping Gluster client......: no mounted path\n";
    }
    MASTERS_GET_SOURCES();
    CLIENT_MOUNT_FOLDERS();
}
Beispiel #2
0
function paths_list()
{
    $gls = new gluster_client();
    $array = $gls->implode_bricks();
    if (!is_array($array)) {
        return null;
    }
    $html = "\n\t\n\t<table class=tableView>\n\t<thead class=thead>\n\t<tr>\n\t\t<th colspan=3>{mounted_cluster_folders}</th>\n\t</tr>\n\t</thead>\n\t";
    $sock = new sockets();
    while (list($path, $arrays) = each($array)) {
        $path_encoded = base64_encode($path);
        $ok = "ok24.png";
        $mounted = $sock->getFrameWork("cmd.php?glfs-is-mounted={$path_encoded}");
        if ($mounted != 1) {
            $ok = "danger24.png";
        }
        if ($cl == "oddRow") {
            $cl = null;
        } else {
            $cl = "oddRow";
        }
        $html = $html . "<tr class={$cl}>\n\t\t<td width=1%><img src='img/{$ok}'></td>\n\t\t<td><code style='font-size:12px'>{$path}</td>\n\t\t<td>" . explode_paths($arrays) . "</td>\n\t\t</tr>\n\t\t";
    }
    $html = $html . "</table>";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
Beispiel #3
0
function probes()
{
    $array = array();
    $unix = new unix();
    $gluster = $unix->find_program("gluster");
    $q = new mysql();
    $results = $q->QUERY_SQL("SELECT client_ip,hostname FROM glusters_clients WHERE LENGTH(uuid)=0 AND NotifToDelete=0", "artica_backup");
    if ($GLOBALS["VERBOSE"]) {
        echo "SELECT client_ip,hostname FROM glusters_clients WHERE LENGTH(uuid)=0 = " . mysql_num_rows($results) . " rows\n";
    }
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Probe {$ligne["client_ip"]}\n";
        }
        if ($ligne["client_ip"] != null) {
            $results2 = array();
            exec("{$gluster} peer probe {$ligne["client_ip"]} 2>&1", $results2);
            if (preg_match("#is already part of another cluster#", $results2[0])) {
                $glusterClass = new gluster_client($ligne["client_ip"]);
                $glusterClass->state = "WARN: is already part of another cluster";
                $glusterClass->edit_client();
            }
            system_admin_events("Probe {$ligne["client_ip"]}:\n" . @implode("\n", $results2), __FUNCTION__, __FILE__, __LINE__, "clusters");
            continue;
        }
    }
    $q = new mysql();
    $results = $q->QUERY_SQL("SELECT client_ip,hostname FROM glusters_clients WHERE NotifToDelete=1", "artica_backup");
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "detach {$ligne["client_ip"]}/{$ligne["hostname"]}\n";
        }
        if ($ligne["client_ip"] != null) {
            $results2 = array();
            exec("{$gluster} peer detach {$ligne["client_ip"]} 2>&1", $results2);
            if (preg_match("#is not part of cluster#i", $results2[0])) {
                $glusterClass = new gluster_client($ligne["client_ip"]);
                $glusterClass->remove();
            }
            if (preg_match("#successful#i", $results2[0])) {
                $glusterClass = new gluster_client($ligne["client_ip"]);
                $glusterClass->remove();
            }
            if (preg_match("#exist in cluster#", $results2[0])) {
                $glusterClass = new gluster_client($ligne["client_ip"]);
                $glusterClass->state = "WARN: {$results2[0]}";
                $glusterClass->edit_client();
                $NOSTATUS[$ligne["client_ip"]] = true;
                continue;
            }
            if (preg_match("#is probably down#", $results2[0])) {
                $glusterClass = new gluster_client($ligne["client_ip"]);
                $glusterClass->state = "WARN: {$results2[0]}";
                $glusterClass->edit_client();
                $NOSTATUS[$ligne["client_ip"]] = true;
                continue;
            }
            system_admin_events("detach {$ligne["client_ip"]}:\n" . @implode("\n", $results2), __FUNCTION__, __FILE__, __LINE__, "clusters");
            continue;
        }
    }
    exec("{$gluster} peer status 2>&1", $results);
    while (list($index, $line) = each($results)) {
        if (preg_match("#Hostname:\\s+(.+)#", $line, $re)) {
            $hostname = $re[1];
            if (!preg_match("#[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$#", $hostname)) {
                $array[$hostname]["client_ip"] = gethostbyname($hostname);
            }
            continue;
        }
        if (preg_match("#Uuid:\\s+(.+)#i", $line, $re)) {
            $array[$hostname]["UUID"] = $re[1];
            continue;
        }
        if (preg_match("#State:\\s+(.+)#i", $line, $re)) {
            $array[$hostname]["STATE"] = $re[1];
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "peer status: {$line} -> SKIP\n";
        }
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "peer status: " . count($array) . " items\n";
    }
    while (list($hostname, $line) = each($array)) {
        $hostnameText = null;
        if (preg_match("#[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$#", $hostname)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$hostname} -> is an ip -> resolve it\n";
            }
            $line["client_ip"] = $hostname;
            $hostnameText = gethostbyaddr($hostname);
        }
        if (isset($NOSTATUS[$line["client_ip"]])) {
            continue;
        }
        $gluster = new gluster_client($hostname);
        if ($gluster->client_ip == null) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$hostname} -> ADD -> {$line["STATE"]}\n";
            }
            if (isset($line["client_ip"])) {
                $gluster->client_ip = $line["client_ip"];
            }
            $gluster->state = $line["STATE"];
            $gluster->uuid = $line["UUID"];
            if ($hostnameText != null) {
                $gluster->hostname = $hostnameText;
            }
            $gluster->add_client();
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "{$hostname} -> EDIT -> {$line["STATE"]} - {$hostnameText}\n";
        }
        $gluster->state = $line["STATE"];
        $gluster->uuid = $line["UUID"];
        $gluster->edit_client();
    }
}