当前位置: 首页>>代码示例>>PHP>>正文


PHP API::Maintenance方法代码示例

本文整理汇总了PHP中API::Maintenance方法的典型用法代码示例。如果您正苦于以下问题:PHP API::Maintenance方法的具体用法?PHP API::Maintenance怎么用?PHP API::Maintenance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在API的用法示例。


在下文中一共展示了API::Maintenance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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');
        }
//.........这里部分代码省略.........
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:101,代码来源:blocks.inc.php

示例2: getPageSortField

    $maintenanceView->show();
} else {
    $sortfield = getPageSortField('name');
    $sortorder = getPageSortOrder();
    // get only maintenance IDs for paging
    $options = array('output' => array('maintenanceid', $sortfield), 'editable' => true, 'sortfield' => $sortfield, 'limit' => $config['search_limit'] + 1);
    if ($pageFilter->groupsSelected && $pageFilter->groupid > 0) {
        $options['groupids'] = $pageFilter->groupid;
    } else {
        $options['groupids'] = $config['dropdown_first_entry'] ? null : array();
    }
    $data['maintenances'] = API::Maintenance()->get($options);
    order_result($data['maintenances'], $sortfield, $sortorder);
    $data['paging'] = getPagingLine($data['maintenances'], array('maintenanceid'));
    // get list of maintenances
    $data['maintenances'] = API::Maintenance()->get(array('maintenanceids' => zbx_objectValues($data['maintenances'], 'maintenanceid'), 'output' => API_OUTPUT_EXTEND));
    foreach ($data['maintenances'] as $number => $maintenance) {
        if ($maintenance['active_till'] < time()) {
            $data['maintenances'][$number]['status'] = MAINTENANCE_STATUS_EXPIRED;
        } elseif ($maintenance['active_since'] > time()) {
            $data['maintenances'][$number]['status'] = MAINTENANCE_STATUS_APPROACH;
        } else {
            $data['maintenances'][$number]['status'] = MAINTENANCE_STATUS_ACTIVE;
        }
    }
    order_result($data['maintenances'], $sortfield, $sortorder);
    $data['pageFilter'] = $pageFilter;
    // nodes
    if ($data['displayNodes']) {
        foreach ($data['maintenances'] as &$maintenance) {
            $maintenance['nodename'] = get_node_name_by_elid($maintenance['maintenanceid'], true);
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:maintenance.php

示例3: getHostInventories

if ($hostId > 0) {
    $data = [];
    // host scripts
    $data['hostScripts'] = API::Script()->getScriptsByHosts([$hostId]);
    // inventory info
    $data['tableTitles'] = getHostInventories();
    $data['tableTitles'] = zbx_toHash($data['tableTitles'], 'db_field');
    $inventoryFields = array_keys($data['tableTitles']);
    // overview tab
    $data['host'] = API::Host()->get(['output' => ['hostid', 'host', 'name', 'status', 'maintenance_status', 'maintenanceid', 'maintenance_type', 'description'], 'selectInterfaces' => API_OUTPUT_EXTEND, 'selectItems' => API_OUTPUT_COUNT, 'selectTriggers' => API_OUTPUT_COUNT, 'selectScreens' => API_OUTPUT_COUNT, 'selectInventory' => $inventoryFields, 'selectGraphs' => API_OUTPUT_COUNT, 'selectApplications' => API_OUTPUT_COUNT, 'selectDiscoveries' => API_OUTPUT_COUNT, 'selectHttpTests' => API_OUTPUT_COUNT, 'hostids' => $hostId, 'preservekeys' => true]);
    $data['host'] = reset($data['host']);
    unset($data['host']['inventory']['hostid']);
    // resolve macros
    $data['host']['interfaces'] = CMacrosResolverHelper::resolveHostInterfaces($data['host']['interfaces']);
    if ($data['host']['maintenance_status'] == HOST_MAINTENANCE_STATUS_ON) {
        $data['maintenances'] = API::Maintenance()->get(['maintenanceids' => [$data['host']['maintenanceid']], 'output' => ['name', 'description'], 'preservekeys' => true]);
    }
    // get permissions
    $userType = CWebUser::getType();
    if ($userType == USER_TYPE_SUPER_ADMIN) {
        $data['rwHost'] = true;
    } elseif ($userType == USER_TYPE_ZABBIX_ADMIN) {
        $rwHost = API::Host()->get(['output' => ['hostid'], 'hostids' => $hostId, 'editable' => true]);
        $data['rwHost'] = (bool) $rwHost;
    } else {
        $data['rwHost'] = false;
    }
    // view generation
    $hostinventoriesView = new CView('inventory.host.view', $data);
    $hostinventoriesView->render();
    $hostinventoriesView->show();
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:hostinventories.php

示例4: update

 /**
  * Update maintenances
  *
  * @param array $maintenances
  * @return boolean
  */
 public function update(array $maintenances)
 {
     $maintenances = zbx_toArray($maintenances);
     $maintenanceids = zbx_objectValues($maintenances, 'maintenanceid');
     // validate maintenance permissions
     if (self::$userData['type'] == USER_TYPE_ZABBIX_USER) {
         self::exception(ZBX_API_ERROR_PERMISSIONS, _('No permissions to referred object or it does not exist!'));
     }
     $hostids = array();
     $groupids = array();
     $updMaintenances = $this->get(array('maintenanceids' => zbx_objectValues($maintenances, 'maintenanceid'), 'editable' => true, 'output' => API_OUTPUT_EXTEND, 'selectGroups' => API_OUTPUT_REFER, 'selectHosts' => API_OUTPUT_REFER, 'selectTimeperiods' => API_OUTPUT_EXTEND, 'preservekeys' => true));
     foreach ($maintenances as $maintenance) {
         if (!isset($updMaintenances[$maintenance['maintenanceid']])) {
             self::exception(ZBX_API_ERROR_PERMISSIONS, _('No permissions to referred object or it does not exist!'));
         }
         // Checking whether a maintenance with this name already exists. First, getting all maintenances with the same name as this
         $receivedMaintenances = API::Maintenance()->get(array('filter' => array('name' => $maintenance['name'])));
         // validate if maintenance name already exists
         foreach ($receivedMaintenances as $rMaintenance) {
             if (bccomp($rMaintenance['maintenanceid'], $maintenance['maintenanceid']) != 0) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Maintenance "%s" already exists.', $maintenance['name']));
             }
         }
         // validate maintenance active since
         if (!validateUnixTime($maintenance['active_since'])) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('"%s" must be between 1970.01.01 and 2038.01.18.', _('Active since')));
         }
         // validate maintenance active till
         if (!validateUnixTime($maintenance['active_till'])) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('"%s" must be between 1970.01.01 and 2038.01.18.', _('Active till')));
         }
         // validate maintenance active interval
         if ($maintenance['active_since'] > $maintenance['active_till']) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Maintenance "Active since" value cannot be bigger than "Active till".'));
         }
         // validate timeperiods
         if (empty($maintenance['timeperiods'])) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('At least one maintenance period must be created.'));
         }
         $hostids = array_merge($hostids, $maintenance['hostids']);
         $groupids = array_merge($groupids, $maintenance['groupids']);
     }
     // validate hosts & groups
     if (empty($hostids) && empty($groupids)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('At least one host or group should be selected.'));
     }
     // validate hosts permissions
     $options = array('hostids' => $hostids, 'editable' => true, 'output' => array('hostid'), 'preservekeys' => true);
     $updHosts = API::Host()->get($options);
     foreach ($hostids as $hostid) {
         if (!isset($updHosts[$hostid])) {
             self::exception(ZBX_API_ERROR_PERMISSIONS, _('You do not have permission to perform this operation.'));
         }
     }
     // validate groups permissions
     $options = array('groupids' => $groupids, 'editable' => true, 'output' => array('groupid'), 'preservekeys' => true);
     $updGroups = API::HostGroup()->get($options);
     foreach ($groupids as $groupid) {
         if (!isset($updGroups[$groupid])) {
             self::exception(ZBX_API_ERROR_PERMISSIONS, _('No permissions to referred object or it does not exist!'));
         }
     }
     $this->removeSecondsFromTimes($maintenances);
     $update = array();
     foreach ($maintenances as $mnum => $maintenance) {
         $dbFields = array('maintenanceid' => null);
         // validate fields
         if (!check_db_fields($dbFields, $maintenance)) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect parameters for maintenance.'));
         }
         $update[$mnum] = array('values' => $maintenance, 'where' => array('maintenanceid' => $maintenance['maintenanceid']));
         // update time periods
         $this->replaceTimePeriods($updMaintenances[$maintenance['maintenanceid']], $maintenance);
     }
     DB::update('maintenances', $update);
     // some of the hosts and groups bound to maintenance must be deleted, other inserted and others left alone
     $insertHosts = array();
     $insertGroups = array();
     foreach ($maintenances as $maintenance) {
         // putting apart those host<->maintenance connections that should be inserted, deleted and not changed
         // $hostDiff['first'] - new hosts, that should be inserted
         // $hostDiff['second'] - hosts, that should be deleted
         // $hostDiff['both'] - hosts, that should not be touched
         $hostDiff = zbx_array_diff(zbx_toObject($maintenance['hostids'], 'hostid'), $updMaintenances[$maintenance['maintenanceid']]['hosts'], 'hostid');
         foreach ($hostDiff['first'] as $host) {
             $insertHosts[] = array('hostid' => $host['hostid'], 'maintenanceid' => $maintenance['maintenanceid']);
         }
         foreach ($hostDiff['second'] as $host) {
             $deleteHosts = array('hostid' => $host['hostid'], 'maintenanceid' => $maintenance['maintenanceid']);
             DB::delete('maintenances_hosts', $deleteHosts);
         }
         // now the same with the groups
         $groupDiff = zbx_array_diff(zbx_toObject($maintenance['groupids'], 'groupid'), $updMaintenances[$maintenance['maintenanceid']]['groups'], 'groupid');
         foreach ($groupDiff['first'] as $group) {
//.........这里部分代码省略.........
开发者ID:itnihao,项目名称:Zabbix_,代码行数:101,代码来源:CMaintenance.php

示例5: 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['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 $backurl
 *
 * @return CDiv
 */
function make_latest_issues(array $filter = [], $backurl)
{
    // hide the sort indicator if no sortfield and sortorder are given
    $show_sort_indicator = isset($filter['sortfield']) || isset($filter['sortorder']);
    if (isset($filter['sortfield']) && $filter['sortfield'] !== 'lastchange') {
        $sort_field = [$filter['sortfield'], 'lastchange'];
        $sort_order = [$filter['sortorder'], ZBX_SORT_DOWN];
    } else {
        $sort_field = ['lastchange'];
        $sort_order = [ZBX_SORT_DOWN];
    }
    $options = ['groupids' => $filter['groupids'], 'hostids' => isset($filter['hostids']) ? $filter['hostids'] : null, 'monitored' => true, 'maintenance' => $filter['maintenance'], 'search' => $filter['trigger_name'] !== '' ? ['description' => $filter['trigger_name']] : null, 'filter' => ['priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE]];
    $triggers = API::Trigger()->get(array_merge($options, ['output' => ['triggerid', 'expression', 'description', 'url', 'priority', 'lastchange', 'comments', 'error', 'state'], 'selectHosts' => ['hostid'], 'selectLastEvent' => ['eventid', 'acknowledged', 'objectid', 'clock', 'ns'], 'withLastEventUnacknowledged' => isset($filter['extAck']) && $filter['extAck'] == EXTACK_OPTION_UNACK ? true : null, 'skipDependent' => true, 'sortfield' => $sort_field, 'sortorder' => $sort_order, 'limit' => isset($filter['limit']) ? $filter['limit'] : DEFAULT_LATEST_ISSUES_CNT, 'preservekeys' => true, 'expandComment' => true]));
    $triggers = CMacrosResolverHelper::resolveTriggerUrls($triggers);
    // don't use withLastEventUnacknowledged and skipDependent because of performance issues
    $triggers_total_count = API::Trigger()->get(array_merge($options, ['countOutput' => true]));
    // get acknowledges
    $hostids = [];
    $eventids = [];
    foreach ($triggers as $trigger) {
        foreach ($trigger['hosts'] as $host) {
            $hostids[$host['hostid']] = true;
        }
        if ($trigger['lastEvent']) {
            $eventids[] = $trigger['lastEvent']['eventid'];
        }
    }
    $config = select_config();
    if ($config['event_ack_enable'] && $eventids) {
        $event_acknowledges = API::Event()->get(['output' => ['eventid'], 'eventids' => $eventids, 'select_acknowledges' => API_OUTPUT_EXTEND, 'preservekeys' => true]);
    }
    // actions
    $actions = makeEventsActions($eventids);
    // indicator of sort field
    if ($show_sort_indicator) {
        $sort_div = (new CDiv())->addClass($filter['sortorder'] === ZBX_SORT_DOWN ? ZBX_STYLE_ARROW_DOWN : ZBX_STYLE_ARROW_UP);
    }
    $table = (new CTableInfo())->setHeader([$show_sort_indicator && $filter['sortfield'] === 'hostname' ? [_('Host'), $sort_div] : _('Host'), $show_sort_indicator && $filter['sortfield'] === 'priority' ? [_('Issue'), $sort_div] : _('Issue'), $show_sort_indicator && $filter['sortfield'] === 'lastchange' ? [_('Last change'), $sort_div] : _('Last change'), _('Age'), _('Info'), $config['event_ack_enable'] ? _('Ack') : null, _('Actions')]);
    $hostids = array_keys($hostids);
    $scripts = API::Script()->getScriptsByHosts($hostids);
    // get hosts
    $hosts = API::Host()->get(['hostids' => $hostids, 'output' => ['hostid', 'name', 'status', 'maintenance_status', 'maintenance_type', 'maintenanceid'], 'selectGraphs' => API_OUTPUT_COUNT, 'selectScreens' => API_OUTPUT_COUNT, 'preservekeys' => true]);
    $maintenanceids = [];
    foreach ($hosts as $host) {
        if ($host['maintenance_status'] == HOST_MAINTENANCE_STATUS_ON) {
            $maintenanceids[$host['maintenanceid']] = true;
        }
    }
    if ($maintenanceids) {
        $maintenances = API::Maintenance()->get(['maintenanceids' => array_keys($maintenanceids), 'output' => ['name', 'description'], 'preservekeys' => true]);
    }
    // triggers
    foreach ($triggers as $trigger) {
        $host_list = [];
        foreach ($trigger['hosts'] as $trigger_host) {
            $host = $hosts[$trigger_host['hostid']];
            $host_name = (new CSpan($host['name']))->addClass(ZBX_STYLE_LINK_ACTION)->setMenuPopup(CMenuPopupHelper::getHost($host, $scripts[$host['hostid']]));
            if ($host['maintenance_status'] == HOST_MAINTENANCE_STATUS_ON) {
                $maintenance_icon = (new CSpan())->addClass(ZBX_STYLE_ICON_MAINT)->addClass(ZBX_STYLE_CURSOR_POINTER);
                if (array_key_exists($host['maintenanceid'], $maintenances)) {
                    $maintenance = $maintenances[$host['maintenanceid']];
                    $hint = $maintenance['name'] . ' [' . ($host['maintenance_type'] ? _('Maintenance without data collection') : _('Maintenance with data collection')) . ']';
                    if ($maintenance['description']) {
                        $hint .= "\n" . $maintenance['description'];
                    }
                    $maintenance_icon->setHint($hint);
                }
                $host_name = (new CSpan([$host_name, $maintenance_icon]))->addClass(ZBX_STYLE_REL_CONTAINER);
            }
            $host_list[] = $host_name;
            $host_list[] = ', ';
        }
        array_pop($host_list);
        // unknown triggers
        $unknown = '';
        if ($trigger['state'] == TRIGGER_STATE_UNKNOWN) {
            $unknown = makeUnknownIcon($trigger['error']);
        }
        // trigger has events
        if ($trigger['lastEvent']) {
            // description
            $description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, ['clock' => $trigger['lastEvent']['clock'], 'ns' => $trigger['lastEvent']['ns']]));
        } else {
//.........这里部分代码省略.........
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:blocks.inc.php

示例6: array

 $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);
     }
     // add comma after hosts, except last
     if (next($trigger['hosts'])) {
         $hostDiv->addItem(',' . SPACE);
     }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:tr_status.php

示例7: getPageSortField

    $maintenanceView->show();
} else {
    // get maintenances
    $sortfield = getPageSortField('name');
    $sortorder = getPageSortOrder();
    $options = array('output' => API_OUTPUT_EXTEND, 'editable' => true, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'limit' => $config['search_limit'] + 1);
    if ($pageFilter->groupsSelected) {
        if ($pageFilter->groupid > 0) {
            $options['groupids'] = $pageFilter->groupid;
        } else {
            $options['groupids'] = array_keys($pageFilter->groups);
        }
    } else {
        $options['groupids'] = array();
    }
    $data['maintenances'] = API::Maintenance()->get($options);
    foreach ($data['maintenances'] as $number => $maintenance) {
        if ($maintenance['active_till'] < time()) {
            $data['maintenances'][$number]['status'] = MAINTENANCE_STATUS_EXPIRED;
        } elseif ($maintenance['active_since'] > time()) {
            $data['maintenances'][$number]['status'] = MAINTENANCE_STATUS_APPROACH;
        } else {
            $data['maintenances'][$number]['status'] = MAINTENANCE_STATUS_ACTIVE;
        }
    }
    order_result($data['maintenances'], $sortfield, $sortorder);
    $data['paging'] = getPagingLine($data['maintenances'], array('maintenanceid'));
    $data['pageFilter'] = $pageFilter;
    // nodes
    if ($data['displayNodes']) {
        foreach ($data['maintenances'] as &$maintenance) {
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:31,代码来源:maintenance.php

示例8: DBselect

// get trigger dependencies
$dbTriggerDependencies = DBselect('SELECT triggerid_down,triggerid_up' . ' FROM trigger_depends' . ' WHERE ' . dbConditionInt('triggerid_up', $triggerIds));
$triggerIdsDown = [];
while ($row = DBfetch($dbTriggerDependencies)) {
    $triggerIdsDown[$row['triggerid_up']][] = intval($row['triggerid_down']);
}
$maintenanceids = [];
foreach ($triggers as $trigger) {
    foreach ($trigger['hosts'] as $host) {
        if ($host['maintenance_status'] == HOST_MAINTENANCE_STATUS_ON) {
            $maintenanceids[$host['maintenanceid']] = true;
        }
    }
}
if ($maintenanceids) {
    $maintenances = API::Maintenance()->get(['maintenanceids' => array_keys($maintenanceids), 'output' => ['name', 'description'], 'preservekeys' => true]);
}
foreach ($triggers as $trigger) {
    /*
     * At this point "all" or one group is selected. And same goes for hosts. It is safe to pass 'groupid' and 'hostid'
     * to trigger menu pop-up, so it properly redirects to Events page. Mind that 'DDRemember' option will be ignored.
     */
    $trigger['groupid'] = $pageFilter->groupid;
    $trigger['hostid'] = $pageFilter->hostid;
    $description = [];
    if (!empty($trigger['dependencies'])) {
        $dependenciesTable = (new CTable())->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_STANDARD_WIDTH . 'px;')->addRow(_('Depends on') . ':');
        foreach ($trigger['dependencies'] as $dependency) {
            $dependenciesTable->addRow(' - ' . CMacrosResolverHelper::resolveTriggerNameById($dependency['triggerid']));
        }
        $description[] = (new CSpan())->addClass(ZBX_STYLE_ICON_DEPEND_DOWN)->addClass(ZBX_STYLE_CURSOR_POINTER)->setHint($dependenciesTable);
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:tr_status.php


注:本文中的API::Maintenance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。