Example #1
0
function get_host_list_select($pdo, $mem, $service_id = false)
{
    $hosts = get_host_list($pdo);
    if (!$hosts) {
        return false;
    }
    foreach ($hosts as $k => $v) {
        $sql = "SELECT sum(use_memory) as use_memory FROM instance WHERE host_id='{$v['host_id']}' AND instance_status=2";
        $use_mem = pdo_fetch_all($pdo, $sql);
        $hosts[$k]['use_mem'] = $use_mem ? $use_mem[0]['use_memory'] : 0;
        $hosts[$k]['use_mem'] = round($hosts[$k]['use_mem'], 2);
        $hosts[$k]['free_mem'] = round($hosts[$k]['host_memory'] - $hosts[$k]['use_mem'], 2);
        $hosts[$k]['host_mem'] = round($hosts[$k]['host_memory'], 2);
        $hosts[$k]['sort'] = 0;
        if ($mem > $hosts[$k]['free_mem']) {
            $hosts[$k]['msg'] = '错误:此host空间不足!';
            $hosts[$k]['sort'] = 9;
            continue;
        }
        if ($service_id) {
            $mapping = pdo_get_mapping_info_by_service($pdo, $service_id);
            $host_ids = array();
            foreach ($mapping as $m) {
                $host_ids[] = $m['host_id'];
            }
            if (in_array($v['host_id'], $host_ids)) {
                $hosts[$k]['msg'] = '提醒:同一个service的instance建议分配到不同的host!';
                $hosts[$k]['sort'] = 5;
            }
        }
    }
    /*根据free_mem和sort排序*/
    foreach ($hosts as $k => $v) {
        $a[] = $v['free_mem'];
        $b[] = $v['sort'];
    }
    array_multisort($a, SORT_DESC, $b, SORT_ASC, $hosts);
    return $hosts;
}
Example #2
0
                $row['alert_setting'] = json_decode($row['alert_setting'], true);
                $alert_info_list[$row["target_type"]][$row["target_id"]][] = $row;
            }
        }
        $target_list = array();
        if (isset($alert_info_list['service'])) {
            //service
            $service_list = get_service_list($pdo);
            foreach ($service_list as $s) {
                $target_list['service'][$s['service_id']] = $s['service_name'];
            }
        }
        if (isset($alert_info_list['instance'])) {
            //instance
            $instance_list = get_instance_list($pdo);
            foreach ($instance_list as $i) {
                $target_list['instance'][$i['instance_id']] = $i['port_num'];
            }
        }
        if (isset($alert_info_list['host'])) {
            //host
            $host_list = get_host_list($pdo);
            foreach ($host_list as $h) {
                $target_list['host'][$h['host_id']] = $h['host_name'];
            }
        }
        $target_type = array('service' => 'Service', 'instance' => 'Instance', 'host' => 'Host');
        $template = 'alert';
        break;
}
require_once './libraries/decorator.inc.php';
Example #3
0
    $service_mapping = pdo_get_mapping($pdo, $service_id);
    if ($service_mapping) {
        foreach ($service_mapping as $v) {
            $qlp['instance_id'][] = $v['instance_id'];
        }
    }
    $qlp['service_id'] = array($service_id);
    $queue_list = get_queue_list_complex2($pdo, 0, 15, $qlp);
    $solr_config = pdo_get_solr_config($pdo, $service_id);
    $solr_config = json_decode($solr_config['config_json'], true);
    $dataimport = pdo_get_dataimport($pdo, $service_id);
}
//instance list & host list - tab2
if (in_array($tab, array('2', '4'))) {
    $instance_list = get_instance_list_complex($pdo, array('service_id' => $service_id, 'with_unbind' => '1'));
    $host_list = change_array_key(get_host_list($pdo), 'host_id');
}
//solr_schema - tab1/2
if (in_array($tab, array('1', '3'))) {
    $solr_schema = pdo_get_solr_schema($pdo, $service_id);
    if ($service_info['schema_type'] == 1) {
        $solr_schema = json_decode($solr_schema['schema_json'], true);
    } elseif ($service_info['schema_type'] == 2) {
        $schema_info = $solr_schema['schema_json'];
        $doc = new DomDocument();
        $doc->loadXML($schema_info);
        $xpath = new DomXPath($doc);
        $query = '//field';
        $nodelist = $xpath->query($query);
        foreach ($nodelist as $key => $node) {
            // var_dump ($node->attributes);
Example #4
0
				href="<?php 
echo get_host_prevpageurl();
?>
"><span
				class="glyphicon glyphicon-chevron-left"></span> Prev</a> <a
				type="button" class="btn btn-default btn-xs btn-page"
				href="<?php 
echo get_host_nextpageurl();
?>
">Next <span
				class="glyphicon glyphicon-chevron-right"></span></a>
		</div>

	</div>
<?php 
$hostList = get_host_list();
if (count($hostList) > 0) {
    foreach ($hostList as $hostList_item) {
        $domain = get_url_domain($hostList_item["HTTP_REFERER"]);
        if ($domain == "unknow") {
            $domain = get_url_domain($hostList_item["location"]);
        }
        ?>
	<div class="main-item main-item-host">
		<div class="main-item-name pull-left  cursor-pointer">
			<input style="margin: 0;" type="checkbox" class="s_checkbox"
				value="<?php 
        echo $hostList_item["ip"];
        ?>
"> <a
				href="<?php 
Example #5
0
 */
require_once "modules/backuppc/includes/xmlrpc.php";
global $conf;
$maxperpage = $conf["global"]["maxperpage"];
$filter = array('filter' => $_GET["filter"], 'location' => $_GET['location']);
$filter1 = $_GET["filter"] . '##' . $_GET['location'];
if ($_GET['location']) {
    //$filter['packageapi'] = getPApiDetail(base64_decode($_GET['location']));
    print "";
}
if (isset($_GET["start"])) {
    $start = $_GET["start"];
} else {
    $start = 0;
}
$response = get_host_list($_GET['filter']);
// Check if error occured
if ($response['err']) {
    new NotifyWidgetFailure(nl2br($response['errtext']));
    return;
}
$hosts = $response['data'];
$count = count($hosts);
//print($_GET["filter"]."=");
//print($_GET["location"]);
$n = new OptimizedListInfos($hosts, _T("Host name", "backuppc"));
$n->setCssClass("machineName");
// CSS for icons
$n->setItemCount($count);
$n->setNavBar(new AjaxNavBar($count, $filter1));
$n->start = isset($_GET['start']) ? $_GET['start'] : 0;