コード例 #1
0
ファイル: maps.inc.php プロジェクト: TonywalkerCN/Zabbix
function drawMapHighligts(&$im, $map, $mapInfo)
{
    $selements = $map['selements'];
    foreach ($selements as $selementId => $selement) {
        if (isset($selement['elementsubtype']) && $selement['elementsubtype'] == SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS) {
            continue;
        }
        $elementInfo = $mapInfo[$selementId];
        $img = get_png_by_selement($elementInfo);
        $iconX = imagesx($img);
        $iconY = imagesy($img);
        if ($map['highlight'] % 2 == SYSMAP_HIGHLIGHT_ON) {
            $hl_color = null;
            $st_color = null;
            if ($elementInfo['icon_type'] == SYSMAP_ELEMENT_ICON_ON) {
                $hl_color = hex2rgb(getSeverityColor($elementInfo['priority']));
            }
            if ($elementInfo['icon_type'] == SYSMAP_ELEMENT_ICON_MAINTENANCE) {
                $st_color = hex2rgb('FF9933');
            }
            if ($elementInfo['icon_type'] == SYSMAP_ELEMENT_ICON_DISABLED) {
                $st_color = hex2rgb('EEEEEE');
            }
            $mainProblems = array(SYSMAP_ELEMENT_TYPE_HOST_GROUP => 1, SYSMAP_ELEMENT_TYPE_MAP => 1);
            if (isset($mainProblems[$selement['elementtype']])) {
                if (!is_null($hl_color)) {
                    $st_color = null;
                }
            } elseif (!is_null($st_color)) {
                $hl_color = null;
            }
            if (!is_null($st_color)) {
                $r = $st_color[0];
                $g = $st_color[1];
                $b = $st_color[2];
                imagefilledrectangle($im, $selement['x'] - 2, $selement['y'] - 2, $selement['x'] + $iconX + 2, $selement['y'] + $iconY + 2, imagecolorallocatealpha($im, $r, $g, $b, 0));
                // shadow
                imagerectangle($im, $selement['x'] - 2 - 1, $selement['y'] - 2 - 1, $selement['x'] + $iconX + 2 + 1, $selement['y'] + $iconY + 2 + 1, imagecolorallocate($im, 120, 120, 120));
                imagerectangle($im, $selement['x'] - 2 - 2, $selement['y'] - 2 - 2, $selement['x'] + $iconX + 2 + 2, $selement['y'] + $iconY + 2 + 2, imagecolorallocate($im, 220, 220, 220));
            }
            if (!is_null($hl_color)) {
                $r = $hl_color[0];
                $g = $hl_color[1];
                $b = $hl_color[2];
                imagefilledellipse($im, $selement['x'] + $iconX / 2, $selement['y'] + $iconY / 2, $iconX + 20, $iconX + 20, imagecolorallocatealpha($im, $r, $g, $b, 0));
                imageellipse($im, $selement['x'] + $iconX / 2, $selement['y'] + $iconY / 2, $iconX + 20 + 1, $iconX + 20 + 1, imagecolorallocate($im, 120, 120, 120));
                $config = select_config();
                if (isset($elementInfo['ack']) && $elementInfo['ack'] && $config['event_ack_enable']) {
                    imagesetthickness($im, 5);
                    imagearc($im, $selement['x'] + $iconX / 2, $selement['y'] + $iconY / 2, $iconX + 20 - 3, $iconX + 20 - 3, 0, 359, imagecolorallocate($im, 50, 150, 50));
                    imagesetthickness($im, 1);
                }
            }
        }
    }
}
コード例 #2
0
ファイル: class.cchart_zabbix.php プロジェクト: kai-cn/zatree
 protected function calcTriggers()
 {
     $this->triggers = array();
     if ($this->m_showTriggers != 1) {
         return;
     }
     $max = 3;
     $cnt = 0;
     foreach ($this->items as $inum => $item) {
         $db_triggers = DBselect('SELECT DISTINCT h.host,tr.description,tr.triggerid,tr.expression,tr.priority,tr.value' . ' FROM triggers tr,functions f,items i,hosts h' . ' WHERE tr.triggerid=f.triggerid' . " AND f.function IN ('last','min','avg','max')" . ' AND tr.status=' . TRIGGER_STATUS_ENABLED . ' AND i.itemid=f.itemid' . ' AND h.hostid=i.hostid' . ' AND f.itemid=' . $item['itemid'] . ' ORDER BY tr.priority');
         while (($trigger = DBfetch($db_triggers)) && $cnt < $max) {
             $db_fnc_cnt = DBselect('SELECT COUNT(*) AS cnt FROM functions f WHERE f.triggerid=' . $trigger['triggerid']);
             $fnc_cnt = DBfetch($db_fnc_cnt);
             if ($fnc_cnt['cnt'] != 1) {
                 continue;
             }
             $trigger = API::UserMacro()->resolveTrigger($trigger);
             if (!preg_match('/^\\{([0-9]+)\\}\\s*?([\\<\\>\\=]{1})\\s*?([\\-0-9\\.]+)([TGMKsmhdw]?)$/', $trigger['expression'], $arr)) {
                 continue;
             }
             $val = convert($arr[3] . $arr[4]);
             $minY = $this->m_minY[$this->items[$inum]['axisside']];
             $maxY = $this->m_maxY[$this->items[$inum]['axisside']];
             $this->triggers[] = array('skipdraw' => $val <= $minY || $val >= $maxY, 'y' => $this->sizeY - ($val - $minY) / ($maxY - $minY) * $this->sizeY + $this->shiftY, 'color' => getSeverityColor($trigger['priority']), 'description' => _('Trigger') . ': ' . CTriggerHelper::expandDescription($trigger), 'constant' => '[' . $arr[2] . ' ' . $arr[3] . $arr[4] . ']');
             ++$cnt;
         }
     }
 }
