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


PHP select_config函数代码示例

本文整理汇总了PHP中select_config函数的典型用法代码示例。如果您正苦于以下问题:PHP select_config函数的具体用法?PHP select_config怎么用?PHP select_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了select_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doAction

 protected function doAction()
 {
     $sortField = $this->getInput('sort', CProfile::get('web.proxies.php.sort', 'host'));
     $sortOrder = $this->getInput('sortorder', CProfile::get('web.proxies.php.sortorder', ZBX_SORT_UP));
     CProfile::update('web.proxies.php.sort', $sortField, PROFILE_TYPE_STR);
     CProfile::update('web.proxies.php.sortorder', $sortOrder, PROFILE_TYPE_STR);
     $config = select_config();
     $data = ['uncheck' => $this->hasInput('uncheck'), 'sort' => $sortField, 'sortorder' => $sortOrder, 'config' => ['max_in_table' => $config['max_in_table']]];
     $data['proxies'] = API::Proxy()->get(['output' => ['proxyid', 'host', 'status', 'lastaccess', 'tls_connect', 'tls_accept'], 'selectHosts' => ['hostid', 'name', 'status'], 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1, 'editable' => true, 'preservekeys' => true]);
     // sorting & paging
     order_result($data['proxies'], $sortField, $sortOrder);
     $url = (new CUrl('zabbix.php'))->setArgument('action', 'proxy.list');
     $data['paging'] = getPagingLine($data['proxies'], $sortOrder, $url);
     foreach ($data['proxies'] as &$proxy) {
         order_result($proxy['hosts'], 'name');
     }
     unset($proxy);
     // get proxy IDs for a *selected* page
     $proxyIds = array_keys($data['proxies']);
     if ($proxyIds) {
         // calculate performance
         $dbPerformance = DBselect('SELECT h.proxy_hostid,SUM(1.0/i.delay) AS qps' . ' FROM hosts h,items i' . ' WHERE h.hostid=i.hostid' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND i.delay<>0' . ' AND i.flags<>' . ZBX_FLAG_DISCOVERY_PROTOTYPE . ' AND ' . dbConditionInt('h.proxy_hostid', $proxyIds) . ' GROUP BY h.proxy_hostid');
         while ($performance = DBfetch($dbPerformance)) {
             $data['proxies'][$performance['proxy_hostid']]['perf'] = round($performance['qps'], 2);
         }
         // get items
         $items = API::Item()->get(['proxyids' => $proxyIds, 'groupCount' => true, 'countOutput' => true, 'webitems' => true, 'monitored' => true]);
         foreach ($items as $item) {
             $data['proxies'][$item['proxy_hostid']]['item_count'] = $item['rowscount'];
         }
     }
     $response = new CControllerResponseData($data);
     $response->setTitle(_('Configuration of proxies'));
     $this->setResponse($response);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:35,代码来源:CControllerProxyList.php

示例2: doAction

 protected function doAction()
 {
     $sortField = $this->getInput('sort', CProfile::get('web.media_types.php.sort', 'description'));
     $sortOrder = $this->getInput('sortorder', CProfile::get('web.media_types.php.sortorder', ZBX_SORT_UP));
     CProfile::update('web.media_type.php.sort', $sortField, PROFILE_TYPE_STR);
     CProfile::update('web.media_types.php.sortorder', $sortOrder, PROFILE_TYPE_STR);
     $config = select_config();
     $data = ['uncheck' => $this->hasInput('uncheck'), 'sort' => $sortField, 'sortorder' => $sortOrder];
     // get media types
     $data['mediatypes'] = API::Mediatype()->get(['output' => ['mediatypeid', 'description', 'type', 'smtp_server', 'smtp_helo', 'smtp_email', 'exec_path', 'gsm_modem', 'username', 'status'], 'limit' => $config['search_limit'] + 1, 'editable' => true, 'preservekeys' => true]);
     if ($data['mediatypes']) {
         // get media types used in actions
         $actions = API::Action()->get(['output' => ['actionid', 'name'], 'selectOperations' => ['operationtype', 'opmessage'], 'mediatypeids' => array_keys($data['mediatypes'])]);
         foreach ($data['mediatypes'] as &$mediaType) {
             $mediaType['typeid'] = $mediaType['type'];
             $mediaType['type'] = media_type2str($mediaType['type']);
             $mediaType['listOfActions'] = [];
             foreach ($actions as $action) {
                 foreach ($action['operations'] as $operation) {
                     if ($operation['operationtype'] == OPERATION_TYPE_MESSAGE && $operation['opmessage']['mediatypeid'] == $mediaType['mediatypeid']) {
                         $mediaType['listOfActions'][$action['actionid']] = ['actionid' => $action['actionid'], 'name' => $action['name']];
                     }
                 }
             }
             order_result($mediaType['listOfActions'], 'name');
         }
         unset($mediaType);
         order_result($data['mediatypes'], $sortField, $sortOrder);
     }
     $url = (new CUrl('zabbix.php'))->setArgument('action', 'mediatype.list');
     $data['paging'] = getPagingLine($data['mediatypes'], $sortOrder, $url);
     $response = new CControllerResponseData($data);
     $response->setTitle(_('Configuration of media types'));
     $this->setResponse($response);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:35,代码来源:CControllerMediatypeList.php

示例3: doAction

 protected function doAction()
 {
     $sortField = $this->getInput('sort', CProfile::get('web.scripts.php.sort', 'name'));
     $sortOrder = $this->getInput('sortorder', CProfile::get('web.scripts.php.sortorder', ZBX_SORT_UP));
     CProfile::update('web.scripts.php.sort', $sortField, PROFILE_TYPE_STR);
     CProfile::update('web.scripts.php.sortorder', $sortOrder, PROFILE_TYPE_STR);
     $config = select_config();
     $data = ['uncheck' => $this->hasInput('uncheck'), 'sort' => $sortField, 'sortorder' => $sortOrder];
     // list of scripts
     $data['scripts'] = API::Script()->get(['output' => ['scriptid', 'name', 'command', 'host_access', 'usrgrpid', 'groupid', 'type', 'execute_on'], 'editable' => true, 'limit' => $config['search_limit'] + 1]);
     // sorting & paging
     order_result($data['scripts'], $sortField, $sortOrder);
     $url = (new CUrl('zabbix.php'))->setArgument('action', 'script.list');
     $data['paging'] = getPagingLine($data['scripts'], $sortOrder, $url);
     // find script host group name and user group name. set to '' if all host/user groups used.
     $usrgrpids = [];
     $groupids = [];
     foreach ($data['scripts'] as &$script) {
         $script['userGroupName'] = null;
         // all user groups
         $script['hostGroupName'] = null;
         // all host groups
         if ($script['usrgrpid'] != 0) {
             $usrgrpids[] = $script['usrgrpid'];
         }
         if ($script['groupid'] != 0) {
             $groupids[] = $script['groupid'];
         }
     }
     unset($script);
     if ($usrgrpids) {
         $userGroups = API::UserGroup()->get(['output' => ['name'], 'usrgrpids' => $usrgrpids, 'preservekeys' => true]);
         foreach ($data['scripts'] as &$script) {
             if ($script['usrgrpid'] != 0 && array_key_exists($script['usrgrpid'], $userGroups)) {
                 $script['userGroupName'] = $userGroups[$script['usrgrpid']]['name'];
             }
             unset($script['usrgrpid']);
         }
         unset($script);
     }
     if ($groupids) {
         $hostGroups = API::HostGroup()->get(['output' => ['name'], 'groupids' => $groupids, 'preservekeys' => true]);
         foreach ($data['scripts'] as &$script) {
             if ($script['groupid'] != 0 && array_key_exists($script['groupid'], $hostGroups)) {
                 $script['hostGroupName'] = $hostGroups[$script['groupid']]['name'];
             }
             unset($script['groupid']);
         }
         unset($script);
     }
     $response = new CControllerResponseData($data);
     $response->setTitle(_('Configuration of scripts'));
     $this->setResponse($response);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:54,代码来源:CControllerScriptList.php

示例4: getUserTheme

/**
 * Find user theme or get default theme.
 *
 * @param array $userData
 *
 * @return string
 */
function getUserTheme($userData)
{
    $config = select_config();
    if (isset($config['default_theme'])) {
        $css = $config['default_theme'];
    }
    if (isset($userData['theme']) && $userData['theme'] != THEME_DEFAULT) {
        $css = $userData['theme'];
    }
    if (!isset($css)) {
        $css = ZBX_DEFAULT_THEME;
    }
    return $css;
}
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:21,代码来源:users.inc.php

示例5: doAction

 protected function doAction()
 {
     $filter = ['groupids' => null, 'maintenance' => null, 'severity' => null, 'trigger_name' => '', 'extAck' => 0];
     if (CProfile::get('web.dashconf.filter.enable', 0) == 1) {
         // groups
         if (CProfile::get('web.dashconf.groups.grpswitch', 0) == 0) {
             // null mean all groups
             $filter['groupids'] = null;
         } else {
             $filter['groupids'] = zbx_objectValues(CFavorite::get('web.dashconf.groups.groupids'), 'value');
             $hideHostGroupIds = zbx_objectValues(CFavorite::get('web.dashconf.groups.hide.groupids'), 'value');
             if ($hideHostGroupIds) {
                 // get all groups if no selected groups defined
                 if (!$filter['groupids']) {
                     $dbHostGroups = API::HostGroup()->get(['output' => ['groupid']]);
                     $filter['groupids'] = zbx_objectValues($dbHostGroups, 'groupid');
                 }
                 $filter['groupids'] = array_diff($filter['groupids'], $hideHostGroupIds);
                 // get available hosts
                 $dbAvailableHosts = API::Host()->get(['groupids' => $filter['groupids'], 'output' => ['hostid']]);
                 $availableHostIds = zbx_objectValues($dbAvailableHosts, 'hostid');
                 $dbDisabledHosts = API::Host()->get(['groupids' => $hideHostGroupIds, 'output' => ['hostid']]);
                 $disabledHostIds = zbx_objectValues($dbDisabledHosts, 'hostid');
                 $filter['hostids'] = array_diff($availableHostIds, $disabledHostIds);
             } else {
                 if (!$filter['groupids']) {
                     // null mean all groups
                     $filter['groupids'] = null;
                 }
             }
         }
         // hosts
         $maintenance = CProfile::get('web.dashconf.hosts.maintenance', 1);
         $filter['maintenance'] = $maintenance == 0 ? 0 : null;
         // triggers
         $severity = CProfile::get('web.dashconf.triggers.severity', null);
         $filter['severity'] = zbx_empty($severity) ? null : explode(';', $severity);
         $filter['severity'] = zbx_toHash($filter['severity']);
         $filter['trigger_name'] = CProfile::get('web.dashconf.triggers.name', '');
         $config = select_config();
         $filter['extAck'] = $config['event_ack_enable'] ? CProfile::get('web.dashconf.events.extAck', 0) : 0;
     }
     $this->setResponse(new CControllerResponseData(['filter' => $filter, 'user' => ['debug_mode' => $this->getDebugMode()]]));
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:44,代码来源:CControllerWidgetSystemView.php

示例6: __construct

 /**
  * @param string $options['name']
  * @param int    $options['value']		(optional) Default: TRIGGER_SEVERITY_NOT_CLASSIFIED
  * @param bool   $options['all']		(optional)
  */
 public function __construct(array $options = [])
 {
     parent::__construct();
     $id = zbx_formatDomId($options['name']);
     $this->addClass(ZBX_STYLE_RADIO_SEGMENTED);
     $this->setId($id);
     if (!array_key_exists('value', $options)) {
         $options['value'] = TRIGGER_SEVERITY_NOT_CLASSIFIED;
     }
     $severity_from = array_key_exists('all', $options) && $options['all'] ? -1 : TRIGGER_SEVERITY_NOT_CLASSIFIED;
     $config = select_config();
     for ($severity = $severity_from; $severity < TRIGGER_SEVERITY_COUNT; $severity++) {
         $name = $severity == -1 ? _('all') : getSeverityName($severity, $config);
         $class = $severity == -1 ? null : getSeverityStyle($severity);
         $radio = (new CInput('radio', $options['name'], $severity))->setId(zbx_formatDomId($options['name'] . '_' . $severity));
         if ($severity === $options['value']) {
             $radio->setAttribute('checked', 'checked');
         }
         parent::addItem((new CListItem([$radio, new CLabel($name, $options['name'] . '_' . $severity)]))->addClass($class));
     }
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:26,代码来源:CSeverity.php

示例7: bodyToString

 public function bodyToString()
 {
     $this->cleanItems();
     $config = select_config();
     // array of triggers (not classified, information, warning, average, high, disaster) in problem state
     $triggersProblemState = [];
     // number of triggers in OK state
     $triggersOkState = 0;
     $options = ['output' => ['triggerid', 'priority', 'value'], 'monitored' => true, 'skipDependent' => true];
     if ($this->groupid != 0) {
         $options['groupids'] = $this->groupid;
     }
     $triggers = API::Trigger()->get($options);
     foreach ($triggers as $trigger) {
         switch ($trigger['value']) {
             case TRIGGER_VALUE_TRUE:
                 if (!array_key_exists($trigger['priority'], $triggersProblemState)) {
                     $triggersProblemState[$trigger['priority']] = 0;
                 }
                 $triggersProblemState[$trigger['priority']]++;
                 break;
             case TRIGGER_VALUE_FALSE:
                 $triggersOkState++;
         }
     }
     $severityCells = [getSeverityCell(null, $config, $triggersOkState . SPACE . _('Ok'), true)];
     for ($severity = TRIGGER_SEVERITY_NOT_CLASSIFIED; $severity < TRIGGER_SEVERITY_COUNT; $severity++) {
         $severityCount = isset($triggersProblemState[$severity]) ? $triggersProblemState[$severity] : 0;
         $severityCells[] = getSeverityCell($severity, $config, $severityCount . SPACE . getSeverityName($severity, $config), !$severityCount);
     }
     if ($this->style == STYLE_HORIZONTAL) {
         $this->addRow($severityCells);
     } else {
         foreach ($severityCells as $severityCell) {
             $this->addRow($severityCell);
         }
     }
     return parent::bodyToString();
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:39,代码来源:CTriggersInfo.php

示例8: makeTriggersPopup

/**
 * Generate table for dashboard triggers popup.
 *
 * @see make_system_status
 *
 * @param array $triggers
 * @param array $ackParams
 * @param array $actions
 *
 * @return CTableInfo
 */
function makeTriggersPopup(array $triggers, array $ackParams, array $actions)
{
    $config = select_config();
    $popupTable = new CTableInfo();
    $popupTable->setAttribute('style', 'width: 400px;');
    $popupTable->setHeader(array(is_show_all_nodes() ? _('Node') : null, _('Host'), _('Issue'), _('Age'), _('Info'), $config['event_ack_enable'] ? _('Ack') : null, _('Actions')));
    CArrayHelper::sort($triggers, array(array('field' => 'lastchange', 'order' => ZBX_SORT_DOWN)));
    foreach ($triggers as $trigger) {
        // unknown triggers
        $unknown = SPACE;
        if ($trigger['state'] == TRIGGER_STATE_UNKNOWN) {
            $unknown = new CDiv(SPACE, 'status_icon iconunknown');
            $unknown->setHint($trigger['error'], '', 'on');
        }
        // ack
        if ($config['event_ack_enable']) {
            $ack = isset($trigger['event']['eventid']) ? getEventAckState($trigger['event'], true, true, $ackParams) : _('No events');
        } else {
            $ack = null;
        }
        // action
        $action = isset($trigger['event']['eventid']) && isset($actions[$trigger['event']['eventid']]) ? $actions[$trigger['event']['eventid']] : _('-');
        $popupTable->addRow(array(get_node_name_by_elid($trigger['triggerid']), $trigger['hosts'][0]['name'], getSeverityCell($trigger['priority'], $trigger['description']), zbx_date2age($trigger['lastchange']), $unknown, $ack, $action));
    }
    return $popupTable;
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:37,代码来源:blocks.inc.php

示例9: array

$data = array();
$data['form_refresh'] = get_request('form_refresh', 0);
// form has been submitted
if ($data['form_refresh']) {
    $data['ok_period'] = get_request('ok_period');
    $data['blink_period'] = get_request('blink_period');
    $data['problem_unack_color'] = get_request('problem_unack_color');
    $data['problem_ack_color'] = get_request('problem_ack_color');
    $data['ok_unack_color'] = get_request('ok_unack_color');
    $data['ok_ack_color'] = get_request('ok_ack_color');
    $data['problem_unack_style'] = get_request('problem_unack_style');
    $data['problem_ack_style'] = get_request('problem_ack_style');
    $data['ok_unack_style'] = get_request('ok_unack_style');
    $data['ok_ack_style'] = get_request('ok_ack_style');
} else {
    $config = select_config(false);
    $data['ok_period'] = $config['ok_period'];
    $data['blink_period'] = $config['blink_period'];
    $data['problem_unack_color'] = $config['problem_unack_color'];
    $data['problem_ack_color'] = $config['problem_ack_color'];
    $data['ok_unack_color'] = $config['ok_unack_color'];
    $data['ok_ack_color'] = $config['ok_ack_color'];
    $data['problem_unack_style'] = $config['problem_unack_style'];
    $data['problem_ack_style'] = $config['problem_ack_style'];
    $data['ok_unack_style'] = $config['ok_unack_style'];
    $data['ok_ack_style'] = $config['ok_ack_style'];
}
$triggerDisplayingForm = new CView('administration.general.triggerDisplayOptions.edit', $data);
$cnf_wdgt->addItem($triggerDisplayingForm->render());
$cnf_wdgt->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:adm.triggerdisplayoptions.php

示例10: selectData

 protected function selectData()
 {
     $this->data = array();
     $now = time(null);
     if (isset($this->stime)) {
         $this->from_time = $this->stime;
         $this->to_time = $this->stime + $this->period;
     } else {
         $this->to_time = $now - SEC_PER_HOUR * $this->from;
         $this->from_time = $this->to_time - $this->period;
     }
     $strvaluelength = 0;
     // we need to know how long in px will be our legend
     // fetch values for items with the "last" function
     $lastValueItems = array();
     foreach ($this->items as $item) {
         if ($item['calc_fnc'] == CALC_FNC_LST) {
             $lastValueItems[] = $item;
         }
     }
     if ($lastValueItems) {
         $history = Manager::History()->getLast($lastValueItems);
     }
     $config = select_config();
     for ($i = 0; $i < $this->num; $i++) {
         $item = get_item_by_itemid($this->items[$i]['itemid']);
         $type = $this->items[$i]['calc_type'];
         $from_time = $this->from_time;
         $to_time = $this->to_time;
         $sql_arr = array();
         // override item history setting with housekeeping settings
         if ($config['hk_history_global']) {
             $item['history'] = $config['hk_history'];
         }
         $trendsEnabled = $config['hk_trends_global'] ? $config['hk_trends'] > 0 : $item['trends'] > 0;
         if (!$trendsEnabled || $item['history'] * SEC_PER_DAY > time() - ($from_time + $this->period / 2)) {
             $this->dataFrom = 'history';
             array_push($sql_arr, 'SELECT h.itemid,' . 'AVG(h.value) AS avg,MIN(h.value) AS min,' . 'MAX(h.value) AS max,MAX(h.clock) AS clock' . ' FROM history h' . ' WHERE h.itemid=' . zbx_dbstr($this->items[$i]['itemid']) . ' AND h.clock>=' . zbx_dbstr($from_time) . ' AND h.clock<=' . zbx_dbstr($to_time) . ' GROUP BY h.itemid', 'SELECT hu.itemid,' . 'AVG(hu.value) AS avg,MIN(hu.value) AS min,' . 'MAX(hu.value) AS max,MAX(hu.clock) AS clock' . ' FROM history_uint hu' . ' WHERE hu.itemid=' . zbx_dbstr($this->items[$i]['itemid']) . ' AND hu.clock>=' . zbx_dbstr($from_time) . ' AND hu.clock<=' . zbx_dbstr($to_time) . ' GROUP BY hu.itemid');
         } else {
             $this->dataFrom = 'trends';
             array_push($sql_arr, 'SELECT t.itemid,' . 'AVG(t.value_avg) AS avg,MIN(t.value_min) AS min,' . 'MAX(t.value_max) AS max,MAX(t.clock) AS clock' . ' FROM trends t' . ' WHERE t.itemid=' . zbx_dbstr($this->items[$i]['itemid']) . ' AND t.clock>=' . zbx_dbstr($from_time) . ' AND t.clock<=' . zbx_dbstr($to_time) . ' GROUP BY t.itemid', 'SELECT t.itemid,' . 'AVG(t.value_avg) AS avg,MIN(t.value_min) AS min,' . 'MAX(t.value_max) AS max,MAX(t.clock) AS clock' . ' FROM trends_uint t' . ' WHERE t.itemid=' . zbx_dbstr($this->items[$i]['itemid']) . ' AND t.clock>=' . zbx_dbstr($from_time) . ' AND t.clock<=' . zbx_dbstr($to_time) . ' GROUP BY t.itemid');
         }
         $this->data[$this->items[$i]['itemid']][$type]['last'] = isset($history[$item['itemid']]) ? $history[$item['itemid']][0]['value'] : null;
         $this->data[$this->items[$i]['itemid']][$type]['shift_min'] = 0;
         $this->data[$this->items[$i]['itemid']][$type]['shift_max'] = 0;
         $this->data[$this->items[$i]['itemid']][$type]['shift_avg'] = 0;
         foreach ($sql_arr as $sql) {
             $result = DBselect($sql);
             while ($row = DBfetch($result)) {
                 $this->data[$this->items[$i]['itemid']][$type]['min'] = $row['min'];
                 $this->data[$this->items[$i]['itemid']][$type]['max'] = $row['max'];
                 $this->data[$this->items[$i]['itemid']][$type]['avg'] = $row['avg'];
                 $this->data[$this->items[$i]['itemid']][$type]['clock'] = $row['clock'];
             }
             unset($row);
         }
         switch ($this->items[$i]['calc_fnc']) {
             case CALC_FNC_MIN:
                 $fncName = 'min';
                 break;
             case CALC_FNC_MAX:
                 $fncName = 'max';
                 break;
             case CALC_FNC_LST:
                 $fncName = 'last';
                 break;
             case CALC_FNC_AVG:
             default:
                 $fncName = 'avg';
         }
         $item_value = empty($this->data[$this->items[$i]['itemid']][$type][$fncName]) ? 0 : abs($this->data[$this->items[$i]['itemid']][$type][$fncName]);
         if ($type == GRAPH_ITEM_SUM) {
             $this->background = $i;
             $graph_sum = $item_value;
         }
         $this->sum += $item_value;
         $convertedUnit = zbx_strlen(convert_units(array('value' => $item_value, 'units' => $this->items[$i]['units'])));
         $strvaluelength = max($strvaluelength, $convertedUnit);
     }
     if (isset($graph_sum)) {
         $this->sum = $graph_sum;
     }
     $this->shiftlegendright += $strvaluelength * 7;
 }
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:84,代码来源:CPieGraphDraw.php

示例11: elseif

    // 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();
} else {
    $data = ['config' => select_config(), 'hosts' => [], 'sort' => $sortField, 'sortorder' => $sortOrder];
    // filter
    $data['pageFilter'] = new CPageFilter(['groups' => ['real_hosts' => true], 'groupid' => getRequest('groupid')]);
    /*
     * Filter
     */
    if (hasRequest('filter_set')) {
        CProfile::update('web.hostinventories.filter_field', getRequest('filter_field', ''), PROFILE_TYPE_STR);
        CProfile::update('web.hostinventories.filter_field_value', getRequest('filter_field_value', ''), PROFILE_TYPE_STR);
        CProfile::update('web.hostinventories.filter_exact', getRequest('filter_exact', 0), PROFILE_TYPE_INT);
    } elseif (hasRequest('filter_rst')) {
        DBStart();
        CProfile::delete('web.hostinventories.filter_field');
        CProfile::delete('web.hostinventories.filter_field_value');
        CProfile::delete('web.hostinventories.filter_exact');
        DBend();
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:hostinventories.php

示例12: getGroupAuthenticationType

/**
 * Get group authentication type.
 *
 * @param array $groupIds
 * @param int   $maxGuiAccess
 *
 * @return int
 */
function getGroupAuthenticationType($groupIds, $maxGuiAccess = null)
{
    $config = select_config();
    switch (getGroupsGuiAccess($groupIds, $maxGuiAccess)) {
        case GROUP_GUI_ACCESS_SYSTEM:
            return $config['authentication_type'];
        case GROUP_GUI_ACCESS_INTERNAL:
            return $config['authentication_type'] == ZBX_AUTH_HTTP ? ZBX_AUTH_HTTP : ZBX_AUTH_INTERNAL;
        default:
            return $config['authentication_type'];
    }
}
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:20,代码来源:perm.inc.php

示例13: 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

示例14: get

 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $output = [];
     $items = API::Item()->get(['output' => ['itemid', 'hostid', 'name', 'key_', 'value_type', 'valuemapid'], 'selectHosts' => ['name'], 'itemids' => $this->itemids, 'webitems' => true, 'preservekeys' => true]);
     $items = CMacrosResolverHelper::resolveItemNames($items);
     $stime = zbxDateToTime($this->timeline['stime']);
     $firstItem = reset($items);
     $iv_string = [ITEM_VALUE_TYPE_LOG => 1, ITEM_VALUE_TYPE_TEXT => 1];
     $iv_numeric = [ITEM_VALUE_TYPE_FLOAT => 1, ITEM_VALUE_TYPE_UINT64 => 1];
     if ($this->action == HISTORY_VALUES || $this->action == HISTORY_LATEST) {
         $options = ['history' => $firstItem['value_type'], 'itemids' => $this->itemids, 'output' => API_OUTPUT_EXTEND, 'sortorder' => ZBX_SORT_DOWN];
         if ($this->action == HISTORY_LATEST) {
             $options['limit'] = 500;
         } elseif ($this->action == HISTORY_VALUES) {
             $config = select_config();
             // interval start value is non-inclusive, hence the + 1 second
             $options['time_from'] = $stime + 1;
             $options['time_till'] = $stime + $this->timeline['period'];
             $options['limit'] = $config['search_limit'];
         }
         // text log
         if (isset($iv_string[$firstItem['value_type']])) {
             $isManyItems = count($items) > 1;
             $useLogItem = $firstItem['value_type'] == ITEM_VALUE_TYPE_LOG;
             $useEventLogItem = strpos($firstItem['key_'], 'eventlog[') === 0;
             if (empty($this->plaintext)) {
                 $historyTable = (new CTableInfo())->setHeader([(new CColHeader(_('Timestamp')))->addClass(ZBX_STYLE_CELL_WIDTH), $isManyItems ? _('Item') : null, $useLogItem ? (new CColHeader(_('Local time')))->addClass(ZBX_STYLE_CELL_WIDTH) : null, $useEventLogItem && $useLogItem ? (new CColHeader(_('Source')))->addClass(ZBX_STYLE_CELL_WIDTH) : null, $useEventLogItem && $useLogItem ? (new CColHeader(_('Severity')))->addClass(ZBX_STYLE_CELL_WIDTH) : null, $useEventLogItem && $useLogItem ? (new CColHeader(_('Event ID')))->addClass(ZBX_STYLE_CELL_WIDTH) : null, _('Value')]);
             }
             if ($this->filter !== '' && in_array($this->filterTask, [FILTER_TASK_SHOW, FILTER_TASK_HIDE])) {
                 $options['search'] = ['value' => $this->filter];
                 if ($this->filterTask == FILTER_TASK_HIDE) {
                     $options['excludeSearch'] = 1;
                 }
             }
             $options['sortfield'] = 'id';
             $historyData = API::History()->get($options);
             foreach ($historyData as $data) {
                 $data['value'] = rtrim($data['value'], " \t\r\n");
                 if (empty($this->plaintext)) {
                     $item = $items[$data['itemid']];
                     $host = reset($item['hosts']);
                     $color = null;
                     if ($this->filter !== '') {
                         $haystack = mb_strtolower($data['value']);
                         $needle = mb_strtolower($this->filter);
                         $pos = mb_strpos($haystack, $needle);
                         if ($pos !== false && $this->filterTask == FILTER_TASK_MARK) {
                             $color = $this->markColor;
                         } elseif ($pos === false && $this->filterTask == FILTER_TASK_INVERT_MARK) {
                             $color = $this->markColor;
                         }
                         switch ($color) {
                             case MARK_COLOR_RED:
                                 $color = ZBX_STYLE_RED;
                                 break;
                             case MARK_COLOR_GREEN:
                                 $color = ZBX_STYLE_GREEN;
                                 break;
                             case MARK_COLOR_BLUE:
                                 $color = ZBX_STYLE_BLUE;
                                 break;
                         }
                     }
                     $row = [];
                     $row[] = (new CCol(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $data['clock'])))->addClass(ZBX_STYLE_NOWRAP)->addClass($color);
                     if ($isManyItems) {
                         $row[] = (new CCol($host['name'] . NAME_DELIMITER . $item['name_expanded']))->addClass($color);
                     }
                     if ($useLogItem) {
                         $row[] = $data['timestamp'] != 0 ? (new CCol(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $data['timestamp'])))->addClass(ZBX_STYLE_NOWRAP)->addClass($color) : '';
                         // if this is a eventLog item, showing additional info
                         if ($useEventLogItem) {
                             $row[] = (new CCol($data['source']))->addClass(ZBX_STYLE_NOWRAP)->addClass($color);
                             $row[] = $data['severity'] != 0 ? (new CCol(get_item_logtype_description($data['severity'])))->addClass(ZBX_STYLE_NOWRAP)->addClass(get_item_logtype_style($data['severity'])) : '';
                             $row[] = $data['logeventid'] != 0 ? (new CCol($data['logeventid']))->addClass(ZBX_STYLE_NOWRAP)->addClass($color) : '';
                         }
                     }
                     $row[] = (new CCol(new CPre(zbx_nl2br($data['value']))))->addClass($color);
                     $historyTable->addRow($row);
                 } else {
                     $output[] = zbx_date2str(DATE_TIME_FORMAT_SECONDS, $data['clock']) . ' ' . $data['clock'] . ' ' . htmlspecialchars($data['value']);
                 }
             }
             if (empty($this->plaintext)) {
                 $output[] = $historyTable;
             }
         } else {
             if (empty($this->plaintext)) {
                 $historyTable = (new CTableInfo())->setHeader([(new CColHeader(_('Timestamp')))->addClass(ZBX_STYLE_CELL_WIDTH), _('Value')]);
             }
             $options['sortfield'] = ['itemid', 'clock'];
             $historyData = API::History()->get($options);
             foreach ($historyData as $data) {
                 $item = $items[$data['itemid']];
                 $value = rtrim($data['value'], " \t\r\n");
//.........这里部分代码省略.........
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:CScreenHistory.php

示例15: update_config

function update_config($configs)
{
    $update = array();
    if (isset($configs['work_period'])) {
        $timePeriodValidator = new CTimePeriodValidator();
        if (!$timePeriodValidator->validate($configs['work_period'])) {
            error(_('Incorrect working time.'));
            return false;
        }
    }
    if (isset($configs['alert_usrgrpid'])) {
        if ($configs['alert_usrgrpid'] != 0 && !DBfetch(DBselect('SELECT u.usrgrpid FROM usrgrp u WHERE u.usrgrpid=' . zbx_dbstr($configs['alert_usrgrpid'])))) {
            error(_('Incorrect user group.'));
            return false;
        }
    }
    if (isset($configs['discovery_groupid'])) {
        $groupid = API::HostGroup()->get(array('groupids' => $configs['discovery_groupid'], 'output' => array('groupid'), 'preservekeys' => true));
        if (empty($groupid)) {
            error(_('Incorrect host group.'));
            return false;
        }
    }
    // checking color values to be correct hexadecimal numbers
    $colors = array('severity_color_0', 'severity_color_1', 'severity_color_2', 'severity_color_3', 'severity_color_4', 'severity_color_5', 'problem_unack_color', 'problem_ack_color', 'ok_unack_color', 'ok_ack_color');
    $colorvalidator = new CColorValidator();
    foreach ($colors as $color) {
        if (isset($configs[$color]) && !is_null($configs[$color])) {
            if (!$colorvalidator->validate($configs[$color])) {
                error($colorvalidator->getError());
                return false;
            }
        }
    }
    if (isset($configs['ok_period']) && !is_null($configs['ok_period']) && !ctype_digit($configs['ok_period'])) {
        error(_('"Display OK triggers" needs to be "0" or a positive integer.'));
        return false;
    }
    if (isset($configs['blink_period']) && !is_null($configs['blink_period']) && !ctype_digit($configs['blink_period'])) {
        error(_('"Triggers blink on status change" needs to be "0" or a positive integer.'));
        return false;
    }
    $currentConfig = select_config();
    // check duplicate severity names and if name is empty.
    $names = array();
    for ($i = 0; $i < TRIGGER_SEVERITY_COUNT; $i++) {
        $varName = 'severity_name_' . $i;
        if (!isset($configs[$varName]) || is_null($configs[$varName])) {
            $configs[$varName] = $currentConfig[$varName];
        }
        if ($configs[$varName] == '') {
            error(_('Severity name cannot be empty.'));
            return false;
        }
        if (isset($names[$configs[$varName]])) {
            error(_s('Duplicate severity name "%s".', $configs[$varName]));
            return false;
        } else {
            $names[$configs[$varName]] = 1;
        }
    }
    foreach ($configs as $key => $value) {
        if (!is_null($value)) {
            if ($key == 'alert_usrgrpid') {
                $update[] = $key . '=' . ($value == '0' ? 'NULL' : $value);
            } else {
                $update[] = $key . '=' . zbx_dbstr($value);
            }
        }
    }
    if (count($update) == 0) {
        error(_('Nothing to do.'));
        return null;
    }
    return DBexecute('UPDATE config' . ' SET ' . implode(',', $update) . whereDbNode('configid', false));
}
开发者ID:hujingguang,项目名称:work,代码行数:76,代码来源:profiles.inc.php


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