本文整理汇总了PHP中CMacrosResolverHelper::resolveTriggerName方法的典型用法代码示例。如果您正苦于以下问题:PHP CMacrosResolverHelper::resolveTriggerName方法的具体用法?PHP CMacrosResolverHelper::resolveTriggerName怎么用?PHP CMacrosResolverHelper::resolveTriggerName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMacrosResolverHelper
的用法示例。
在下文中一共展示了CMacrosResolverHelper::resolveTriggerName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSelementsInfo
//.........这里部分代码省略.........
$host = $allHosts[$hostId];
$last_hostid = $hostId;
if ($host['status'] == HOST_STATUS_NOT_MONITORED) {
$i['disabled']++;
} elseif ($host['maintenance_status'] == HOST_MAINTENANCE_STATUS_ON) {
$i['maintenance']++;
}
}
foreach ($selement['triggers'] as $triggerId) {
$trigger = $allTriggers[$triggerId];
if ($options['severity_min'] <= $trigger['priority']) {
if ($trigger['status'] == TRIGGER_STATUS_DISABLED) {
$i['trigger_disabled']++;
} else {
if ($trigger['value'] == TRIGGER_VALUE_TRUE) {
$i['problem']++;
$lastProblemId = $triggerId;
if ($i['priority'] < $trigger['priority']) {
$i['priority'] = $trigger['priority'];
}
}
if ($showUnacknowledged && $trigger['lastEvent'] && !$trigger['lastEvent']['acknowledged']) {
$i['problem_unack']++;
}
$i['latelyChanged'] |= time() - $trigger['lastchange'] < $config['blink_period'];
}
}
}
$i['ack'] = (bool) (!$i['problem_unack']);
if ($sysmap['expandproblem'] && $i['problem'] == 1) {
if (!isset($lastProblemId)) {
$lastProblemId = null;
}
$i['problem_title'] = CMacrosResolverHelper::resolveTriggerName($allTriggers[$lastProblemId]);
}
if ($selement['elementtype'] == SYSMAP_ELEMENT_TYPE_HOST && $i['maintenance'] == 1) {
$mnt = get_maintenance_by_maintenanceid($allHosts[$last_hostid]['maintenanceid']);
$i['maintenance_title'] = $mnt['name'];
}
// replace default icons
if (!$selement['iconid_on']) {
$selement['iconid_on'] = $selement['iconid_off'];
}
if (!$selement['iconid_maintenance']) {
$selement['iconid_maintenance'] = $selement['iconid_off'];
}
if (!$selement['iconid_disabled']) {
$selement['iconid_disabled'] = $selement['iconid_off'];
}
switch ($selement['elementtype']) {
case SYSMAP_ELEMENT_TYPE_MAP:
$info[$selementId] = getMapsInfo($selement, $i, $showUnacknowledged);
break;
case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
$info[$selementId] = getHostGroupsInfo($selement, $i, $showUnacknowledged);
break;
case SYSMAP_ELEMENT_TYPE_HOST:
$info[$selementId] = getHostsInfo($selement, $i, $showUnacknowledged);
if ($sysmap['iconmapid'] && $selement['use_iconmap']) {
$info[$selementId]['iconid'] = getIconByMapping($iconMap, $hostInventories[$selement['elementid']]);
}
break;
case SYSMAP_ELEMENT_TYPE_TRIGGER:
$info[$selementId] = getTriggersInfo($selement, $i, $showUnacknowledged);
break;
case SYSMAP_ELEMENT_TYPE_IMAGE:
示例2: get_request
$trigger = API::Trigger()->get(array('triggerids' => get_request('triggers'), 'output' => array('triggerid'), 'limit' => 1));
if (!$trigger) {
access_deny();
}
}
/*
* Actions
*/
$eventTrigger = null;
$eventAcknowledged = null;
$bulk = !isset($_REQUEST['eventid']);
if (!$bulk) {
$events = API::Event()->get(array('eventids' => $_REQUEST['eventid'], 'output' => API_OUTPUT_EXTEND, 'selectRelatedObject' => API_OUTPUT_EXTEND));
if ($events) {
$event = reset($events);
$eventTriggerName = CMacrosResolverHelper::resolveTriggerName($event['relatedObject']);
$eventAcknowledged = $event['acknowledged'];
}
$_REQUEST['events'] = $_REQUEST['eventid'];
}
if (isset($_REQUEST['save']) || isset($_REQUEST['saveandreturn'])) {
if ($bulk) {
$_REQUEST['message'] .= $_REQUEST['message'] == '' ? '' : "\n\r" . _('----[BULK ACKNOWLEDGE]----');
}
if (isset($_REQUEST['events'])) {
$_REQUEST['events'] = zbx_toObject($_REQUEST['events'], 'eventid');
} elseif (isset($_REQUEST['triggers'])) {
$_REQUEST['events'] = API::Event()->get(array('source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'objectids' => $_REQUEST['triggers'], 'output' => array('eventid'), 'acknowledged' => EVENT_NOT_ACKNOWLEDGED));
}
$acknowledgeEvent = API::Event()->acknowledge(array('eventids' => zbx_objectValues($_REQUEST['events'], 'eventid'), 'message' => $_REQUEST['message']));
show_messages($acknowledgeEvent, _('Event acknowledged'), _('Cannot acknowledge event'));
示例3: make_trigger_details
function make_trigger_details($trigger)
{
$hosts = reset($trigger['hosts']);
$hostId = $hosts['hostid'];
$hosts = API::Host()->get(array('output' => array('name', 'hostid', 'status'), 'hostids' => $hostId, 'selectScreens' => API_OUTPUT_COUNT, 'preservekeys' => true));
$host = reset($hosts);
$scripts = API::Script()->getScriptsByHosts($hostId);
$hostName = new CSpan($host['name'], 'link_menu');
$hostName->setMenuPopup(getMenuPopupHost($host, $scripts ? reset($scripts) : null));
$table = new CTableInfo();
if (is_show_all_nodes()) {
$table->addRow(array(_('Node'), get_node_name_by_elid($trigger['triggerid'])));
}
$table->addRow(array(_('Host'), $hostName));
$table->addRow(array(_('Trigger'), CMacrosResolverHelper::resolveTriggerName($trigger)));
$table->addRow(array(_('Severity'), getSeverityCell($trigger['priority'])));
$table->addRow(array(_('Expression'), explode_exp($trigger['expression'], true, true)));
$table->addRow(array(_('Event generation'), _('Normal') . (TRIGGER_MULT_EVENT_ENABLED == $trigger['type'] ? SPACE . '+' . SPACE . _('Multiple PROBLEM events') : '')));
$table->addRow(array(_('Disabled'), TRIGGER_STATUS_ENABLED == $trigger['status'] ? new CCol(_('No'), 'off') : new CCol(_('Yes'), 'on')));
return $table;
}
示例4: CSpan
$description = new CSpan($trigger['description'], 'link');
$trigger['description'] = $trigger['hostname'] . NAME_DELIMITER . $trigger['description'];
if ($multiselect) {
$js_action = 'addValue(' . zbx_jsvalue($reference) . ', ' . zbx_jsvalue($trigger['triggerid']) . ', ' . $parentId . ');';
} else {
$values = array($dstfld1 => $trigger[$srcfld1], $dstfld2 => $trigger[$srcfld2]);
if (isset($srcfld3)) {
$values[$dstfld3] = $trigger[$srcfld3];
}
$js_action = 'addValues(' . zbx_jsvalue($dstfrm) . ', ' . zbx_jsvalue($values) . '); return false;';
}
$description->setAttribute('onclick', $js_action . ' jQuery(this).removeAttr("onclick");');
if (count($trigger['dependencies']) > 0) {
$description = array($description, BR(), bold(_('Depends on')), BR());
foreach ($trigger['dependencies'] as $dependentTrigger) {
$description[] = array(CMacrosResolverHelper::resolveTriggerName($dependentTrigger), BR());
}
}
$table->addRow(array($multiselect ? new CCheckBox('triggers[' . zbx_jsValue($trigger[$srcfld1]) . ']', null, null, $trigger['triggerid']) : null, $description, getSeverityCell($trigger['priority']), new CSpan(triggerIndicator($trigger['status'], $trigger['state']), triggerIndicatorStyle($trigger['status'], $trigger['state']))));
// made to save memory usage
if ($multiselect) {
$jsTriggers[$trigger['triggerid']] = array('id' => $trigger['triggerid'], 'name' => $trigger['description'], 'prefix' => get_node_name_by_elid($trigger['triggerid'], null, NAME_DELIMITER), 'triggerid' => $trigger['triggerid'], 'description' => $trigger['description'], 'expression' => $trigger['expression'], 'priority' => $trigger['priority'], 'status' => $trigger['status'], 'host' => $trigger['hostname']);
}
}
if ($multiselect) {
$button = new CButton('select', _('Select'), "addSelectedValues('triggers', " . zbx_jsvalue($reference) . ', ' . $parentId . ');');
$table->setFooter(new CCol($button, 'right'));
insert_js('var popupReference = ' . zbx_jsValue($jsTriggers, true) . ';');
}
zbx_add_post_js('chkbxRange.pageGoName = "triggers";');
$form->addItem($table);
示例5: calcTriggers
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=' . zbx_dbstr($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['expression'] = CMacrosResolverHelper::resolveTriggerExpressionUserMacro($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') . NAME_DELIMITER . CMacrosResolverHelper::resolveTriggerName($trigger), 'constant' => '[' . $arr[2] . ' ' . $arr[3] . $arr[4] . ']');
++$cnt;
}
}
}
示例6: make_trigger_details
function make_trigger_details($trigger)
{
$hostNames = array();
$hostIds = zbx_objectValues($trigger['hosts'], 'hostid');
$hosts = API::Host()->get(array('output' => array('name', 'hostid', 'status'), 'hostids' => $hostIds, 'selectScreens' => API_OUTPUT_COUNT, 'selectGraphs' => API_OUTPUT_COUNT));
if (count($hosts) > 1) {
order_result($hosts, 'name', ZBX_SORT_UP);
}
$scripts = API::Script()->getScriptsByHosts($hostIds);
foreach ($hosts as $host) {
$hostName = new CSpan($host['name'], 'link_menu');
$hostName->setMenuPopup(CMenuPopupHelper::getHost($host, $scripts[$host['hostid']]));
$hostNames[] = $hostName;
$hostNames[] = ', ';
}
array_pop($hostNames);
$table = new CTableInfo();
$table->addRow(array(new CCol(_n('Host', 'Hosts', count($hosts))), new CCol($hostNames, 'wraptext')));
$table->addRow(array(new CCol(_('Trigger')), new CCol(CMacrosResolverHelper::resolveTriggerName($trigger), 'wraptext')));
$table->addRow(array(_('Severity'), getSeverityCell($trigger['priority'])));
$table->addRow(array(new CCol(_('Expression')), new CCol(explode_exp($trigger['expression'], true, true), 'trigger-expression')));
$table->addRow(array(_('Event generation'), _('Normal') . (TRIGGER_MULT_EVENT_ENABLED == $trigger['type'] ? SPACE . '+' . SPACE . _('Multiple PROBLEM events') : '')));
$table->addRow(array(_('Disabled'), TRIGGER_STATUS_ENABLED == $trigger['status'] ? new CCol(_('No'), 'off') : new CCol(_('Yes'), 'on')));
return $table;
}
示例7: array
}
// get triggers
$options = array('triggerids' => $_REQUEST['triggerid'], 'expandData' => 1, 'selectHosts' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND);
$triggers = API::Trigger()->get($options);
if (empty($triggers)) {
access_deny();
}
$trigger = reset($triggers);
// get events
$options = array('source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'eventids' => $_REQUEST['eventid'], 'objectids' => $_REQUEST['triggerid'], 'select_alerts' => API_OUTPUT_EXTEND, 'select_acknowledges' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND, 'selectHosts' => API_OUTPUT_EXTEND);
$events = API::Event()->get($options);
$event = reset($events);
$tr_event_wdgt = new CWidget();
$tr_event_wdgt->setClass('header');
// Main widget header
$text = array(_('EVENTS') . ': "' . CMacrosResolverHelper::resolveTriggerName($trigger) . '"');
$fs_icon = get_icon('fullscreen', array('fullscreen' => $_REQUEST['fullscreen']));
$tr_event_wdgt->addHeader($text, $fs_icon);
$left_col = array();
// tr details
$triggerDetails = new CUIWidget('hat_triggerdetails', make_trigger_details($trigger));
$triggerDetails->setHeader(_('Event source details'));
$left_col[] = $triggerDetails;
// event details
$eventDetails = new CUIWidget('hat_eventdetails', make_event_details($event, $trigger));
$eventDetails->setHeader(_('Event details'));
$left_col[] = $eventDetails;
$right_col = array();
// if acknowledges are not disabled in configuration, let's show them
if ($config['event_ack_enable']) {
$event_ack = new CUIWidget('hat_eventack', makeAckTab($event), CProfile::get('web.tr_events.hats.hat_eventack.state', 1));
示例8: getRequest
// triggers
$triggers = API::Trigger()->get(array('output' => API_OUTPUT_EXTEND, 'selectHosts' => API_OUTPUT_EXTEND, 'triggerids' => getRequest('triggerid')));
if (!$triggers) {
access_deny();
}
$trigger = reset($triggers);
// events
$events = API::Event()->get(array('output' => API_OUTPUT_EXTEND, 'select_alerts' => API_OUTPUT_EXTEND, 'select_acknowledges' => API_OUTPUT_EXTEND, 'selectHosts' => API_OUTPUT_EXTEND, 'source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'eventids' => getRequest('eventid'), 'objectids' => getRequest('triggerid')));
$event = reset($events);
/*
* Display
*/
$config = select_config();
$eventWidget = new CWidget();
$eventWidget->setClass('header');
$eventWidget->addHeader(array(_('EVENTS') . ': "' . CMacrosResolverHelper::resolveTriggerName($trigger) . '"'), get_icon('fullscreen', array('fullscreen' => getRequest('fullscreen'))));
// trigger details
$triggerDetailsWidget = new CUiWidget('hat_triggerdetails', make_trigger_details($trigger));
$triggerDetailsWidget->setHeader(_('Event source details'));
// event details
$eventDetailsWidget = new CUiWidget('hat_eventdetails', make_event_details($event, $trigger));
$eventDetailsWidget->setHeader(_('Event details'));
// if acknowledges are not disabled in configuration, let's show them
if ($config['event_ack_enable']) {
$eventAcknowledgesWidget = new CCollapsibleUiWidget('hat_eventack', makeAckTab($event));
$eventAcknowledgesWidget->open = (bool) CProfile::get('web.tr_events.hats.hat_eventack.state', true);
$eventAcknowledgesWidget->setHeader(_('Acknowledges'));
} else {
$eventAcknowledgesWidget = null;
}
// actions messages
示例9: CSpan
$description = new CSpan($trigger['description'], 'link');
$trigger['description'] = $trigger['hostname'] . NAME_DELIMITER . $trigger['description'];
if ($multiselect) {
$js_action = 'addValue(' . zbx_jsvalue($reference) . ', ' . zbx_jsvalue($trigger['triggerid']) . ');';
} else {
$values = array($dstfld1 => $trigger[$srcfld1], $dstfld2 => $trigger[$srcfld2]);
if (isset($srcfld3)) {
$values[$dstfld3] = $trigger[$srcfld3];
}
$js_action = 'addValues(' . zbx_jsvalue($dstfrm) . ', ' . zbx_jsvalue($values) . '); return false;';
}
$description->setAttribute('onclick', $js_action . ' jQuery(this).removeAttr("onclick");');
if (count($trigger['dependencies']) > 0) {
$description = array($description, BR(), bold(_('Depends on')), BR());
foreach ($trigger['dependencies'] as $val) {
$description[] = array(CMacrosResolverHelper::resolveTriggerName($val), BR());
}
}
$table->addRow(array($multiselect ? new CCheckBox('triggers[' . zbx_jsValue($trigger[$srcfld1]) . ']', null, null, $trigger['triggerid']) : null, $description, getSeverityCell($trigger['priority']), new CSpan(triggerIndicator($trigger['status'], $trigger['state']), triggerIndicatorStyle($trigger['status'], $trigger['state']))));
// made to save memmory usage
if ($multiselect) {
$jsTriggers[$trigger['triggerid']] = array('triggerid' => $trigger['triggerid'], 'description' => $trigger['description'], 'expression' => $trigger['expression'], 'priority' => $trigger['priority'], 'status' => $trigger['status'], 'host' => $trigger['hostname']);
}
}
if ($multiselect) {
$button = new CButton('select', _('Select'), "addSelectedValues('triggers', " . zbx_jsvalue($reference) . ');');
$table->setFooter(new CCol($button, 'right'));
insert_js('var popupReference = ' . zbx_jsValue($jsTriggers, true) . ';');
}
zbx_add_post_js('chkbxRange.pageGoName = "triggers";');
$form->addItem($table);
示例10: make_trigger_details
function make_trigger_details($trigger)
{
$hostNames = [];
$config = select_config();
$hostIds = zbx_objectValues($trigger['hosts'], 'hostid');
$hosts = API::Host()->get(['output' => ['name', 'hostid', 'status'], 'hostids' => $hostIds, 'selectScreens' => API_OUTPUT_COUNT, 'selectGraphs' => API_OUTPUT_COUNT]);
if (count($hosts) > 1) {
order_result($hosts, 'name', ZBX_SORT_UP);
}
$scripts = API::Script()->getScriptsByHosts($hostIds);
foreach ($hosts as $host) {
$hostName = new CSpan($host['name'], ZBX_STYLE_LINK_ACTION);
$hostName->setMenuPopup(CMenuPopupHelper::getHost($host, $scripts[$host['hostid']]));
$hostNames[] = $hostName;
$hostNames[] = ', ';
}
array_pop($hostNames);
$expression = CMacrosResolverHelper::resolveTriggerExpression($trigger['expression'], ['html' => true, 'resolve_usermacros' => true, 'resolve_macros' => true]);
$table = (new CTableInfo())->addRow([new CCol(_n('Host', 'Hosts', count($hosts))), new CCol($hostNames)])->addRow([new CCol(_('Trigger')), new CCol(CMacrosResolverHelper::resolveTriggerName($trigger))])->addRow([_('Severity'), getSeverityCell($trigger['priority'], $config)])->addRow([new CCol(_('Expression')), new CCol($expression)])->addRow([_('Event generation'), _('Normal') . (TRIGGER_MULT_EVENT_ENABLED == $trigger['type'] ? SPACE . '+' . SPACE . _('Multiple PROBLEM events') : '')])->addRow([_('Disabled'), TRIGGER_STATUS_ENABLED == $trigger['status'] ? (new CCol(_('No')))->addClass(ZBX_STYLE_GREEN) : (new CCol(_('Yes')))->addClass(ZBX_STYLE_RED)]);
return $table;
}