當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。