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


PHP zbx_array_merge函数代码示例

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


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

示例1: get

 /**
  * Get value maps.
  *
  * @param array $options
  *
  * @return array
  */
 public function get($options = [])
 {
     $options = zbx_array_merge($this->getOptions, $options);
     if ($options['editable'] !== null && self::$userData['type'] != USER_TYPE_SUPER_ADMIN) {
         return $options['countOutput'] !== null && $options['groupCount'] === null ? 0 : [];
     }
     $res = DBselect($this->createSelectQuery($this->tableName(), $options), $options['limit']);
     $result = [];
     while ($row = DBfetch($res)) {
         if ($options['countOutput'] === null) {
             $result[$row[$this->pk()]] = $row;
         } else {
             if ($options['groupCount'] === null) {
                 $result = $row['rowscount'];
             } else {
                 $result[] = $row;
             }
         }
     }
     if ($options['countOutput'] !== null) {
         return $result;
     }
     if ($result) {
         $result = $this->addRelatedObjects($options, $result);
     }
     // removing keys (hash -> array)
     if ($options['preservekeys'] === null) {
         $result = zbx_cleanHashes($result);
     }
     return $result;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:38,代码来源:CValueMap.php

示例2: get

 /**
  * Get host prototypes.
  *
  * @param array $options
  *
  * @return array
  */
 public function get(array $options)
 {
     $options = zbx_array_merge($this->getOptions, $options);
     $options['filter']['flags'] = ZBX_FLAG_DISCOVERY_PROTOTYPE;
     // build and execute query
     $sql = $this->createSelectQuery($this->tableName(), $options);
     $res = DBselect($sql, $options['limit']);
     // fetch results
     $result = [];
     while ($row = DBfetch($res)) {
         // a count query, return a single result
         if ($options['countOutput'] !== null) {
             if ($options['groupCount'] !== null) {
                 $result[] = $row;
             } else {
                 $result = $row['rowscount'];
             }
         } else {
             $result[$row[$this->pk()]] = $row;
         }
     }
     if ($options['countOutput'] !== null) {
         return $result;
     }
     if ($result) {
         $result = $this->addRelatedObjects($options, $result);
         $result = $this->unsetExtraFields($result, ['triggerid'], $options['output']);
     }
     if ($options['preservekeys'] === null) {
         $result = zbx_cleanHashes($result);
     }
     return $result;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:40,代码来源:CHostPrototype.php

示例3: get

 /**
  * Get GraphItems data
  *
  * @param array $options
  * @return array|boolean
  */
 public function get($options = array())
 {
     $result = array();
     $userType = self::$userData['type'];
     $userid = self::$userData['userid'];
     $sqlParts = array('select' => array('gitems' => 'gi.gitemid'), 'from' => array('graphs_items' => 'graphs_items gi'), 'where' => array(), 'order' => array(), 'limit' => null);
     $defOptions = array('graphids' => null, 'itemids' => null, 'type' => null, 'editable' => null, 'nopermissions' => null, 'selectGraphs' => null, 'output' => API_OUTPUT_EXTEND, 'expandData' => null, 'countOutput' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null);
     $options = zbx_array_merge($defOptions, $options);
     $this->checkDeprecatedParam($options, 'expandData');
     // editable + PERMISSION CHECK
     if ($userType != USER_TYPE_SUPER_ADMIN && !$options['nopermissions']) {
         $permission = $options['editable'] ? PERM_READ_WRITE : PERM_READ;
         $userGroups = getUserGroupsByUserId($userid);
         $sqlParts['where'][] = 'EXISTS (' . 'SELECT NULL' . ' FROM items i,hosts_groups hgg' . ' JOIN rights r' . ' ON r.id=hgg.groupid' . ' AND ' . dbConditionInt('r.groupid', $userGroups) . ' WHERE gi.itemid=i.itemid' . ' AND i.hostid=hgg.hostid' . ' GROUP BY i.itemid' . ' HAVING MIN(r.permission)>' . PERM_DENY . ' AND MAX(r.permission)>=' . zbx_dbstr($permission) . ')';
     }
     // graphids
     if (!is_null($options['graphids'])) {
         zbx_value2array($options['graphids']);
         $sqlParts['from']['graphs'] = 'graphs g';
         $sqlParts['where']['gig'] = 'gi.graphid=g.graphid';
         $sqlParts['where'][] = dbConditionInt('g.graphid', $options['graphids']);
     }
     // itemids
     if (!is_null($options['itemids'])) {
         zbx_value2array($options['itemids']);
         $sqlParts['where'][] = dbConditionInt('gi.itemid', $options['itemids']);
     }
     // type
     if (!is_null($options['type'])) {
         $sqlParts['where'][] = 'gi.type=' . zbx_dbstr($options['type']);
     }
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     $sqlParts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $sqlParts = $this->applyQuerySortOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $dbRes = DBselect($this->createSelectQueryFromParts($sqlParts), $sqlParts['limit']);
     while ($gitem = DBfetch($dbRes)) {
         if (!is_null($options['countOutput'])) {
             $result = $gitem['rowscount'];
         } else {
             $result[$gitem['gitemid']] = $gitem;
         }
     }
     if (!is_null($options['countOutput'])) {
         return $result;
     }
     if ($result) {
         $result = $this->addRelatedObjects($options, $result);
         $result = $this->unsetExtraFields($result, array('graphid'), $options['output']);
     }
     // removing keys (hash -> array)
     if (is_null($options['preservekeys'])) {
         $result = zbx_cleanHashes($result);
     }
     return $result;
 }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:64,代码来源:CGraphItem.php

示例4: get

 /**
  * Get IconMap data.
  * @param array $options
  * @param array $options['iconmapids']
  * @param array $options['sysmapids']
  * @param array $options['editable']
  * @param array $options['count']
  * @param array $options['limit']
  * @param array $options['order']
  * @return array
  */
 public function get(array $options = [])
 {
     $result = [];
     $sqlParts = ['select' => ['icon_map' => 'im.iconmapid'], 'from' => ['icon_map' => 'icon_map im'], 'where' => [], 'order' => [], 'limit' => null];
     $defOptions = ['iconmapids' => null, 'sysmapids' => null, 'nopermissions' => null, 'editable' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_EXTEND, 'selectMappings' => null, 'countOutput' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null];
     $options = zbx_array_merge($defOptions, $options);
     // editable + PERMISSION CHECK
     if ($options['editable'] && self::$userData['type'] != USER_TYPE_SUPER_ADMIN) {
         return [];
     }
     // iconmapids
     if (!is_null($options['iconmapids'])) {
         zbx_value2array($options['iconmapids']);
         $sqlParts['where'][] = dbConditionInt('im.iconmapid', $options['iconmapids']);
     }
     // sysmapids
     if (!is_null($options['sysmapids'])) {
         zbx_value2array($options['sysmapids']);
         $sqlParts['from']['sysmaps'] = 'sysmaps s';
         $sqlParts['where'][] = dbConditionInt('s.sysmapid', $options['sysmapids']);
         $sqlParts['where']['ims'] = 'im.iconmapid=s.iconmapid';
     }
     // filter
     if (is_array($options['filter'])) {
         $this->dbFilter('icon_map im', $options, $sqlParts);
     }
     // search
     if (is_array($options['search'])) {
         zbx_db_search('icon_map im', $options, $sqlParts);
     }
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     $sqlParts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $sqlParts = $this->applyQuerySortOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $dbRes = DBselect($this->createSelectQueryFromParts($sqlParts), $sqlParts['limit']);
     while ($iconMap = DBfetch($dbRes)) {
         if ($options['countOutput']) {
             $result = $iconMap['rowscount'];
         } else {
             $result[$iconMap['iconmapid']] = $iconMap;
         }
     }
     if (!is_null($options['countOutput'])) {
         return $result;
     }
     if ($result) {
         $result = $this->addRelatedObjects($options, $result);
     }
     // removing keys (hash -> array)
     if (is_null($options['preservekeys'])) {
         $result = zbx_cleanHashes($result);
     }
     return $result;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:67,代码来源:CIconMap.php

示例5: get

 /**
  * Get screen item data.
  *
  * @param array $options
  * @param array $options['hostid']			Use hostid to get real resource id
  * @param array $options['screenitemids']	Search by screen item IDs
  * @param array $options['screenids']		Search by screen IDs
  * @param array $options['filter']			Result filter
  * @param array $options['limit']			The size of the result set
  *
  * @return array
  */
 public function get(array $options = [])
 {
     $options = zbx_array_merge($this->getOptions, $options);
     // build and execute query
     $sql = $this->createSelectQuery($this->tableName(), $options);
     $res = DBselect($sql, $options['limit']);
     // fetch results
     $result = [];
     while ($row = DBfetch($res)) {
         // count query, return a single result
         if ($options['countOutput'] !== null) {
             $result = $row['rowscount'];
         } else {
             if ($options['preservekeys'] !== null) {
                 $result[$row['screenitemid']] = $row;
             } else {
                 $result[] = $row;
             }
         }
     }
     // fill result with real resourceid
     if ($options['hostids'] && $result) {
         if (empty($options['screenitemid'])) {
             $options['screenitemid'] = zbx_objectValues($result, 'screenitemid');
         }
         $dbTemplateScreens = API::TemplateScreen()->get(['output' => ['screenitemid'], 'screenitemids' => $options['screenitemid'], 'hostids' => $options['hostids'], 'selectScreenItems' => API_OUTPUT_EXTEND]);
         if ($dbTemplateScreens) {
             foreach ($result as &$screenItem) {
                 foreach ($dbTemplateScreens as $dbTemplateScreen) {
                     foreach ($dbTemplateScreen['screenitems'] as $dbScreenItem) {
                         if ($screenItem['screenitemid'] == $dbScreenItem['screenitemid'] && isset($dbScreenItem['real_resourceid']) && $dbScreenItem['real_resourceid']) {
                             $screenItem['real_resourceid'] = $dbScreenItem['real_resourceid'];
                         }
                     }
                 }
             }
             unset($screenItem);
         }
     }
     return $result;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:53,代码来源:CTemplateScreenItem.php

示例6: get

 /**
  * Get ScreemItem data
  *
  * @param array $options
  * @param array $options['nodeids']			Node IDs
  * @param array $options['screenitemids']	Search by screen item IDs
  * @param array $options['screenids']		Search by screen IDs
  * @param array $options['filter']			Result filter
  * @param array $options['limit']			The size of the result set
  *
  * @return array|boolean Host data as array or false if error
  */
 public function get(array $options = array())
 {
     $options = zbx_array_merge($this->getOptions, $options);
     // build and execute query
     $sql = $this->createSelectQuery($this->tableName(), $options);
     $res = DBselect($sql, $options['limit']);
     // fetch results
     $result = array();
     while ($row = DBfetch($res)) {
         // count query, return a single result
         if ($options['countOutput'] !== null) {
             $result = $row['rowscount'];
         } else {
             if ($options['preservekeys'] !== null) {
                 $result[$row['screenitemid']] = $row;
             } else {
                 $result[] = $row;
             }
         }
     }
     return $result;
 }
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:34,代码来源:CScreenItem.php

示例7: get

 /**
  * Get scripts data.
  *
  * @param array  $options
  * @param array  $options['itemids']
  * @param array  $options['hostids']	deprecated (very slow)
  * @param array  $options['groupids']
  * @param array  $options['triggerids']
  * @param array  $options['scriptids']
  * @param bool   $options['status']
  * @param bool   $options['editable']
  * @param bool   $options['count']
  * @param string $options['pattern']
  * @param int    $options['limit']
  * @param string $options['order']
  *
  * @return array
  */
 public function get(array $options)
 {
     $result = array();
     $userType = self::$userData['type'];
     $userid = self::$userData['userid'];
     $sqlParts = array('select' => array('scripts' => 's.scriptid'), 'from' => array('scripts s'), 'where' => array(), 'order' => array(), 'limit' => null);
     $defOptions = array('groupids' => null, 'hostids' => null, 'scriptids' => null, 'usrgrpids' => null, 'editable' => null, 'nopermissions' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_EXTEND, 'selectGroups' => null, 'selectHosts' => null, 'countOutput' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null);
     $options = zbx_array_merge($defOptions, $options);
     // editable + permission check
     if ($userType != USER_TYPE_SUPER_ADMIN) {
         if (!is_null($options['editable'])) {
             return $result;
         }
         $userGroups = getUserGroupsByUserId($userid);
         $sqlParts['where'][] = '(s.usrgrpid IS NULL OR ' . dbConditionInt('s.usrgrpid', $userGroups) . ')';
         $sqlParts['where'][] = '(s.groupid IS NULL OR EXISTS (' . 'SELECT NULL' . ' FROM rights r' . ' WHERE s.groupid=r.id' . ' AND ' . dbConditionInt('r.groupid', $userGroups) . ' GROUP BY r.id' . ' HAVING MIN(r.permission)>' . PERM_DENY . '))';
     }
     // groupids
     if (!is_null($options['groupids'])) {
         zbx_value2array($options['groupids']);
         $sqlParts['where'][] = '(s.groupid IS NULL OR ' . dbConditionInt('s.groupid', $options['groupids']) . ')';
     }
     // hostids
     if (!is_null($options['hostids'])) {
         zbx_value2array($options['hostids']);
         // return scripts that are assigned to the hosts' groups or to no group
         $hostGroups = API::HostGroup()->get(array('output' => array('groupid'), 'hostids' => $options['hostids']));
         $hostGroupIds = zbx_objectValues($hostGroups, 'groupid');
         $sqlParts['where'][] = '(' . dbConditionInt('s.groupid', $hostGroupIds) . ' OR s.groupid IS NULL)';
     }
     // usrgrpids
     if (!is_null($options['usrgrpids'])) {
         zbx_value2array($options['usrgrpids']);
         $sqlParts['where'][] = '(s.usrgrpid IS NULL OR ' . dbConditionInt('s.usrgrpid', $options['usrgrpids']) . ')';
     }
     // scriptids
     if (!is_null($options['scriptids'])) {
         zbx_value2array($options['scriptids']);
         $sqlParts['where'][] = dbConditionInt('s.scriptid', $options['scriptids']);
     }
     // search
     if (is_array($options['search'])) {
         zbx_db_search('scripts s', $options, $sqlParts);
     }
     // filter
     if (is_array($options['filter'])) {
         $this->dbFilter('scripts s', $options, $sqlParts);
     }
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     $sqlParts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $sqlParts = $this->applyQuerySortOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $res = DBselect($this->createSelectQueryFromParts($sqlParts), $sqlParts['limit']);
     while ($script = DBfetch($res)) {
         if ($options['countOutput']) {
             $result = $script['rowscount'];
         } else {
             $result[$script['scriptid']] = $script;
         }
     }
     if (!is_null($options['countOutput'])) {
         return $result;
     }
     if ($result) {
         $result = $this->addRelatedObjects($options, $result);
         $result = $this->unsetExtraFields($result, array('groupid', 'host_access'), $options['output']);
     }
     // removing keys (hash -> array)
     if (is_null($options['preservekeys'])) {
         $result = zbx_cleanHashes($result);
     }
     return $result;
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:93,代码来源:CScript.php

示例8: make_latest_issues


//.........这里部分代码省略.........
    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');
        }
        $hostDiv = new CDiv(array($hostName, $maintenanceIcon), 'maintenance-abs-cont');
        // unknown triggers
        $unknown = SPACE;
        if ($trigger['state'] == TRIGGER_STATE_UNKNOWN) {
            $unknown = new CDiv(SPACE, 'status_icon iconunknown');
            $unknown->setHint($trigger['error'], '', 'on');
        }
        // trigger has events
        if ($trigger['lastEvent']) {
            // description
            $description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, array('clock' => $trigger['lastEvent']['clock'], 'ns' => $trigger['lastEvent']['ns'])));
            // ack
            $ack = getEventAckState($trigger['lastEvent'], empty($filter['backUrl']) ? true : $filter['backUrl'], true, $ackParams);
        } else {
            // description
            $description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, array('clock' => $trigger['lastchange'], 'ns' => '999999999')));
            // ack
            $ack = new CSpan(_('No events'), 'unknown');
        }
        // description
        if (!zbx_empty($trigger['url'])) {
            $description = new CLink($description, resolveTriggerUrl($trigger), null, null, true);
        } else {
            $description = new CSpan($description, 'pointer');
        }
        $description = new CCol($description, getSeverityStyle($trigger['priority']));
        if ($trigger['lastEvent']) {
            $description->setHint(make_popup_eventlist($trigger['triggerid'], $trigger['lastEvent']['eventid']), '', '', false);
        }
        // clock
        $clock = new CLink(zbx_date2str(_('d M Y H:i:s'), $trigger['lastchange']), 'events.php?triggerid=' . $trigger['triggerid'] . '&source=0&show_unknown=1&nav_time=' . $trigger['lastchange']);
        // actions
        $actionHint = $trigger['lastEvent'] && isset($actions[$trigger['lastEvent']['eventid']]) ? $actions[$trigger['lastEvent']['eventid']] : SPACE;
        $table->addRow(array(get_node_name_by_elid($trigger['triggerid']), $hostDiv, $description, $clock, zbx_date2age($trigger['lastchange']), $unknown, $ack, $actionHint));
    }
    // initialize blinking
    zbx_add_post_js('jqBlink.blink();');
    $script = new CJSScript(get_js("jQuery('#hat_lastiss_footer').html('" . _s('Updated: %s', zbx_date2str(_('H:i:s'))) . "')"));
    $infoDiv = new CDiv(_n('%1$d of %2$d issue is shown', '%1$d of %2$d issues are shown', count($triggers), $triggersTotalCount));
    $infoDiv->addStyle('text-align: right; padding-right: 3px;');
    return new CDiv(array($table, $infoDiv, $script));
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:101,代码来源:blocks.inc.php

