示例#1
0
文件: map.php 项目: phedders/zabbix
    $color = convertColor($im, $link["color"]);
    $triggers = get_link_triggers($link['linkid']);
    if (!empty($triggers)) {
        $max_severity = 0;
        foreach ($triggers as $id => $link_trigger) {
            $triggers[$id] = array_merge($link_trigger, get_trigger_by_triggerid($link_trigger["triggerid"]));
            if ($triggers[$id]["status"] == TRIGGER_STATUS_ENABLED && $triggers[$id]["value"] == TRIGGER_VALUE_TRUE) {
                if ($triggers[$id]['severity'] >= $max_severity) {
                    $drawtype = $triggers[$id]['drawtype'];
                    $color = convertColor($im, $triggers[$id]['color']);
                    $max_severity = $triggers[$id]['severity'];
                }
            }
        }
    }
    MyDrawLine($im, $x1, $y1, $x2, $y2, $color, $drawtype);
}
// Draw elements
$icons = array();
$db_elements = DBselect('select * from sysmaps_elements where sysmapid=' . $_REQUEST['sysmapid']);
while ($db_element = DBfetch($db_elements)) {
    if ($img = get_png_by_selementid($db_element['selementid'])) {
        imagecopy($im, $img, $db_element['x'], $db_element['y'], 0, 0, ImageSX($img), ImageSY($img));
    }
    if ($label_type == MAP_LABEL_TYPE_NOTHING) {
        continue;
    }
    $color = $darkgreen;
    $label_color = $black;
    $info_line = '';
    $label_location = $db_element['label_location'];
示例#2
0
function drawMapConnectors(&$im, &$map, &$map_info)
{
    $links = $map['links'];
    $selements = $map['selements'];
    foreach ($links as $lnum => $link) {
        if (empty($link)) {
            continue;
        }
        $selement = $selements[$link['selementid1']];
        list($x1, $y1) = get_icon_center_by_selement($selement, $map_info[$link['selementid1']]);
        $selement = $selements[$link['selementid2']];
        list($x2, $y2) = get_icon_center_by_selement($selement, $map_info[$link['selementid2']]);
        $drawtype = $link['drawtype'];
        $color = convertColor($im, $link['color']);
        $linktriggers = $link['linktriggers'];
        order_result($linktriggers, 'triggerid');
        if (!empty($linktriggers)) {
            $max_severity = 0;
            $options = array();
            $options['nopermissions'] = 1;
            $options['extendoutput'] = 1;
            $options['triggerids'] = array();
            $triggers = array();
            foreach ($linktriggers as $lt_num => $link_trigger) {
                if ($link_trigger['triggerid'] == 0) {
                    continue;
                }
                $id = $link_trigger['linktriggerid'];
                $triggers[$id] = zbx_array_merge($link_trigger, get_trigger_by_triggerid($link_trigger['triggerid']));
                if ($triggers[$id]['status'] == TRIGGER_STATUS_ENABLED && $triggers[$id]['value'] == TRIGGER_VALUE_TRUE) {
                    if ($triggers[$id]['priority'] >= $max_severity) {
                        $drawtype = $triggers[$id]['drawtype'];
                        $color = convertColor($im, $triggers[$id]['color']);
                        $max_severity = $triggers[$id]['priority'];
                    }
                }
            }
        }
        MyDrawLine($im, $x1, $y1, $x2, $y2, $color, $drawtype);
    }
}
示例#3
0
$x = imagesx($im) / 2 - ImageFontWidth(4) * zbx_strlen($name) / 2;
imagetext($im, 10, 0, $x, 25, $colors['Dark Red'], $name);
$str = zbx_date2str(S_MAPS_DATE_FORMAT, time(NULL));
imagestring($im, 0, imagesx($im) - 120, imagesy($im) - 12, $str, $colors['Gray']);
if (isset($_REQUEST['grid'])) {
    $grid = get_request('grid', 50);
    if (!is_numeric($grid)) {
        $grid = 50;
    }
    $dims = imageTextSize(8, 0, '11');
    for ($x = $grid; $x < $width; $x += $grid) {
        MyDrawLine($im, $x, 0, $x, $height, $colors['Black'], MAP_LINK_DRAWTYPE_DASHED_LINE);
        imageText($im, 8, 0, $x + 3, $dims['height'] + 3, $colors['Black'], $x);
    }
    for ($y = $grid; $y < $height; $y += $grid) {
        MyDrawLine($im, 0, $y, $width, $y, $colors['Black'], MAP_LINK_DRAWTYPE_DASHED_LINE);
        imageText($im, 8, 0, 3, $y + $dims['height'] + 3, $colors['Black'], $y);
    }
    imageText($im, 8, 0, 2, $dims['height'] + 3, $colors['Black'], 'Y X:');
}
// ACTION /////////////////////////////////////////////////////////////////////////////
$json = new CJSON();
if (isset($_REQUEST['selements']) || isset($_REQUEST['noselements'])) {
    $map['selements'] = get_request('selements', '[]');
    $map['selements'] = $json->decode($map['selements'], true);
} else {
    $map['selements'] = zbx_toHash($map['selements'], 'selementid');
}
if (isset($_REQUEST['links']) || isset($_REQUEST['nolinks'])) {
    $map['links'] = get_request('links', '[]');
    $map['links'] = $json->decode($map['links'], true);