本文整理汇总了PHP中CSpan::setMenuPopup方法的典型用法代码示例。如果您正苦于以下问题:PHP CSpan::setMenuPopup方法的具体用法?PHP CSpan::setMenuPopup怎么用?PHP CSpan::setMenuPopup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSpan
的用法示例。
在下文中一共展示了CSpan::setMenuPopup方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: make_latest_issues
/**
* Create DIV with latest problem triggers.
*
* If no sortfield and sortorder are defined, the sort indicater in the column name will not be displayed.
*
* @param array $filter['screenid']
* @param array $filter['groupids']
* @param array $filter['hostids']
* @param array $filter['maintenance']
* @param int $filter['extAck']
* @param int $filter['severity']
* @param int $filter['limit']
* @param string $filter['sortfield']
* @param string $filter['sortorder']
* @param string $filter['backUrl']
*
* @return CDiv
*/
function make_latest_issues(array $filter = array())
{
// hide the sort indicator if no sortfield and sortorder are given
$showSortIndicator = isset($filter['sortfield']) || isset($filter['sortorder']);
if (!isset($filter['sortfield'])) {
$filter['sortfield'] = 'lastchange';
}
if (!isset($filter['sortorder'])) {
$filter['sortorder'] = ZBX_SORT_DOWN;
}
$options = array('groupids' => $filter['groupids'], 'hostids' => isset($filter['hostids']) ? $filter['hostids'] : null, 'monitored' => true, 'maintenance' => $filter['maintenance'], 'filter' => array('priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE));
$triggers = API::Trigger()->get(array_merge($options, array('withLastEventUnacknowledged' => isset($filter['extAck']) && $filter['extAck'] == EXTACK_OPTION_UNACK ? true : null, 'skipDependent' => true, 'output' => array('triggerid', 'state', 'error', 'url', 'expression', 'description', 'priority', 'lastchange'), 'selectHosts' => array('hostid', 'name'), 'selectLastEvent' => array('eventid', 'acknowledged', 'objectid', 'clock', 'ns'), 'sortfield' => $filter['sortfield'], 'sortorder' => $filter['sortorder'], 'limit' => isset($filter['limit']) ? $filter['limit'] : DEFAULT_LATEST_ISSUES_CNT)));
// don't use withLastEventUnacknowledged and skipDependent because of performance issues
$triggersTotalCount = API::Trigger()->get(array_merge($options, array('countOutput' => true)));
// get acknowledges
$eventIds = array();
foreach ($triggers as $trigger) {
if ($trigger['lastEvent']) {
$eventIds[] = $trigger['lastEvent']['eventid'];
}
}
if ($eventIds) {
$eventAcknowledges = API::Event()->get(array('eventids' => $eventIds, 'select_acknowledges' => API_OUTPUT_EXTEND, 'preservekeys' => true));
}
foreach ($triggers as $tnum => $trigger) {
// if trigger is lost (broken expression) we skip it
if (empty($trigger['hosts'])) {
unset($triggers[$tnum]);
continue;
}
$host = reset($trigger['hosts']);
$trigger['hostid'] = $host['hostid'];
$trigger['hostname'] = $host['name'];
if ($trigger['lastEvent']) {
$trigger['lastEvent']['acknowledges'] = isset($eventAcknowledges[$trigger['lastEvent']['eventid']]) ? $eventAcknowledges[$trigger['lastEvent']['eventid']]['acknowledges'] : null;
}
$triggers[$tnum] = $trigger;
}
$hostIds = zbx_objectValues($triggers, 'hostid');
// get hosts
$hosts = API::Host()->get(array('hostids' => $hostIds, 'output' => array('hostid', 'name', 'status', 'maintenance_status', 'maintenance_type', 'maintenanceid'), 'selectScreens' => API_OUTPUT_COUNT, 'preservekeys' => true));
// actions
$actions = getEventActionsStatHints($eventIds);
// ack params
$ackParams = isset($filter['screenid']) ? array('screenid' => $filter['screenid']) : array();
$config = select_config();
// indicator of sort field
if ($showSortIndicator) {
$sortDiv = new CDiv(SPACE, $filter['sortorder'] === ZBX_SORT_DOWN ? 'icon_sortdown default_cursor' : 'icon_sortup default_cursor');
$sortDiv->addStyle('float: left');
$hostHeaderDiv = new CDiv(array(_('Host'), SPACE));
$hostHeaderDiv->addStyle('float: left');
$issueHeaderDiv = new CDiv(array(_('Issue'), SPACE));
$issueHeaderDiv->addStyle('float: left');
$lastChangeHeaderDiv = new CDiv(array(_('Time'), SPACE));
$lastChangeHeaderDiv->addStyle('float: left');
}
$table = new CTableInfo(_('No events found.'));
$table->setHeader(array(is_show_all_nodes() ? _('Node') : null, $showSortIndicator && $filter['sortfield'] === 'hostname' ? array($hostHeaderDiv, $sortDiv) : _('Host'), $showSortIndicator && $filter['sortfield'] === 'priority' ? array($issueHeaderDiv, $sortDiv) : _('Issue'), $showSortIndicator && $filter['sortfield'] === 'lastchange' ? array($lastChangeHeaderDiv, $sortDiv) : _('Last change'), _('Age'), _('Info'), $config['event_ack_enable'] ? _('Ack') : null, _('Actions')));
$scripts = API::Script()->getScriptsByHosts($hostIds);
// triggers
foreach ($triggers as $trigger) {
$host = $hosts[$trigger['hostid']];
$hostName = new CSpan($host['name'], 'link_menu');
$hostName->setMenuPopup(getMenuPopupHost($host, $scripts[$host['hostid']]));
// add maintenance icon with hint if host is in maintenance
$maintenanceIcon = null;
if ($host['maintenance_status']) {
$maintenanceIcon = new CDiv(null, 'icon-maintenance-abs');
// get maintenance
$maintenances = API::Maintenance()->get(array('maintenanceids' => $host['maintenanceid'], 'output' => API_OUTPUT_EXTEND, 'limit' => 1));
if ($maintenance = reset($maintenances)) {
$hint = $maintenance['name'] . ' [' . ($host['maintenance_type'] ? _('Maintenance without data collection') : _('Maintenance with data collection')) . ']';
if (isset($maintenance['description'])) {
// double quotes mandatory
$hint .= "\n" . $maintenance['description'];
}
$maintenanceIcon->setHint($hint);
$maintenanceIcon->addClass('pointer');
}
$hostName->addClass('left-to-icon-maintenance-abs');
}
//.........这里部分代码省略.........
示例2: 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;
}
示例3: array
if ($host['status'] == HOST_STATUS_MONITORED) {
$monitoredHostIds[$host['hostid']] = true;
}
}
}
if ($monitoredHostIds) {
$monitoredHosts = API::Host()->get(array('output' => array('hostid'), 'selectGroups' => array('groupid'), 'hostids' => array_keys($monitoredHostIds), 'preservekeys' => true));
}
foreach ($triggers as $trigger) {
foreach ($trigger['hosts'] as $host) {
if ($host['status'] == HOST_STATUS_MONITORED) {
// Pass a monitored 'hostid' and corresponding first 'groupid' to menu pop-up "Events" link.
$trigger['hostid'] = $host['hostid'];
$trigger['groupid'] = $monitoredHosts[$trigger['hostid']]['groups'][0]['groupid'];
break;
} else {
// Unmonitored will have disabled "Events" link and there is no 'groupid' or 'hostid'.
$trigger['hostid'] = 0;
$trigger['groupid'] = 0;
}
}
$hostId = $trigger['hosts'][0]['hostid'];
$hostName = new CSpan($trigger['hosts'][0]['name'], 'link_menu menu-host' . ($hosts[$hostId]['status'] == HOST_STATUS_NOT_MONITORED ? ' not-monitored' : ''));
$hostName->setMenuPopup(CMenuPopupHelper::getHost($hosts[$hostId], $scripts[$hostId]));
$triggerDescription = new CSpan($trigger['description'], 'link_menu');
$triggerDescription->setMenuPopup(CMenuPopupHelper::getTrigger($trigger));
$table->addRow(array($hostName, $triggerDescription, getSeverityCell($trigger['priority']), $trigger['cnt_event']));
}
$rprt_wdgt->addItem($table);
$rprt_wdgt->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
示例4: getItemsDataOverview
/**
* Retrieve overview table object for items.
*
* @param array $hostIds
* @param string $application name of application to filter
* @param int $viewMode
*
* @return CTableInfo
*/
function getItemsDataOverview($hostIds, $application, $viewMode)
{
$sqlFrom = '';
$sqlWhere = '';
if ($application !== '') {
$sqlFrom = 'applications a,items_applications ia,';
$sqlWhere = ' AND i.itemid=ia.itemid AND a.applicationid=ia.applicationid AND a.name=' . zbx_dbstr($application);
}
$dbItems = DBfetchArray(DBselect('SELECT DISTINCT h.hostid,h.name AS hostname,i.itemid,i.key_,i.value_type,i.units,' . 'i.name,t.priority,i.valuemapid,t.value AS tr_value,t.triggerid' . ' FROM hosts h,' . $sqlFrom . 'items i' . ' LEFT JOIN functions f ON f.itemid=i.itemid' . ' LEFT JOIN triggers t ON t.triggerid=f.triggerid AND t.status=' . TRIGGER_STATUS_ENABLED . ' WHERE ' . dbConditionInt('h.hostid', $hostIds) . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . dbConditionInt('i.flags', array(ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED)) . $sqlWhere));
$dbItems = CMacrosResolverHelper::resolveItemNames($dbItems);
CArrayHelper::sort($dbItems, array(array('field' => 'name_expanded', 'order' => ZBX_SORT_UP), array('field' => 'itemid', 'order' => ZBX_SORT_UP)));
// fetch latest values
$history = Manager::History()->getLast(zbx_toHash($dbItems, 'itemid'), 1, ZBX_HISTORY_PERIOD);
// fetch data for the host JS menu
$hosts = API::Host()->get(array('output' => array('name', 'hostid', 'status'), 'monitored_hosts' => true, 'hostids' => $hostIds, 'with_monitored_items' => true, 'preservekeys' => true, 'selectScreens' => $viewMode == STYLE_LEFT ? API_OUTPUT_COUNT : null));
$items = array();
foreach ($dbItems as $dbItem) {
$name = $dbItem['name_expanded'];
$dbItem['hostname'] = get_node_name_by_elid($dbItem['hostid'], null, NAME_DELIMITER) . $dbItem['hostname'];
$hostNames[$dbItem['hostid']] = $dbItem['hostname'];
// a little tricky check for attempt to overwrite active trigger (value=1) with
// inactive or active trigger with lower priority.
if (!isset($items[$name][$dbItem['hostname']]) || ($items[$name][$dbItem['hostname']]['tr_value'] == TRIGGER_VALUE_FALSE && $dbItem['tr_value'] == TRIGGER_VALUE_TRUE || ($items[$name][$dbItem['hostname']]['tr_value'] == TRIGGER_VALUE_FALSE || $dbItem['tr_value'] == TRIGGER_VALUE_TRUE) && $dbItem['priority'] > $items[$name][$dbItem['hostname']]['severity'])) {
$items[$name][$dbItem['hostname']] = array('itemid' => $dbItem['itemid'], 'value_type' => $dbItem['value_type'], 'value' => isset($history[$dbItem['itemid']]) ? $history[$dbItem['itemid']][0]['value'] : null, 'units' => $dbItem['units'], 'name' => $name, 'valuemapid' => $dbItem['valuemapid'], 'severity' => $dbItem['priority'], 'tr_value' => $dbItem['tr_value'], 'triggerid' => $dbItem['triggerid']);
}
}
$table = new CTableInfo(_('No items found.'));
if (empty($hostNames)) {
return $table;
}
$table->makeVerticalRotation();
order_result($hostNames);
if ($viewMode == STYLE_TOP) {
$header = array(new CCol(_('Items'), 'center'));
foreach ($hostNames as $hostName) {
$header[] = new CCol($hostName, 'vertical_rotation');
}
$table->setHeader($header, 'vertical_header');
foreach ($items as $descr => $ithosts) {
$tableRow = array(nbsp($descr));
foreach ($hostNames as $hostName) {
$tableRow = getItemDataOverviewCells($tableRow, $ithosts, $hostName);
}
$table->addRow($tableRow);
}
} else {
$scripts = API::Script()->getScriptsByHosts(zbx_objectValues($hosts, 'hostid'));
$header = array(new CCol(_('Hosts'), 'center'));
foreach ($items as $descr => $ithosts) {
$header[] = new CCol($descr, 'vertical_rotation');
}
$table->setHeader($header, 'vertical_header');
foreach ($hostNames as $hostId => $hostName) {
$host = $hosts[$hostId];
$name = new CSpan($host['name'], 'link_menu');
$name->setMenuPopup(getMenuPopupHost($host, $scripts[$hostId]));
$tableRow = array(new CCol($name));
foreach ($items as $ithosts) {
$tableRow = getItemDataOverviewCells($tableRow, $ithosts, $hostName);
}
$table->addRow($tableRow);
}
}
return $table;
}
示例5: CWidget
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
$hostInventoryWidget = new CWidget(null, 'inventory-host');
$hostInventoryWidget->addPageHeader(_('HOST INVENTORY'), SPACE);
$hostInventoriesForm = new CForm();
/*
* Overview tab
*/
$overviewFormList = new CFormList();
$hostSpan = new CSpan($this->data['host']['host'], 'link_menu menu-host');
$hostSpan->setMenuPopup(getMenuPopupHost($this->data['host'], $this->data['hostScripts'][$this->data['host']['hostid']], false));
$hostName = $this->data['host']['maintenance_status'] == HOST_MAINTENANCE_STATUS_ON ? array($hostSpan, SPACE, new CDiv(null, 'icon-maintenance-inline')) : $hostSpan;
$overviewFormList->addRow(_('Host name'), $hostName);
if ($this->data['host']['host'] != $this->data['host']['name']) {
$overviewFormList->addRow(_('Visible name'), new CSpan($this->data['host']['name'], 'text-field'));
}
$agentInterfaceRows = array();
$snmpInterfaceRows = array();
$ipmiInterfaceRows = array();
$jmxInterfaceRows = array();
foreach ($this->data['host']['interfaces'] as $interface) {
$spanClass = $interface['main'] ? ' default_interface' : null;
switch ($interface['type']) {
case INTERFACE_TYPE_AGENT:
$agentInterfaceRows[] = new CRow(array(new CDiv($interface['ip'], 'ip' . $spanClass), new CDiv($interface['dns'], 'dns' . $spanClass), new CDiv($interface['useip'] == 1 ? _('IP') : _('DNS'), 'useip' . $spanClass), new CDiv($interface['port'], 'port' . $spanClass)));
break;
示例6: CDiv
$host = $hosts[$dbHost['hostid']];
if (!isset($tab_rows[$hostId])) {
continue;
}
$appRows = $tab_rows[$hostId];
$openState = CProfile::get('web.latest.toggle_other', null, $host['hostid']);
$toggle = new CDiv(null, 'app-list-toggle icon-plus-9x9');
if ($openState) {
$toggle->addClass('icon-minus-9x9');
}
$toggle->setAttribute('data-app-id', '0_' . $host['hostid']);
$toggle->setAttribute('data-open-state', $openState);
$hostName = null;
if (!$singleHostSelected) {
$hostName = new CSpan($host['name'], 'link_menu menu-host' . ($host['status'] == HOST_STATUS_NOT_MONITORED ? ' not-monitored' : ''));
$hostName->setMenuPopup(CMenuPopupHelper::getHost($host, $hostScripts[$host['hostid']]));
}
// add toggle row
$table->addRow(array($toggle, '', $hostName, new CCol(array(bold('- ' . 'other' . ' -'), ' (' . _n('%1$s Item', '%1$s Items', $dbHost['item_cnt']) . ')'), null, $filter['showDetails'] ? 10 : 5)), 'odd_row');
// add toggle sub rows
foreach ($appRows as $row) {
$row->setAttribute('parent_app_id', '0_' . $host['hostid']);
$row->addClass('odd_row');
if (!$openState) {
$row->addClass('hidden');
}
$table->addRow($row);
}
}
$goBox = new CComboBox('graphtype', GRAPH_TYPE_STACKED, null, array(GRAPH_TYPE_STACKED => _('Display stacked graph'), GRAPH_TYPE_NORMAL => _('Display graph')));
$goBox->setAttribute('id', 'action');
示例7: dbConditionInt
}
$sql .= ' AND ' . dbConditionInt('t.flags', array(ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED)) . ' GROUP BY e.objectid' . ' ORDER BY cnt_event desc';
$result = DBselect($sql, 100);
while ($row = DBfetch($result)) {
$triggersEventCount[$row['objectid']] = $row['cnt_event'];
}
$triggers = API::Trigger()->get(array('triggerids' => array_keys($triggersEventCount), 'output' => array('triggerid', 'description', 'expression', 'priority', 'flags', 'url', 'lastchange'), 'selectItems' => array('hostid', 'name', 'value_type', 'key_'), 'selectHosts' => array('hostid'), 'expandDescription' => true, 'expandData' => true, 'preservekeys' => true, 'nopermissions' => true));
$hostIds = array();
foreach ($triggers as $triggerId => $trigger) {
$hostIds[$trigger['hostid']] = $trigger['hostid'];
$triggerItems = array();
foreach ($trigger['items'] as $item) {
$triggerItems[] = array('name' => itemName($item), 'params' => array('itemid' => $item['itemid'], 'action' => in_array($item['value_type'], array(ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64)) ? 'showgraph' : 'showvalues'));
}
$triggers[$triggerId]['items'] = $triggerItems;
$triggers[$triggerId]['cnt_event'] = $triggersEventCount[$triggerId];
}
CArrayHelper::sort($triggers, array(array('field' => 'cnt_event', 'order' => ZBX_SORT_DOWN), 'host', 'description', 'priority'));
$hosts = API::Host()->get(array('output' => array('hostid'), 'hostids' => $hostIds, 'selectScreens' => API_OUTPUT_COUNT, 'preservekeys' => true));
$scripts = API::Script()->getScriptsByHosts($hostIds);
foreach ($triggers as $trigger) {
$hostId = $trigger['hostid'];
$hostName = new CSpan($trigger['hostname'], 'link_menu');
$hostName->setMenuPopup(getMenuPopupHost($hosts[$hostId], $scripts[$hostId]));
$triggerDescription = new CSpan($trigger['description'], 'link_menu');
$triggerDescription->setMenuPopup(getMenuPopupTrigger($trigger, $trigger['items']));
$table->addRow(array(get_node_name_by_elid($trigger['triggerid']), $hostName, $triggerDescription, getSeverityCell($trigger['priority']), $trigger['cnt_event']));
}
$rprt_wdgt->addItem($table);
$rprt_wdgt->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
示例8: make_hint_row
function make_hint_row($type, $instance)
{
$state = $instance['state'];
if ($type == "other" && $instance["stuck_state"] == 1) {
$state = "stuck";
}
$r = new CRow();
if (in_array($type, array("poweron", "poweroff", "suspend"))) {
$r->addItem(new CCheckBox("hostids[]", null, null, $instance['hostid']));
}
$hostScripts = API::Script()->getScriptsByHosts(zbx_objectValues(array($instance['host']), 'hostid'));
$hostSpan = new CSpan(nbsp($instance['name']), 'link_menu menu-host');
$hostSpan->setMenuPopup(getMenuPopupHost($instance['host'], $hostScripts[$instance['hostid']]));
$r->addItem($hostSpan);
$r->addItem(new CCol($state, get_item_level($state)));
$r->addItem($instance['cpu']);
$r->addItem($instance['memory']);
$r->addItem($instance['main_interface']);
if ($type == "other" && $instance["stuck_state"] == 1) {
$question = $instance['stuck_question'];
$json = new CJSON();
$choiceinfos = $json->decode($instance['stuck_choices'], true);
$answer_form = new CForm();
$answer_form->setAction('#');
$answer_form->setAttribute('id', "answer");
$answer_form->addVar("driver", "vsphere");
$answer_form->addVar("hostids[]", $instance['hostid']);
$instancename = $instance['host']['host'];
$answer_button = new CButton('answer', _('Answer'), "return checkAnswer('answer', 'choice', '{$instancename}', 'Execute');");
$choice_table = new CTableInfo();
foreach ($choiceinfos as $choice) {
$radio = new CRadioButton('choice', $choice['key']);
$label = new CLabel($choice['label']);
$choice_table->addRow(new CRow(array($radio, $label)));
}
$answer_form->addItem($choice_table);
$answer_form->addItem($answer_button);
$question_span = new CSpan($question);
$question_span->setHint($answer_form);
$question_col = new CCol($question_span, 'warning');
$r->addItem($question_col);
} else {
if ($type == "poweron") {
$ssh_link = new CLink(_('connect'), "gateone.php?hostid={$instance['hostid']}");
$ssh_link->setTarget("_blank");
$r->addItem($ssh_link);
}
}
return $r;
}
示例9: array
$description = array($img, SPACE, $description);
}
unset($img, $dependenciesTable, $dependency);
$triggerDescription = new CSpan($description, 'pointer');
// host js menu
$hostList = array();
foreach ($trigger['hosts'] as $triggerHost) {
// fetch scripts for the host js menu
$scripts = array();
if (isset($scriptsByHosts[$triggerHost['hostid']])) {
foreach ($scriptsByHosts[$triggerHost['hostid']] as $script) {
$scripts[] = $script;
}
}
$hostName = new CSpan($triggerHost['name'], 'link_menu');
$hostName->setMenuPopup(getMenuPopupHost($hosts[$triggerHost['hostid']], $scripts));
$hostDiv = new CDiv($hostName);
// add maintenance icon with hint if host is in maintenance
if ($triggerHost['maintenance_status']) {
$maintenanceIcon = new CDiv(null, 'icon-maintenance-inline');
$maintenances = API::Maintenance()->get(array('maintenanceids' => $triggerHost['maintenanceid'], 'output' => API_OUTPUT_EXTEND, 'limit' => 1));
if ($maintenance = reset($maintenances)) {
$hint = $maintenance['name'] . ' [' . ($triggerHost['maintenance_type'] ? _('Maintenance without data collection') : _('Maintenance with data collection')) . ']';
if (isset($maintenance['description'])) {
// double quotes mandatory
$hint .= "\n" . $maintenance['description'];
}
$maintenanceIcon->setHint($hint);
$maintenanceIcon->addClass('pointer');
}
$hostDiv->addItem($maintenanceIcon);
示例10: 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;
}
示例11: array
}
$description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, array('clock' => $event['clock'], 'ns' => $event['ns'])));
$triggerDescription = new CSpan($description, 'pointer link_menu');
$triggerDescription->setMenuPopup(getMenuPopupTrigger($trigger, $triggerItems, null, $event['clock']));
// acknowledge
$ack = getEventAckState($event, true);
// duration
$event['duration'] = ($nextEvent = get_next_event($event, $events)) ? zbx_date2age($event['clock'], $nextEvent['clock']) : zbx_date2age($event['clock']);
$statusSpan = new CSpan(trigger_value2str($event['value']));
// add colors and blinking to span depending on configuration and trigger parameters
addTriggerValueStyle($statusSpan, $event['value'], $event['clock'], $event['acknowledged']);
// host JS menu link
$hostName = null;
if ($_REQUEST['hostid'] == 0) {
$hostName = new CSpan($host['name'], 'link_menu');
$hostName->setMenuPopup(getMenuPopupHost($host, $scripts[$host['hostid']]));
}
// action
$action = isset($actions[$event['eventid']]) ? $actions[$event['eventid']] : ' - ';
$table->addRow(array(new CLink(zbx_date2str(EVENTS_ACTION_TIME_FORMAT, $event['clock']), 'tr_events.php?triggerid=' . $event['objectid'] . '&eventid=' . $event['eventid'], 'action'), is_show_all_nodes() ? get_node_name_by_elid($event['objectid']) : null, $hostName, $triggerDescription, $statusSpan, getSeverityCell($trigger['priority'], null, !$event['value']), $event['duration'], $config['event_ack_enable'] ? $ack : null, $action));
if ($CSV_EXPORT) {
$csvRows[] = array(zbx_date2str(EVENTS_ACTION_TIME_FORMAT, $event['clock']), is_show_all_nodes() ? get_node_name_by_elid($event['objectid']) : null, $_REQUEST['hostid'] == 0 ? $host['name'] : null, $description, trigger_value2str($event['value']), getSeverityCaption($trigger['priority']), $event['duration'], $config['event_ack_enable'] ? $event['acknowledges'] ? _('Yes') : _('No') : null, strip_tags((string) $action));
}
}
} else {
$events = array();
$paging = getPagingLine($events);
}
}
if ($CSV_EXPORT) {
print zbx_toCSV($csvRows);
示例12: array
$description = array($img, SPACE, $description);
}
unset($img, $dependenciesTable, $dependency);
$triggerDescription = new CSpan($description, 'pointer');
// host js menu
$hostList = array();
foreach ($trigger['hosts'] as $triggerHost) {
// fetch scripts for the host js menu
$scripts = array();
if (isset($scriptsByHosts[$triggerHost['hostid']])) {
foreach ($scriptsByHosts[$triggerHost['hostid']] as $script) {
$scripts[] = $script;
}
}
$hostName = new CSpan($triggerHost['name'], 'link_menu');
$hostName->setMenuPopup(CMenuPopupHelper::getHost($hosts[$triggerHost['hostid']], $scripts));
$hostDiv = new CDiv($hostName);
// add maintenance icon with hint if host is in maintenance
if ($triggerHost['maintenance_status']) {
$maintenanceIcon = new CDiv(null, 'icon-maintenance-inline');
$maintenances = API::Maintenance()->get(array('maintenanceids' => $triggerHost['maintenanceid'], 'output' => API_OUTPUT_EXTEND, 'limit' => 1));
if ($maintenance = reset($maintenances)) {
$hint = $maintenance['name'] . ' [' . ($triggerHost['maintenance_type'] ? _('Maintenance without data collection') : _('Maintenance with data collection')) . ']';
if (isset($maintenance['description'])) {
// double quotes mandatory
$hint .= "\n" . $maintenance['description'];
}
$maintenanceIcon->setHint($hint);
$maintenanceIcon->addClass('pointer');
}
$hostDiv->addItem($maintenanceIcon);
示例13: 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;
}
示例14: dbConditionInt
$sql .= ' AND ' . dbConditionInt('t.flags', array(ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED)) . ' GROUP BY e.objectid' . ' ORDER BY cnt_event desc';
$result = DBselect($sql, 100);
while ($row = DBfetch($result)) {
$triggersEventCount[$row['objectid']] = $row['cnt_event'];
}
$triggers = API::Trigger()->get(array('triggerids' => array_keys($triggersEventCount), 'output' => array('triggerid', 'description', 'expression', 'priority', 'flags', 'url', 'lastchange'), 'selectItems' => array('hostid', 'name', 'value_type', 'key_'), 'selectHosts' => array('hostid', 'status', 'name'), 'expandDescription' => true, 'preservekeys' => true, 'nopermissions' => true));
$hostIds = array();
foreach ($triggers as $triggerId => $trigger) {
$hostIds[$trigger['hosts'][0]['hostid']] = $trigger['hosts'][0]['hostid'];
$triggerItems = array();
$trigger['items'] = CMacrosResolverHelper::resolveItemNames($trigger['items']);
foreach ($trigger['items'] as $item) {
$triggerItems[] = array('name' => $item['name_expanded'], 'params' => array('itemid' => $item['itemid'], 'action' => in_array($item['value_type'], array(ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64)) ? HISTORY_GRAPH : HISTORY_VALUES));
}
$triggers[$triggerId]['items'] = $triggerItems;
$triggers[$triggerId]['cnt_event'] = $triggersEventCount[$triggerId];
}
CArrayHelper::sort($triggers, array(array('field' => 'cnt_event', 'order' => ZBX_SORT_DOWN), 'host', 'description', 'priority'));
$hosts = API::Host()->get(array('output' => array('hostid', 'status'), 'hostids' => $hostIds, 'selectGraphs' => API_OUTPUT_COUNT, 'selectScreens' => API_OUTPUT_COUNT, 'preservekeys' => true));
$scripts = API::Script()->getScriptsByHosts($hostIds);
foreach ($triggers as $trigger) {
$hostId = $trigger['hosts'][0]['hostid'];
$hostName = new CSpan($trigger['hosts'][0]['name'], 'link_menu menu-host' . ($hosts[$hostId]['status'] == HOST_STATUS_NOT_MONITORED ? ' not-monitored' : ''));
$hostName->setMenuPopup(CMenuPopupHelper::getHost($hosts[$hostId], $scripts[$hostId]));
$triggerDescription = new CSpan($trigger['description'], 'link_menu');
$triggerDescription->setMenuPopup(CMenuPopupHelper::getTrigger($trigger, $trigger['items']));
$table->addRow(array($hostName, $triggerDescription, getSeverityCell($trigger['priority']), $trigger['cnt_event']));
}
$rprt_wdgt->addItem($table);
$rprt_wdgt->show();
require_once dirname(__FILE__) . '/include/page_footer.php';