示例9: get

 /**
  * Get Service data
  *
  * @param _array $options
  * @param array $options['nodeids'] Node IDs
  * @param array $options['groupids'] ServiceGroup IDs
  * @param array $options['hostids'] Service IDs
  * @param boolean $options['monitored_hosts'] only monitored Services
  * @param boolean $options['templated_hosts'] include templates in result
  * @param boolean $options['with_items'] only with items
  * @param boolean $options['with_historical_items'] only with historical items
  * @param boolean $options['with_triggers'] only with triggers
  * @param boolean $options['with_httptests'] only with http tests
  * @param boolean $options['with_graphs'] only with graphs
  * @param boolean $options['editable'] only with read-write permission. Ignored for SuperAdmins
  * @param boolean $options['selectGroups'] select ServiceGroups
  * @param boolean $options['selectTemplates'] select Templates
  * @param boolean $options['selectItems'] select Items
  * @param boolean $options['selectTriggers'] select Triggers
  * @param boolean $options['selectGraphs'] select Graphs
  * @param boolean $options['selectApplications'] select Applications
  * @param boolean $options['selectMacros'] select Macros
  * @param int $options['count'] count Services, returned column name is rowscount
  * @param string $options['pattern'] search hosts by pattern in Service name
  * @param string $options['extendPattern'] search hosts by pattern in Service name, ip and DNS
  * @param int $options['limit'] limit selection
  * @param string $options['sortfield'] field to sort by
  * @param string $options['sortorder'] sort order
  * @return array|boolean Service data as array or false if error
  */
 public function get($options = array())
 {
     $result = array();
     $nodeCheck = false;
     $userType = self::$userData['type'];
     // allowed columns for sorting
     $sortColumns = array('dserviceid', 'dhostid', 'ip');
     // allowed output options for [ select_* ] params
     $subselectsAllowedOutputs = array(API_OUTPUT_REFER, API_OUTPUT_EXTEND, API_OUTPUT_CUSTOM);
     $sqlParts = array('select' => array('dservices' => 'ds.dserviceid'), 'from' => array('dservices' => 'dservices ds'), 'where' => array(), 'group' => array(), 'order' => array(), 'limit' => null);
     $defOptions = array('nodeids' => null, 'dserviceids' => null, 'dhostids' => null, 'dcheckids' => null, 'druleids' => null, 'editable' => null, 'nopermissions' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_REFER, 'selectDRules' => null, 'selectDHosts' => null, 'selectDChecks' => null, 'selectHosts' => null, 'countOutput' => null, 'groupCount' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null, 'limitSelects' => null);
     $options = zbx_array_merge($defOptions, $options);
     if (is_array($options['output'])) {
         unset($sqlParts['select']['dservices']);
         $dbTable = DB::getSchema('dservices');
         foreach ($options['output'] as $field) {
             if (isset($dbTable['fields'][$field])) {
                 $sqlParts['select'][$field] = 's.' . $field;
             }
         }
         $options['output'] = API_OUTPUT_CUSTOM;
     }
     // editable + PERMISSION CHECK
     if (USER_TYPE_SUPER_ADMIN == $userType) {
     } elseif (is_null($options['editable']) && self::$userData['type'] == USER_TYPE_ZABBIX_ADMIN) {
     } elseif (!is_null($options['editable']) && self::$userData['type'] != USER_TYPE_SUPER_ADMIN) {
         return array();
     }
     // nodeids
     $nodeids = !is_null($options['nodeids']) ? $options['nodeids'] : get_current_nodeid();
     // dserviceids
     if (!is_null($options['dserviceids'])) {
         zbx_value2array($options['dserviceids']);
         $sqlParts['where']['dserviceid'] = dbConditionInt('ds.dserviceid', $options['dserviceids']);
         if (!$nodeCheck) {
             $nodeCheck = true;
             $sqlParts['where'][] = DBin_node('ds.dserviceid', $nodeids);
         }
     }
     // dhostids
     if (!is_null($options['dhostids'])) {
         zbx_value2array($options['dhostids']);
         if ($options['output'] != API_OUTPUT_SHORTEN) {
             $sqlParts['select']['dhostid'] = 'ds.dhostid';
         }
         $sqlParts['where'][] = dbConditionInt('ds.dhostid', $options['dhostids']);
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['dhostid'] = 'ds.dhostid';
         }
         if (!$nodeCheck) {
             $nodeCheck = true;
             $sqlParts['where'][] = DBin_node('ds.dhostid', $nodeids);
         }
     }
     // dcheckids
     if (!is_null($options['dcheckids'])) {
         zbx_value2array($options['dcheckids']);
         if ($options['output'] != API_OUTPUT_SHORTEN) {
             $sqlParts['select']['dcheckid'] = 'dc.dcheckid';
         }
         $sqlParts['from']['dhosts'] = 'dhosts dh';
         $sqlParts['from']['dchecks'] = 'dchecks dc';
         $sqlParts['where'][] = dbConditionInt('dc.dcheckid', $options['dcheckids']);
         $sqlParts['where']['dhds'] = 'dh.hostid=ds.hostid';
         $sqlParts['where']['dcdh'] = 'dc.druleid=dh.druleid';
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['dcheckid'] = 'dc.dcheckid';
         }
     }
     // druleids