コード例 #3
0
ファイル: jsrpc.php プロジェクト: SandipSingh14/Zabbix_
             if (!isset($usedTriggers[$event['objectid']])) {
                 $trigger = $event['trigger'];
                 $host = $event['host'];
                 if ($event['value'] == TRIGGER_VALUE_FALSE) {
                     $priority = 0;
                     $title = _('Resolved');
                     $sound = $msgsettings['sounds.recovery'];
                 } else {
                     $priority = $trigger['priority'];
                     $title = _('Problem on');
                     $sound = $msgsettings['sounds.' . $trigger['priority']];
                 }
                 $url_tr_status = 'tr_status.php?hostid=' . $host['hostid'];
                 $url_events = 'events.php?triggerid=' . $event['objectid'];
                 $url_tr_events = 'tr_events.php?eventid=' . $event['eventid'] . '&triggerid=' . $event['objectid'];
                 $result[$number] = array('type' => 3, 'caption' => 'events', 'sourceid' => $event['eventid'], 'time' => $event['clock'], 'priority' => $priority, 'sound' => $sound, 'color' => getSeverityColor($trigger['priority'], $event['value']), 'title' => $title . ' ' . get_node_name_by_elid($host['hostid'], null, NAME_DELIMITER) . '[url=' . $url_tr_status . ']' . $host['host'] . '[/url]', 'body' => array(_('Details') . ': [url=' . $url_events . ']' . $trigger['description'] . '[/url]', _('Date') . ': [b][url=' . $url_tr_events . ']' . zbx_date2str(_('d M Y H:i:s'), $event['clock']) . '[/url][/b]'), 'timeout' => $msgsettings['timeout']);
                 $sortClock[$number] = $event['clock'];
                 $sortEvent[$number] = $event['eventid'];
                 $usedTriggers[$event['objectid']] = true;
             }
         } else {
             break;
         }
     }
     array_multisort($sortClock, SORT_ASC, $sortEvent, SORT_ASC, $result);
     break;
 case 'message.closeAll':
     $msgsettings = getMessageSettings();
     switch (strtolower($data['params']['caption'])) {
         case 'events':
             $msgsettings['last.clock'] = (int) $data['params']['time'] + 1;
コード例 #4
0
ファイル: jsrpc.php プロジェクト: omidmt/zabbix-greenplum
             if (!isset($usedTriggers[$event['objectid']])) {
                 $trigger = $event['trigger'];
                 $host = $event['host'];
                 if ($event['value'] == TRIGGER_VALUE_FALSE) {
                     $priority = 0;
                     $title = _('Resolved');
                     $sound = $msgsettings['sounds.recovery'];
                 } else {
                     $priority = $trigger['priority'];
                     $title = _('Problem on');
                     $sound = $msgsettings['sounds.' . $trigger['priority']];
                 }
                 $url_tr_status = 'tr_status.php?hostid=' . $host['hostid'];
                 $url_events = 'events.php?filter_set=1&triggerid=' . $event['objectid'] . '&source=' . EVENT_SOURCE_TRIGGERS;
                 $url_tr_events = 'tr_events.php?eventid=' . $event['eventid'] . '&triggerid=' . $event['objectid'];
                 $result[$number] = array('type' => 3, 'caption' => 'events', 'sourceid' => $event['eventid'], 'time' => $event['clock'], 'priority' => $priority, 'sound' => $sound, 'color' => getSeverityColor($trigger['priority'], $event['value']), 'title' => $title . ' [url=' . $url_tr_status . ']' . $host['name'] . '[/url]', 'body' => array(_('Details') . ': [url=' . $url_events . ']' . $trigger['description'] . '[/url]', _('Date') . ': [b][url=' . $url_tr_events . ']' . zbx_date2str(DATE_TIME_FORMAT_SECONDS, $event['clock']) . '[/url][/b]'), 'timeout' => $msgsettings['timeout']);
                 $sortClock[$number] = $event['clock'];
                 $sortEvent[$number] = $event['eventid'];
                 $usedTriggers[$event['objectid']] = true;
             }
         } else {
             break;
         }
     }
     array_multisort($sortClock, SORT_ASC, $sortEvent, SORT_ASC, $result);
     break;
 case 'message.closeAll':
     $msgsettings = getMessageSettings();
     switch (strtolower($data['params']['caption'])) {
         case 'events':
             $msgsettings['last.clock'] = (int) $data['params']['time'] + 1;
コード例 #5
0
ファイル: maps.inc.php プロジェクト: jbfavre/debian-zabbix
function drawMapHighligts(&$im, $map, $mapInfo)
{
    $config = select_config();
    $selements = $map['selements'];
    foreach ($selements as $selementId => $selement) {
        if (isset($selement['elementsubtype']) && $selement['elementsubtype'] == SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS) {
            continue;
        }
        $elementInfo = $mapInfo[$selementId];
        $img = get_png_by_selement($elementInfo);
        $iconX = imagesx($img);
        $iconY = imagesy($img);
        if ($map['highlight'] % 2 == SYSMAP_HIGHLIGHT_ON) {
            $hl_color = null;
            $st_color = null;
            if ($elementInfo['icon_type'] == SYSMAP_ELEMENT_ICON_ON) {
                $hl_color = getSeverityColor($elementInfo['priority']);
            }
            if ($elementInfo['icon_type'] == SYSMAP_ELEMENT_ICON_MAINTENANCE) {
                $st_color = 'FF9933';
            }
            if ($elementInfo['icon_type'] == SYSMAP_ELEMENT_ICON_DISABLED) {
                $st_color = '999999';
            }
            $mainProblems = [SYSMAP_ELEMENT_TYPE_HOST_GROUP => 1, SYSMAP_ELEMENT_TYPE_MAP => 1];
            if (isset($mainProblems[$selement['elementtype']])) {
                if ($hl_color !== null) {
                    $st_color = null;
                }
            } elseif (!is_null($st_color)) {
                $hl_color = null;
            }
            if ($st_color !== null) {
                imagefilledrectangle($im, $selement['x'] - 2, $selement['y'] - 2, $selement['x'] + $iconX + 2, $selement['y'] + $iconY + 2, get_color($im, $st_color, 50));
            }
            if ($hl_color !== null) {
                imagefilledellipse($im, $selement['x'] + $iconX / 2, $selement['y'] + $iconY / 2, $iconX + 20, $iconX + 20, get_color($im, $hl_color));
                if (isset($elementInfo['ack']) && $elementInfo['ack'] && $config['event_ack_enable']) {
                    imagesetthickness($im, 5);
                    imagearc($im, $selement['x'] + $iconX / 2, $selement['y'] + $iconY / 2, $iconX + 20 - 2, $iconX + 20 - 2, 0, 359, imagecolorallocate($im, 50, 150, 50));
                    imagesetthickness($im, 1);
                }
            }
        }
    }
}