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


PHP CMacrosResolverHelper::resolveTriggerDescriptions方法代码示例

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


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

示例1: get


//.........这里部分代码省略.........
     if (is_array($options['filter'])) {
         if (!array_key_exists('flags', $options['filter'])) {
             $options['filter']['flags'] = [ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED];
         }
         $this->dbFilter('triggers t', $options, $sqlParts);
         if (isset($options['filter']['host']) && !is_null($options['filter']['host'])) {
             zbx_value2array($options['filter']['host']);
             $sqlParts['from']['functions'] = 'functions f';
             $sqlParts['from']['items'] = 'items i';
             $sqlParts['where']['ft'] = 'f.triggerid=t.triggerid';
             $sqlParts['where']['fi'] = 'f.itemid=i.itemid';
             $sqlParts['from']['hosts'] = 'hosts h';
             $sqlParts['where']['hi'] = 'h.hostid=i.hostid';
             $sqlParts['where']['host'] = dbConditionString('h.host', $options['filter']['host']);
         }
         if (isset($options['filter']['hostid']) && !is_null($options['filter']['hostid'])) {
             zbx_value2array($options['filter']['hostid']);
             $sqlParts['from']['functions'] = 'functions f';
             $sqlParts['from']['items'] = 'items i';
             $sqlParts['where']['ft'] = 'f.triggerid=t.triggerid';
             $sqlParts['where']['fi'] = 'f.itemid=i.itemid';
             $sqlParts['where']['hostid'] = dbConditionInt('i.hostid', $options['filter']['hostid']);
         }
     }
     // group
     if (!is_null($options['group'])) {
         $sqlParts['from']['functions'] = 'functions f';
         $sqlParts['from']['items'] = 'items i';
         $sqlParts['from']['hosts_groups'] = 'hosts_groups hg';
         $sqlParts['from']['groups'] = 'groups g';
         $sqlParts['where']['ft'] = 'f.triggerid=t.triggerid';
         $sqlParts['where']['fi'] = 'f.itemid=i.itemid';
         $sqlParts['where']['hgi'] = 'hg.hostid=i.hostid';
         $sqlParts['where']['ghg'] = 'g.groupid = hg.groupid';
         $sqlParts['where']['group'] = ' g.name=' . zbx_dbstr($options['group']);
     }
     // host
     if (!is_null($options['host'])) {
         $sqlParts['from']['functions'] = 'functions f';
         $sqlParts['from']['items'] = 'items i';
         $sqlParts['from']['hosts'] = 'hosts h';
         $sqlParts['where']['ft'] = 'f.triggerid=t.triggerid';
         $sqlParts['where']['fi'] = 'f.itemid=i.itemid';
         $sqlParts['where']['hi'] = 'h.hostid=i.hostid';
         $sqlParts['where']['host'] = ' h.host=' . zbx_dbstr($options['host']);
     }
     // only_true
     if (!is_null($options['only_true'])) {
         $config = select_config();
         $sqlParts['where']['ot'] = '((t.value=' . TRIGGER_VALUE_TRUE . ')' . ' OR ' . '((t.value=' . TRIGGER_VALUE_FALSE . ') AND (t.lastchange>' . (time() - $config['ok_period']) . ')))';
     }
     // min_severity
     if (!is_null($options['min_severity'])) {
         $sqlParts['where'][] = 't.priority>=' . zbx_dbstr($options['min_severity']);
     }
     // limit
     if (!zbx_ctype_digit($options['limit']) || !$options['limit']) {
         $options['limit'] = null;
     }
     $sqlParts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $sqlParts = $this->applyQuerySortOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     // return count or grouped counts via direct SQL count
     if (!is_null($options['countOutput']) && !$this->requiresPostSqlFiltering($options)) {
         $dbRes = DBselect($this->createSelectQueryFromParts($sqlParts), $options['limit']);
         while ($trigger = DBfetch($dbRes)) {
             if (!is_null($options['groupCount'])) {
                 $result[] = $trigger;
             } else {
                 $result = $trigger['rowscount'];
             }
         }
         return $result;
     }
     $result = zbx_toHash($this->customFetch($this->createSelectQueryFromParts($sqlParts), $options), 'triggerid');
     // return count for post SQL filtered result sets
     if (!is_null($options['countOutput'])) {
         return count($result);
     }
     if ($result) {
         $result = $this->addRelatedObjects($options, $result);
     }
     // expandDescription
     if (!is_null($options['expandDescription']) && $result && array_key_exists('description', reset($result))) {
         $result = CMacrosResolverHelper::resolveTriggerNames($result);
     }
     // expandComment
     if (!is_null($options['expandComment']) && $result && array_key_exists('comments', reset($result))) {
         $result = CMacrosResolverHelper::resolveTriggerDescriptions($result);
     }
     // expand expression
     if ($options['expandExpression'] !== null && $result && array_key_exists('expression', reset($result))) {
         $result = CMacrosResolverHelper::resolveTriggerExpressions($result, ['resolve_usermacros' => true, 'resolve_macros' => true]);
     }
     // removing keys (hash -> array)
     if (is_null($options['preservekeys'])) {
         $result = zbx_cleanHashes($result);
     }
     $result = $this->unsetExtraFields($result, ['state', 'expression'], $options['output']);
     return $result;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:CTrigger.php


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