//.........这里部分代码省略.........
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:101,代码来源:CDService.php

示例10: get

 /**
  * Get history data
  *
  * {@source}
  * @access public
  * @static
  * @since 1.8.3
  * @version 1.3
  *
  * @param array $options
  * @param array $options['itemids']
  * @param boolean $options['editable']
  * @param string $options['pattern']
  * @param int $options['limit']
  * @param string $options['order']
  * @return array|int item data as array or false if error
  */
 public static function get($options = array())
 {
     global $USER_DETAILS;
     $nodeCheck = false;
     $result = array();
     $sort_columns = array('itemid', 'clock');
     // allowed columns for sorting
     $subselects_allowed_outputs = array(API_OUTPUT_REFER, API_OUTPUT_EXTEND);
     // allowed output options for [ select_* ] params
     $sql_parts = array('select' => array('history' => 'h.itemid'), 'from' => array(), 'where' => array(), 'group' => array(), 'order' => array(), 'limit' => null);
     $def_options = array('history' => ITEM_VALUE_TYPE_UINT64, 'nodeids' => null, 'hostids' => null, 'itemids' => null, 'triggerids' => null, 'editable' => null, 'nopermissions' => null, 'filter' => null, 'search' => null, 'startSearch' => null, 'excludeSearch' => null, 'time_from' => null, 'time_till' => null, 'output' => API_OUTPUT_REFER, 'countOutput' => null, 'groupCount' => null, 'groupOutput' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null);
     $options = zbx_array_merge($def_options, $options);
     switch ($options['history']) {
         case ITEM_VALUE_TYPE_LOG:
             $sql_parts['from']['history'] = 'history_log h';
             $sort_columns[] = 'id';
             break;
         case ITEM_VALUE_TYPE_TEXT:
             $sql_parts['from']['history'] = 'history_text h';
             $sort_columns[] = 'id';
             break;
         case ITEM_VALUE_TYPE_STR:
             $sql_parts['from']['history'] = 'history_str h';
             break;
         case ITEM_VALUE_TYPE_UINT64:
             $sql_parts['from']['history'] = 'history_uint h';
             break;
         case ITEM_VALUE_TYPE_FLOAT:
         default:
             $sql_parts['from']['history'] = 'history h';
     }
     // editable + PERMISSION CHECK
     if (USER_TYPE_SUPER_ADMIN == $USER_DETAILS['type'] || $options['nopermissions']) {
     } else {
         $itemOptions = array('editable' => $options['editable'], 'preservekeys' => 1);
         if (!is_null($options['itemids'])) {
             $itemOptions['itemids'] = $options['itemids'];
         }
         $items = CItem::get($itemOptions);
         $options['itemids'] = array_keys($items);
     }
     // nodeids
     $nodeids = !is_null($options['nodeids']) ? $options['nodeids'] : get_current_nodeid();
     // itemids
     if (!is_null($options['itemids'])) {
         zbx_value2array($options['itemids']);
         $sql_parts['where']['itemid'] = DBcondition('h.itemid', $options['itemids']);
         if (!$nodeCheck) {
             $nodeCheck = true;
             $sql_parts['where'][] = DBin_node('h.itemid', $nodeids);
         }
     }
     // hostids
     if (!is_null($options['hostids'])) {
         zbx_value2array($options['hostids']);
         if ($options['output'] != API_OUTPUT_SHORTEN) {
             $sql_parts['select']['hostid'] = 'i.hostid';
         }
         $sql_parts['from']['items'] = 'items i';
         $sql_parts['where']['i'] = DBcondition('i.hostid', $options['hostids']);
         $sql_parts['where']['hi'] = 'h.itemid=i.itemid';
         if (!$nodeCheck) {
             $nodeCheck = true;
             $sql_parts['where'][] = DBin_node('i.hostid', $nodeids);
         }
     }
     // node check !!!!!
     // should be last, after all ****IDS checks
     if (!$nodeCheck) {
         $nodeCheck = true;
         $sql_parts['where'][] = DBin_node('h.itemid', $nodeids);
     }
     // time_from
     if (!is_null($options['time_from'])) {
         $sql_parts['select']['clock'] = 'h.clock';
         $sql_parts['where']['clock_from'] = 'h.clock>=' . $options['time_from'];
     }
     // time_till
     if (!is_null($options['time_till'])) {
         $sql_parts['select']['clock'] = 'h.clock';
         $sql_parts['where']['clock_till'] = 'h.clock<=' . $options['time_till'];
     }
     // filter
//.........这里部分代码省略.........
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:101,代码来源:class.chistory.php

示例11: get_viewed_hosts

function get_viewed_hosts($perm, $groupid = 0, $options = array(), $nodeid = null, $sql = array())
{
    global $USER_DETAILS;
    global $page;
    $userid = $USER_DETAILS['userid'];
    $def_sql = array('select' => array('h.hostid', 'h.host'), 'from' => array('hosts h'), 'where' => array(), 'order' => array());
    $def_options = array('deny_all' => 0, 'allow_all' => 0, 'select_first_host' => 0, 'select_first_host_if_empty' => 0, 'select_host_on_group_switch' => 0, 'do_not_select' => 0, 'do_not_select_if_empty' => 0, 'monitored_hosts' => 0, 'templated_hosts' => 0, 'real_hosts' => 0, 'not_proxy_hosts' => 0, 'with_items' => 0, 'with_monitored_items' => 0, 'with_historical_items' => 0, 'with_triggers' => 0, 'with_monitored_triggers' => 0, 'with_httptests' => 0, 'with_monitored_httptests' => 0, 'with_graphs' => 0, 'only_current_node' => 0);
    $def_options = zbx_array_merge($def_options, $options);
    $config = select_config();
    $dd_first_entry = $config['dropdown_first_entry'];
    if ($def_options['allow_all']) {
        $dd_first_entry = ZBX_DROPDOWN_FIRST_ALL;
    }
    if ($def_options['deny_all']) {
        $dd_first_entry = ZBX_DROPDOWN_FIRST_NONE;
    }
    if ($dd_first_entry == ZBX_DROPDOWN_FIRST_ALL) {
        $def_options['select_host_on_group_switch'] = 1;
    }
    $result = array('original' => -1, 'selected' => 0, 'hosts' => array(), 'hostids' => array());
    $hosts =& $result['hosts'];
    $hostids =& $result['hostids'];
    $first_entry = $dd_first_entry == ZBX_DROPDOWN_FIRST_NONE ? S_NOT_SELECTED_SMALL : S_ALL_SMALL;
    $hosts['0'] = $first_entry;
    if (!is_array($groupid) && $groupid == 0) {
        if ($dd_first_entry == ZBX_DROPDOWN_FIRST_NONE) {
            return $result;
        }
    } else {
        zbx_value2array($groupid);
        $def_sql['from'][] = 'hosts_groups hg';
        $def_sql['where'][] = DBcondition('hg.groupid', $groupid);
        $def_sql['where'][] = 'hg.hostid=h.hostid';
    }
    $_REQUEST['hostid'] = $result['original'] = get_request('hostid', -1);
    //-----
    if (is_null($nodeid)) {
        if (!$def_options['only_current_node']) {
            $nodeid = get_current_nodeid();
        } else {
            $nodeid = get_current_nodeid(false);
        }
    }
    //$nodeid = is_null($nodeid)?get_current_nodeid($opt):$nodeid;
    //$available_hosts = get_accessible_hosts_by_user($USER_DETAILS,$perm,PERM_RES_IDS_ARRAY,$nodeid,AVAILABLE_NOCACHE);
    if (USER_TYPE_SUPER_ADMIN != $USER_DETAILS['type']) {
        $def_sql['from']['hg'] = 'hosts_groups hg';
        $def_sql['from']['r'] = 'rights r';
        $def_sql['from']['ug'] = 'users_groups ug';
        $def_sql['where']['hgh'] = 'hg.hostid=h.hostid';
        $def_sql['where'][] = 'r.id=hg.groupid ';
        $def_sql['where'][] = 'r.groupid=ug.usrgrpid';
        $def_sql['where'][] = 'ug.userid=' . $userid;
        $def_sql['where'][] = 'r.permission>=' . $perm;
        $def_sql['where'][] = 'NOT EXISTS( ' . ' SELECT hgg.groupid ' . ' FROM hosts_groups hgg, rights rr, users_groups gg ' . ' WHERE hgg.hostid=hg.hostid ' . ' AND rr.id=hgg.groupid ' . ' AND rr.groupid=gg.usrgrpid ' . ' AND gg.userid=' . $userid . ' AND rr.permission<' . $perm . ')';
    }
    // nodes
    if (ZBX_DISTRIBUTED) {
        $def_sql['select'][] = 'n.name';
        $def_sql['from'][] = 'nodes n';
        $def_sql['where'][] = 'n.nodeid=' . DBid2nodeid('h.hostid');
        $def_sql['order'][] = 'n.name';
    }
    // hosts
    if ($def_options['monitored_hosts']) {
        $def_sql['where'][] = 'h.status=' . HOST_STATUS_MONITORED;
    } else {
        if ($def_options['real_hosts']) {
            $def_sql['where'][] = 'h.status IN(' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')';
        } else {
            if ($def_options['templated_hosts']) {
                $def_sql['where'][] = 'h.status=' . HOST_STATUS_TEMPLATE;
            } else {
                if ($def_options['not_proxy_hosts']) {
                    $def_sql['where'][] = 'h.status<>' . HOST_STATUS_PROXY;
                }
            }
        }
    }
    // items
    if ($def_options['with_items']) {
        $def_sql['where'][] = 'EXISTS (SELECT i.hostid FROM items i WHERE h.hostid=i.hostid )';
    } else {
        if ($def_options['with_monitored_items']) {
            $def_sql['where'][] = 'EXISTS (SELECT i.hostid FROM items i WHERE h.hostid=i.hostid AND i.status=' . ITEM_STATUS_ACTIVE . ')';
        } else {
            if ($def_options['with_historical_items']) {
                $def_sql['where'][] = 'EXISTS (SELECT i.hostid FROM items i WHERE h.hostid=i.hostid AND (i.status=' . ITEM_STATUS_ACTIVE . ' OR i.status=' . ITEM_STATUS_NOTSUPPORTED . ') AND i.lastvalue IS NOT NULL)';
            }
        }
    }
    // triggers
    if ($def_options['with_triggers']) {
        $def_sql['where'][] = 'EXISTS( SELECT i.itemid ' . ' FROM items i, functions f, triggers t' . ' WHERE i.hostid=h.hostid ' . ' AND i.itemid=f.itemid ' . ' AND f.triggerid=t.triggerid)';
    } else {
        if ($def_options['with_monitored_triggers']) {
            $def_sql['where'][] = 'EXISTS( SELECT i.itemid ' . ' FROM items i, functions f, triggers t' . ' WHERE i.hostid=h.hostid ' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND i.itemid=f.itemid ' . ' AND f.triggerid=t.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ')';
        }
    }
    // httptests
//.........这里部分代码省略.........
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:101,代码来源:hosts.inc.php

示例12: get

 /**
  * Get items data.
  *
  * @param array  $options
  * @param array  $options['itemids']
  * @param array  $options['hostids']
  * @param array  $options['groupids']
  * @param array  $options['triggerids']
  * @param array  $options['applicationids']
  * @param bool   $options['status']
  * @param bool   $options['templated_items']
  * @param bool   $options['editable']
  * @param bool   $options['count']
  * @param string $options['pattern']
  * @param int    $options['limit']
  * @param string $options['order']
  *
  * @return array|int item data as array or false if error
  */
 public function get($options = array())
 {
     $result = array();
     $userType = self::$userData['type'];
     $userid = self::$userData['userid'];
     $sqlParts = array('select' => array('items' => 'i.itemid'), 'from' => array('items' => 'items i'), 'where' => array('webtype' => 'i.type<>' . ITEM_TYPE_HTTPTEST, 'flags' => 'i.flags IN (' . ZBX_FLAG_DISCOVERY_NORMAL . ',' . ZBX_FLAG_DISCOVERY_CREATED . ')'), 'group' => array(), 'order' => array(), 'limit' => null);
     $defOptions = array('groupids' => null, 'templateids' => null, 'hostids' => null, 'proxyids' => null, 'itemids' => null, 'interfaceids' => null, 'graphids' => null, 'triggerids' => null, 'applicationids' => null, 'webitems' => null, 'inherited' => null, 'templated' => null, 'monitored' => null, 'editable' => null, 'nopermissions' => null, 'group' => null, 'host' => null, 'application' => null, 'with_triggers' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_EXTEND, 'selectHosts' => null, 'selectInterfaces' => null, 'selectTriggers' => null, 'selectGraphs' => null, 'selectApplications' => null, 'selectDiscoveryRule' => null, 'selectItemDiscovery' => null, 'countOutput' => null, 'groupCount' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null, 'limitSelects' => null);
     $options = zbx_array_merge($defOptions, $options);
     // editable + permission check
     if ($userType != USER_TYPE_SUPER_ADMIN && !$options['nopermissions']) {
         $permission = $options['editable'] ? PERM_READ_WRITE : PERM_READ;
         $userGroups = getUserGroupsByUserId($userid);
         $sqlParts['where'][] = 'EXISTS (' . 'SELECT NULL' . ' FROM hosts_groups hgg' . ' JOIN rights r' . ' ON r.id=hgg.groupid' . ' AND ' . dbConditionInt('r.groupid', $userGroups) . ' WHERE i.hostid=hgg.hostid' . ' GROUP BY hgg.hostid' . ' HAVING MIN(r.permission)>' . PERM_DENY . ' AND MAX(r.permission)>=' . zbx_dbstr($permission) . ')';
     }
     // itemids
     if (!is_null($options['itemids'])) {
         zbx_value2array($options['itemids']);
         $sqlParts['where']['itemid'] = dbConditionInt('i.itemid', $options['itemids']);
     }
     // templateids
     if (!is_null($options['templateids'])) {
         zbx_value2array($options['templateids']);
         if (!is_null($options['hostids'])) {
             zbx_value2array($options['hostids']);
             $options['hostids'] = array_merge($options['hostids'], $options['templateids']);
         } else {
             $options['hostids'] = $options['templateids'];
         }
     }
     // hostids
     if (!is_null($options['hostids'])) {
         zbx_value2array($options['hostids']);
         $sqlParts['where']['hostid'] = dbConditionInt('i.hostid', $options['hostids']);
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['i'] = 'i.hostid';
         }
     }
     // interfaceids
     if (!is_null($options['interfaceids'])) {
         zbx_value2array($options['interfaceids']);
         $sqlParts['where']['interfaceid'] = dbConditionInt('i.interfaceid', $options['interfaceids']);
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['i'] = 'i.interfaceid';
         }
     }
     // groupids
     if (!is_null($options['groupids'])) {
         zbx_value2array($options['groupids']);
         $sqlParts['from']['hosts_groups'] = 'hosts_groups hg';
         $sqlParts['where'][] = dbConditionInt('hg.groupid', $options['groupids']);
         $sqlParts['where'][] = 'hg.hostid=i.hostid';
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['hg'] = 'hg.groupid';
         }
     }
     // proxyids
     if (!is_null($options['proxyids'])) {
         zbx_value2array($options['proxyids']);
         $sqlParts['from']['hosts'] = 'hosts h';
         $sqlParts['where'][] = dbConditionInt('h.proxy_hostid', $options['proxyids']);
         $sqlParts['where'][] = 'h.hostid=i.hostid';
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['h'] = 'h.proxy_hostid';
         }
     }
     // triggerids
     if (!is_null($options['triggerids'])) {
         zbx_value2array($options['triggerids']);
         $sqlParts['from']['functions'] = 'functions f';
         $sqlParts['where'][] = dbConditionInt('f.triggerid', $options['triggerids']);
         $sqlParts['where']['if'] = 'i.itemid=f.itemid';
     }
     // applicationids
     if (!is_null($options['applicationids'])) {
         zbx_value2array($options['applicationids']);
         $sqlParts['from']['items_applications'] = 'items_applications ia';
         $sqlParts['where'][] = dbConditionInt('ia.applicationid', $options['applicationids']);
         $sqlParts['where']['ia'] = 'ia.itemid=i.itemid';
     }
     // graphids
     if (!is_null($options['graphids'])) {
//.........这里部分代码省略.........
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:101,代码来源:CItem.php

示例13: str_in_array

             $i['value_type'] = $item['value_type'];
             //ZBX-3059: So it would be possible to show different caption for history for chars and numbers (KB)
             $i['action'] = str_in_array($item['value_type'], array(ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64)) ? 'showgraph' : 'showvalues';
             $i['description'] = item_description($item);
             $items[] = $i;
         }
         // Actions
         $actions = get_event_actions_status($event['eventid']);
         if ($config['event_ack_enable']) {
             if ($event['acknowledged'] == 1) {
                 $ack = new CLink(S_YES, 'acknow.php?eventid=' . $event['eventid'] . '&backurl=' . $page['file']);
             } else {
                 $ack = new CLink(S_NO, 'acknow.php?eventid=' . $event['eventid'] . '&backurl=' . $page['file'], 'on');
             }
         }
         $description = expand_trigger_description_by_data(zbx_array_merge($trigger, array('clock' => $event['clock'])), ZBX_FLAG_EVENT);
         $tr_desc = new CSpan($description, 'pointer');
         $tr_desc->addAction('onclick', "create_mon_trigger_menu(event, " . " new Array({'triggerid': '" . $trigger['triggerid'] . "', 'lastchange': '" . $event['clock'] . "'})," . zbx_jsvalue($items, true) . ");");
         // Duration
         $tr_event = $event + $trigger;
         if ($next_event = get_next_event($tr_event, $events, $_REQUEST['hide_unknown'])) {
             $event['duration'] = zbx_date2age($tr_event['clock'], $next_event['clock']);
         } else {
             $event['duration'] = zbx_date2age($tr_event['clock']);
         }
         $table->addRow(array(new CLink(zbx_date2str(S_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, $_REQUEST['hostid'] == 0 ? $host['host'] : null, new CSpan($tr_desc, 'link_menu'), new CCol(trigger_value2str($event['value']), get_trigger_value_style($event['value'])), new CCol(get_severity_description($trigger['priority']), get_severity_style($trigger['priority'], $event['value'])), $event['duration'], $config['event_ack_enable'] ? $ack : NULL, $actions));
     }
 }
 $table = array($paging, $table, $paging);
 $jsmenu = new CPUMenu(null, 170);
 $jsmenu->InsertJavaScript();
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:31,代码来源:events.php

示例14: getItemFormData


//.........这里部分代码省略.........
        $data['interfaceid'] = $data['item']['interfaceid'];
        $data['type'] = $data['item']['type'];
        $data['snmp_community'] = $data['item']['snmp_community'];
        $data['snmp_oid'] = $data['item']['snmp_oid'];
        $data['port'] = $data['item']['port'];
        $data['value_type'] = $data['item']['value_type'];
        $data['data_type'] = $data['item']['data_type'];
        $data['trapper_hosts'] = $data['item']['trapper_hosts'];
        $data['units'] = $data['item']['units'];
        $data['valuemapid'] = $data['item']['valuemapid'];
        $data['multiplier'] = $data['item']['multiplier'];
        $data['hostid'] = $data['item']['hostid'];
        $data['params'] = $data['item']['params'];
        $data['snmpv3_contextname'] = $data['item']['snmpv3_contextname'];
        $data['snmpv3_securityname'] = $data['item']['snmpv3_securityname'];
        $data['snmpv3_securitylevel'] = $data['item']['snmpv3_securitylevel'];
        $data['snmpv3_authprotocol'] = $data['item']['snmpv3_authprotocol'];
        $data['snmpv3_authpassphrase'] = $data['item']['snmpv3_authpassphrase'];
        $data['snmpv3_privprotocol'] = $data['item']['snmpv3_privprotocol'];
        $data['snmpv3_privpassphrase'] = $data['item']['snmpv3_privpassphrase'];
        $data['ipmi_sensor'] = $data['item']['ipmi_sensor'];
        $data['authtype'] = $data['item']['authtype'];
        $data['username'] = $data['item']['username'];
        $data['password'] = $data['item']['password'];
        $data['publickey'] = $data['item']['publickey'];
        $data['privatekey'] = $data['item']['privatekey'];
        $data['logtimefmt'] = $data['item']['logtimefmt'];
        $data['new_application'] = getRequest('new_application', '');
        if (!$data['is_discovery_rule']) {
            $data['formula'] = $data['item']['formula'];
        }
        if (!$data['limited'] || !isset($_REQUEST['form_refresh'])) {
            $data['delay'] = $data['item']['delay'];
            if (($data['type'] == ITEM_TYPE_TRAPPER || $data['type'] == ITEM_TYPE_SNMPTRAP) && $data['delay'] == 0) {
                $data['delay'] = ZBX_ITEM_DELAY_DEFAULT;
            }
            $data['history'] = $data['item']['history'];
            $data['status'] = $data['item']['status'];
            $data['delta'] = $data['item']['delta'];
            $data['trends'] = $data['item']['trends'];
            $db_delay_flex = $data['item']['delay_flex'];
            if (isset($db_delay_flex)) {
                $arr_of_dellays = explode(';', $db_delay_flex);
                foreach ($arr_of_dellays as $one_db_delay) {
                    $arr_of_delay = explode('/', $one_db_delay);
                    if (!isset($arr_of_delay[0]) || !isset($arr_of_delay[1])) {
                        continue;
                    }
                    array_push($data['delay_flex'], array('delay' => $arr_of_delay[0], 'period' => $arr_of_delay[1]));
                }
            }
            $data['applications'] = array_unique(zbx_array_merge($data['applications'], get_applications_by_itemid($data['itemid'])));
        }
    }
    // applications
    if (count($data['applications']) == 0) {
        array_push($data['applications'], 0);
    }
    $data['db_applications'] = DBfetchArray(DBselect('SELECT DISTINCT a.applicationid,a.name' . ' FROM applications a' . ' WHERE a.hostid=' . zbx_dbstr($data['hostid'])));
    order_result($data['db_applications'], 'name');
    // interfaces
    $data['interfaces'] = API::HostInterface()->get(array('hostids' => $data['hostid'], 'output' => API_OUTPUT_EXTEND));
    // valuemapid
    if ($data['limited']) {
        if (!empty($data['valuemapid'])) {
            if ($map_data = DBfetch(DBselect('SELECT v.name FROM valuemaps v WHERE v.valuemapid=' . zbx_dbstr($data['valuemapid'])))) {
                $data['valuemaps'] = $map_data['name'];
            }
        }
    } else {
        $data['valuemaps'] = DBfetchArray(DBselect('SELECT v.* FROM valuemaps v'));
        order_result($data['valuemaps'], 'name');
    }
    // possible host inventories
    if (empty($data['parent_discoveryid'])) {
        $data['possibleHostInventories'] = getHostInventories();
        // get already populated fields by other items
        $data['alreadyPopulated'] = API::item()->get(array('output' => array('inventory_link'), 'filter' => array('hostid' => $data['hostid']), 'nopermissions' => true));
        $data['alreadyPopulated'] = zbx_toHash($data['alreadyPopulated'], 'inventory_link');
    }
    // template
    $data['is_template'] = isTemplate($data['hostid']);
    // unset snmpv3 fields
    if ($data['type'] != ITEM_TYPE_SNMPV3) {
        $data['snmpv3_contextname'] = '';
        $data['snmpv3_securityname'] = '';
        $data['snmpv3_securitylevel'] = ITEM_SNMPV3_SECURITYLEVEL_NOAUTHNOPRIV;
        $data['snmpv3_authprotocol'] = ITEM_AUTHPROTOCOL_MD5;
        $data['snmpv3_authpassphrase'] = '';
        $data['snmpv3_privprotocol'] = ITEM_PRIVPROTOCOL_DES;
        $data['snmpv3_privpassphrase'] = '';
    }
    // unset ssh auth fields
    if ($data['type'] != ITEM_TYPE_SSH) {
        $data['authtype'] = ITEM_AUTHTYPE_PASSWORD;
        $data['publickey'] = '';
        $data['privatekey'] = '';
    }
    return $data;
}
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:101,代码来源:forms.inc.php

示例15: getUserData

 private function getUserData($user)
 {
     if (!$this->connect()) {
         return false;
     }
     // force superuser bind if wanted and not bound as superuser yet
     if (!empty($this->cnf['bind_dn']) && !empty($this->cnf['bind_password']) && $this->bound < 2) {
         if (!ldap_bind($this->ds, $this->cnf['bind_dn'], $this->cnf['bind_password'])) {
             return false;
         }
         $this->bound = 2;
     }
     // with no superuser creds we continue as user or anonymous here
     $info['user'] = $user;
     $info['host'] = $this->cnf['host'];
     // get info for given user
     $base = $this->makeFilter($this->cnf['base_dn'], $info);
     if (isset($this->cnf['userfilter']) && !empty($this->cnf['userfilter'])) {
         $filter = $this->makeFilter($this->cnf['userfilter'], $info);
     } else {
         $filter = '(ObjectClass=*)';
     }
     $sr = ldap_search($this->ds, $base, $filter);
     $result = ldap_get_entries($this->ds, $sr);
     // don't accept more or less than one response
     if ($result['count'] != 1) {
         error('LDAP: User not found.');
         return false;
     }
     $user_result = $result[0];
     ldap_free_result($sr);
     // general user info
     $info['dn'] = $user_result['dn'];
     $info['name'] = $user_result['cn'][0];
     $info['grps'] = array();
     // overwrite if other attribs are specified.
     if (is_array($this->cnf['mapping'])) {
         foreach ($this->cnf['mapping'] as $localkey => $key) {
             $info[$localkey] = isset($user_result[$key]) ? $user_result[$key][0] : null;
         }
     }
     $user_result = zbx_array_merge($info, $user_result);
     // get groups for given user if grouptree is given
     if (isset($this->cnf['grouptree']) && isset($this->cnf['groupfilter'])) {
         $base = $this->makeFilter($this->cnf['grouptree'], $user_result);
         $filter = $this->makeFilter($this->cnf['groupfilter'], $user_result);
         $sr = ldap_search($this->ds, $base, $filter, array($this->cnf['groupkey']));
         if (!$sr) {
             error('LDAP: Reading group memberships failed.');
             return false;
         }
         $result = ldap_get_entries($this->ds, $sr);
         foreach ($result as $grp) {
             if (!empty($grp[$this->cnf['groupkey']][0])) {
                 $info['grps'][] = $grp[$this->cnf['groupkey']][0];
             }
         }
     }
     // always add the default group to the list of groups
     if (isset($conf['defaultgroup']) && !str_in_array($conf['defaultgroup'], $info['grps'])) {
         $info['grps'][] = $conf['defaultgroup'];
     }
     return $info;
 }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:64,代码来源:CLdap.php


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