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


PHP CMacrosResolverHelper::resolveItemNames方法代码示例

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


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

示例1: get

 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     // if screen is defined in template, then 'real_resourceid' is defined and should be used
     if (!empty($this->screenitem['real_resourceid'])) {
         $this->screenitem['resourceid'] = $this->screenitem['real_resourceid'];
     }
     if ($this->screenitem['dynamic'] == SCREEN_DYNAMIC_ITEM && !empty($this->hostid)) {
         $newitemid = get_same_item_for_host($this->screenitem['resourceid'], $this->hostid);
         $this->screenitem['resourceid'] = !empty($newitemid) ? $newitemid : 0;
     }
     if ($this->screenitem['resourceid'] == 0) {
         $table = (new CTableInfo())->setHeader([_('Timestamp'), _('Item')]);
         return $this->getOutput($table);
     }
     $items = CMacrosResolverHelper::resolveItemNames([get_item_by_itemid($this->screenitem['resourceid'])]);
     $item = reset($items);
     switch ($item['value_type']) {
         case ITEM_VALUE_TYPE_TEXT:
         case ITEM_VALUE_TYPE_LOG:
             $orderField = 'id';
             break;
         case ITEM_VALUE_TYPE_FLOAT:
         case ITEM_VALUE_TYPE_UINT64:
         default:
             $orderField = ['itemid', 'clock'];
     }
     $host = get_host_by_itemid($this->screenitem['resourceid']);
     $table = (new CTableInfo())->setHeader([_('Timestamp'), _('Value')]);
     $stime = zbxDateToTime($this->timeline['stime']);
     $histories = API::History()->get(['history' => $item['value_type'], 'itemids' => $this->screenitem['resourceid'], 'output' => API_OUTPUT_EXTEND, 'sortorder' => ZBX_SORT_DOWN, 'sortfield' => $orderField, 'limit' => $this->screenitem['elements'], 'time_from' => $stime, 'time_till' => $stime + $this->timeline['period']]);
     foreach ($histories as $history) {
         switch ($item['value_type']) {
             case ITEM_VALUE_TYPE_FLOAT:
                 sscanf($history['value'], '%f', $value);
                 break;
             case ITEM_VALUE_TYPE_TEXT:
             case ITEM_VALUE_TYPE_STR:
             case ITEM_VALUE_TYPE_LOG:
                 $value = $this->screenitem['style'] ? new CJsScript($history['value']) : $history['value'];
                 break;
             default:
                 $value = $history['value'];
                 break;
         }
         if ($item['valuemapid'] > 0) {
             $value = applyValueMap($value, $item['valuemapid']);
         }
         if ($this->screenitem['style'] == 0) {
             $value = new CPre($value);
         }
         $table->addRow([zbx_date2str(DATE_TIME_FORMAT_SECONDS, $history['clock']), $value]);
     }
     $footer = (new CList())->addItem(_s('Updated: %s', zbx_date2str(TIME_FORMAT_SECONDS)))->addClass(ZBX_STYLE_DASHBRD_WIDGET_FOOT);
     return $this->getOutput((new CUiWidget(uniqid(), [$table, $footer]))->setHeader($host['name'] . NAME_DELIMITER . $item['name_expanded']));
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:60,代码来源:CScreenPlainText.php

示例2: get

 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     // if screen is defined in template, then 'real_resourceid' is defined and should be used
     if (!empty($this->screenitem['real_resourceid'])) {
         $this->screenitem['resourceid'] = $this->screenitem['real_resourceid'];
     }
     if ($this->screenitem['dynamic'] == SCREEN_DYNAMIC_ITEM && !empty($this->hostid)) {
         $newitemid = get_same_item_for_host($this->screenitem['resourceid'], $this->hostid);
         $this->screenitem['resourceid'] = !empty($newitemid) ? $newitemid : 0;
     }
     if ($this->screenitem['resourceid'] == 0) {
         $table = new CTableInfo(_('No values found.'));
         $table->setHeader(array(_('Timestamp'), _('Item')));
         return $this->getOutput($table);
     }
     $items = CMacrosResolverHelper::resolveItemNames(array(get_item_by_itemid($this->screenitem['resourceid'])));
     $item = reset($items);
     switch ($item['value_type']) {
         case ITEM_VALUE_TYPE_TEXT:
         case ITEM_VALUE_TYPE_LOG:
             $orderField = 'id';
             break;
         case ITEM_VALUE_TYPE_FLOAT:
         case ITEM_VALUE_TYPE_UINT64:
         default:
             $orderField = array('itemid', 'clock');
     }
     $host = get_host_by_itemid($this->screenitem['resourceid']);
     $table = new CTableInfo(_('No values found.'));
     $table->setHeader(array(_('Timestamp'), $host['name'] . NAME_DELIMITER . $item['name_expanded']));
     $stime = zbxDateToTime($this->timeline['stime']);
     $histories = API::History()->get(array('history' => $item['value_type'], 'itemids' => $this->screenitem['resourceid'], 'output' => API_OUTPUT_EXTEND, 'sortorder' => ZBX_SORT_DOWN, 'sortfield' => $orderField, 'limit' => $this->screenitem['elements'], 'time_from' => $stime, 'time_till' => $stime + $this->timeline['period']));
     foreach ($histories as $history) {
         switch ($item['value_type']) {
             case ITEM_VALUE_TYPE_FLOAT:
                 sscanf($history['value'], '%f', $value);
                 break;
             case ITEM_VALUE_TYPE_TEXT:
             case ITEM_VALUE_TYPE_STR:
             case ITEM_VALUE_TYPE_LOG:
                 $value = $this->screenitem['style'] ? new CJsScript($history['value']) : $history['value'];
                 break;
             default:
                 $value = $history['value'];
                 break;
         }
         if ($item['valuemapid'] > 0) {
             $value = applyValueMap($value, $item['valuemapid']);
         }
         $class = $this->screenitem['style'] ? null : 'pre';
         $table->addRow(array(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $history['clock']), new CCol($value, $class)));
     }
     return $this->getOutput($table);
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:59,代码来源:CScreenPlainText.php

示例3: addItem

 public function addItem($itemid, $calc_fnc = CALC_FNC_AVG, $color = null, $type = null)
 {
     $items = CMacrosResolverHelper::resolveItemNames(array(get_item_by_itemid($itemid)));
     $this->items[$this->num] = reset($items);
     $host = get_host_by_hostid($this->items[$this->num]['hostid']);
     $this->items[$this->num]['host'] = $host['host'];
     $this->items[$this->num]['hostname'] = $host['name'];
     $this->items[$this->num]['color'] = is_null($color) ? 'Dark Green' : $color;
     $this->items[$this->num]['calc_fnc'] = is_null($calc_fnc) ? CALC_FNC_AVG : $calc_fnc;
     $this->items[$this->num]['calc_type'] = is_null($type) ? GRAPH_ITEM_SIMPLE : $type;
     $this->num++;
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:12,代码来源:CPieGraphDraw.php

示例4: getFavouriteGraphsData

/**
 * Get favourite graphs and simple graph data.
 *
 * @return array['graphs']
 * @return array['simpleGraphs']
 */
function getFavouriteGraphsData()
{
    $graphs = $simpeGraphs = [];
    $favourites = CFavorite::get('web.favorite.graphids');
    if ($favourites) {
        $graphIds = $itemIds = $dbGraphs = $dbItems = [];
        foreach ($favourites as $favourite) {
            if ($favourite['source'] === 'itemid') {
                $itemIds[$favourite['value']] = $favourite['value'];
            } else {
                $graphIds[$favourite['value']] = $favourite['value'];
            }
        }
        if ($graphIds) {
            $dbGraphs = API::Graph()->get(['output' => ['graphid', 'name'], 'selectHosts' => ['hostid', 'name'], 'expandName' => true, 'graphids' => $graphIds, 'preservekeys' => true]);
        }
        if ($itemIds) {
            $dbItems = API::Item()->get(['output' => ['itemid', 'hostid', 'name', 'key_'], 'selectHosts' => ['hostid', 'name'], 'itemids' => $itemIds, 'webitems' => true, 'preservekeys' => true]);
            $dbItems = CMacrosResolverHelper::resolveItemNames($dbItems);
        }
        foreach ($favourites as $favourite) {
            $sourceId = $favourite['value'];
            if ($favourite['source'] === 'itemid') {
                if (isset($dbItems[$sourceId])) {
                    $dbItem = $dbItems[$sourceId];
                    $dbHost = reset($dbItem['hosts']);
                    $simpeGraphs[] = ['id' => $sourceId, 'label' => $dbHost['name'] . NAME_DELIMITER . $dbItem['name_expanded']];
                }
            } else {
                if (isset($dbGraphs[$sourceId])) {
                    $dbGraph = $dbGraphs[$sourceId];
                    $dbHost = reset($dbGraph['hosts']);
                    $graphs[] = ['id' => $sourceId, 'label' => $dbHost['name'] . NAME_DELIMITER . $dbGraph['name']];
                }
            }
        }
    }
    return ['graphs' => $graphs, 'simpleGraphs' => $simpeGraphs];
}
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:45,代码来源:blocks.inc.php

示例5: getCreatedItemIds

 /**
  * Retrieves items created for item prototype given as resource for this screen item
  * and returns array of the item IDs, ordered by item name.
  *
  * @return array
  */
 protected function getCreatedItemIds()
 {
     if (!$this->createdItemIds) {
         $itemPrototype = $this->getItemPrototype();
         if ($itemPrototype) {
             // get all created (discovered) items for current host
             $allCreatedItems = API::Item()->get(array('output' => array('itemid', 'name', 'key_', 'hostid'), 'hostids' => array($itemPrototype['discoveryRule']['hostid']), 'selectItemDiscovery' => array('itemid', 'parent_itemid'), 'filter' => array('flags' => ZBX_FLAG_DISCOVERY_CREATED)));
             // collect those items where parent item is item prototype selected for this screen item as resource
             $createdItems = array();
             foreach ($allCreatedItems as $item) {
                 if ($item['itemDiscovery']['parent_itemid'] == $itemPrototype['itemid']) {
                     $createdItems[] = $item;
                 }
             }
             $createdItems = CMacrosResolverHelper::resolveItemNames($createdItems);
             foreach ($createdItems as $item) {
                 $this->createdItemIds[$item['itemid']] = $item['name_expanded'];
             }
             natsort($this->createdItemIds);
             $this->createdItemIds = array_keys($this->createdItemIds);
         }
     }
     return $this->createdItemIds;
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:30,代码来源:CScreenLldSimpleGraph.php

示例6: unset

        }
    }
} else {
    if (preg_match('/^([a-z]+)\\[([=><]{1,2})\\]$/i', $exprType, $matches)) {
        $function = $matches[1];
        $operator = $matches[2];
        if (!isset($functions[$exprType])) {
            unset($function);
        }
    }
    // fetch item
    $item = API::Item()->get(array('output' => array('itemid', 'hostid', 'name', 'key_', 'value_type'), 'selectHosts' => array('host', 'name'), 'itemids' => $itemId, 'webitems' => true, 'filter' => array('flags' => null)));
    $item = reset($item);
}
if ($itemId) {
    $items = CMacrosResolverHelper::resolveItemNames(array($item));
    $item = $items[0];
    $itemValueType = $item['value_type'];
    $itemKey = $item['key_'];
    $itemHostData = reset($item['hosts']);
    $description = $itemHostData['name'] . NAME_DELIMITER . $item['name_expanded'];
} else {
    $itemKey = '';
    $description = '';
    $itemValueType = null;
}
if (is_null($paramType) && isset($functions[$exprType]['params']['M'])) {
    $paramType = is_array($functions[$exprType]['params']['M']) ? reset($functions[$exprType]['params']['M']) : $functions[$exprType]['params']['M'];
} elseif (is_null($paramType)) {
    $paramType = PARAM_TYPE_TIME;
}
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:31,代码来源:popup_trexpr.php

示例7: make_graph_submenu

function make_graph_submenu()
{
    $graphids = array();
    $itemids = array();
    $favGraphs = array();
    $fav_graphs = CFavorite::get('web.favorite.graphids');
    if (!$fav_graphs) {
        return $favGraphs;
    }
    foreach ($fav_graphs as $favorite) {
        if ('itemid' == $favorite['source']) {
            $itemids[$favorite['value']] = $favorite['value'];
        } else {
            $graphids[$favorite['value']] = $favorite['value'];
        }
    }
    if ($graphids) {
        $options = array('graphids' => $graphids, 'selectHosts' => array('hostid', 'host'), 'output' => array('graphid', 'name'), 'expandName' => true);
        $graphs = API::Graph()->get($options);
        $graphs = zbx_toHash($graphs, 'graphid');
    }
    if ($itemids) {
        $items = API::Item()->get(array('output' => array('itemid', 'hostid', 'name', 'key_'), 'selectHosts' => array('hostid', 'host'), 'itemids' => $itemids, 'webitems' => true, 'preservekeys' => true));
        $items = CMacrosResolverHelper::resolveItemNames($items);
    }
    foreach ($fav_graphs as $favorite) {
        $source = $favorite['source'];
        $sourceid = $favorite['value'];
        if ($source == 'itemid') {
            if (!isset($items[$sourceid])) {
                continue;
            }
            $item_added = true;
            $item = $items[$sourceid];
            $host = reset($item['hosts']);
            $favGraphs[] = array('name' => $host['host'] . NAME_DELIMITER . $item['name_expanded'], 'favobj' => 'itemid', 'favid' => $sourceid, 'favaction' => 'remove');
        } else {
            if (!isset($graphs[$sourceid])) {
                continue;
            }
            $graph_added = true;
            $graph = $graphs[$sourceid];
            $ghost = reset($graph['hosts']);
            $favGraphs[] = array('name' => $ghost['host'] . NAME_DELIMITER . $graph['name'], 'favobj' => 'graphid', 'favid' => $sourceid, 'favaction' => 'remove');
        }
    }
    if (isset($graph_added)) {
        $favGraphs[] = array('name' => _('Remove') . ' ' . _('All') . ' ' . _('Graphs'), 'favobj' => 'graphid', 'favid' => 0, 'favaction' => 'remove');
    }
    if (isset($item_added)) {
        $favGraphs[] = array('name' => _('Remove') . ' ' . _('All') . ' ' . _('Simple graphs'), 'favobj' => 'itemid', 'favid' => 0, 'favaction' => 'remove');
    }
    return $favGraphs;
}
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:54,代码来源:blocks.inc.php

示例8: unset

        }
    }
} else {
    if (preg_match('/^([a-z]+)\\[([=><]{1,2})\\]$/i', $exprType, $matches)) {
        $function = $matches[1];
        $operator = $matches[2];
        if (!isset($functions[$exprType])) {
            unset($function);
        }
    }
    // fetch item
    $item = API::Item()->get(['output' => ['itemid', 'hostid', 'name', 'key_', 'value_type'], 'selectHosts' => ['host', 'name'], 'itemids' => $itemId, 'webitems' => true, 'filter' => ['flags' => null]]);
    $item = reset($item);
}
if ($itemId) {
    $items = CMacrosResolverHelper::resolveItemNames([$item]);
    $item = $items[0];
    $itemValueType = $item['value_type'];
    $itemKey = $item['key_'];
    $itemHostData = reset($item['hosts']);
    $description = $itemHostData['name'] . NAME_DELIMITER . $item['name_expanded'];
} else {
    $itemKey = '';
    $description = '';
    $itemValueType = null;
}
if (is_null($paramType) && isset($functions[$exprType]['params']['M'])) {
    $paramType = is_array($functions[$exprType]['params']['M']) ? reset($functions[$exprType]['params']['M']) : $functions[$exprType]['params']['M'];
} elseif (is_null($paramType)) {
    $paramType = PARAM_TYPE_TIME;
}
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:popup_trexpr.php

示例9: array

 if ($hostDiscoveryRules) {
     $hostDiscoveryRules = CMacrosResolverHelper::resolveItemNames($hostDiscoveryRules);
     $discoveryRuleList = array();
     foreach ($hostDiscoveryRules as $discoveryRule) {
         $discoveryRuleList[$discoveryRule['itemid']] = $discoveryRule['name_expanded'];
     }
     order_result($discoveryRuleList);
     $hostDiscoveryRuleids = array_keys($discoveryRuleList);
     $listBox = new CListBox('discoveryRules', null, 8);
     $listBox->setAttribute('disabled', 'disabled');
     $listBox->addItems($discoveryRuleList);
     $templateList->addRow(_('Discovery rules'), $listBox);
     // item prototypes
     $hostItemPrototypes = API::ItemPrototype()->get(array('hostids' => $templateid, 'discoveryids' => $hostDiscoveryRuleids, 'inherited' => false, 'output' => API_OUTPUT_EXTEND));
     if ($hostItemPrototypes) {
         $hostItemPrototypes = CMacrosResolverHelper::resolveItemNames($hostItemPrototypes);
         $prototypeList = array();
         foreach ($hostItemPrototypes as $itemPrototype) {
             $prototypeList[$itemPrototype['itemid']] = $itemPrototype['name_expanded'];
         }
         order_result($prototypeList);
         $listBox = new CListBox('itemsPrototypes', null, 8);
         $listBox->setAttribute('disabled', 'disabled');
         $listBox->addItems($prototypeList);
         $templateList->addRow(_('Item prototypes'), $listBox);
     }
     // Trigger prototypes
     $hostTriggerPrototypes = API::TriggerPrototype()->get(array('hostids' => $templateid, 'discoveryids' => $hostDiscoveryRuleids, 'inherited' => false, 'output' => API_OUTPUT_EXTEND));
     if (!empty($hostTriggerPrototypes)) {
         $prototypeList = array();
         foreach ($hostTriggerPrototypes as $triggerPrototype) {
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:configuration.template.edit.php

示例10: getItemsDataOverview

/**
 * Retrieve overview table object for items.
 *
 * @param array  $hostIds
 * @param string $application name of application to filter
 * @param int    $viewMode
 *
 * @return CTableInfo
 */
function getItemsDataOverview($hostIds, $application, $viewMode)
{
    $sqlFrom = '';
    $sqlWhere = '';
    if ($application !== '') {
        $sqlFrom = 'applications a,items_applications ia,';
        $sqlWhere = ' AND i.itemid=ia.itemid AND a.applicationid=ia.applicationid AND a.name=' . zbx_dbstr($application);
    }
    $dbItems = DBfetchArray(DBselect('SELECT DISTINCT h.hostid,h.name AS hostname,i.itemid,i.key_,i.value_type,i.units,' . 'i.name,t.priority,i.valuemapid,t.value AS tr_value,t.triggerid' . ' FROM hosts h,' . $sqlFrom . 'items i' . ' LEFT JOIN functions f ON f.itemid=i.itemid' . ' LEFT JOIN triggers t ON t.triggerid=f.triggerid AND t.status=' . TRIGGER_STATUS_ENABLED . ' WHERE ' . dbConditionInt('h.hostid', $hostIds) . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . dbConditionInt('i.flags', array(ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED)) . $sqlWhere));
    $dbItems = CMacrosResolverHelper::resolveItemNames($dbItems);
    CArrayHelper::sort($dbItems, array(array('field' => 'name_expanded', 'order' => ZBX_SORT_UP), array('field' => 'itemid', 'order' => ZBX_SORT_UP)));
    // fetch latest values
    $history = Manager::History()->getLast(zbx_toHash($dbItems, 'itemid'), 1, ZBX_HISTORY_PERIOD);
    // fetch data for the host JS menu
    $hosts = API::Host()->get(array('output' => array('name', 'hostid', 'status'), 'monitored_hosts' => true, 'hostids' => $hostIds, 'with_monitored_items' => true, 'preservekeys' => true, 'selectScreens' => $viewMode == STYLE_LEFT ? API_OUTPUT_COUNT : null));
    $items = array();
    foreach ($dbItems as $dbItem) {
        $name = $dbItem['name_expanded'];
        $dbItem['hostname'] = get_node_name_by_elid($dbItem['hostid'], null, NAME_DELIMITER) . $dbItem['hostname'];
        $hostNames[$dbItem['hostid']] = $dbItem['hostname'];
        // a little tricky check for attempt to overwrite active trigger (value=1) with
        // inactive or active trigger with lower priority.
        if (!isset($items[$name][$dbItem['hostname']]) || ($items[$name][$dbItem['hostname']]['tr_value'] == TRIGGER_VALUE_FALSE && $dbItem['tr_value'] == TRIGGER_VALUE_TRUE || ($items[$name][$dbItem['hostname']]['tr_value'] == TRIGGER_VALUE_FALSE || $dbItem['tr_value'] == TRIGGER_VALUE_TRUE) && $dbItem['priority'] > $items[$name][$dbItem['hostname']]['severity'])) {
            $items[$name][$dbItem['hostname']] = array('itemid' => $dbItem['itemid'], 'value_type' => $dbItem['value_type'], 'value' => isset($history[$dbItem['itemid']]) ? $history[$dbItem['itemid']][0]['value'] : null, 'units' => $dbItem['units'], 'name' => $name, 'valuemapid' => $dbItem['valuemapid'], 'severity' => $dbItem['priority'], 'tr_value' => $dbItem['tr_value'], 'triggerid' => $dbItem['triggerid']);
        }
    }
    $table = new CTableInfo(_('No items found.'));
    if (empty($hostNames)) {
        return $table;
    }
    $table->makeVerticalRotation();
    order_result($hostNames);
    if ($viewMode == STYLE_TOP) {
        $header = array(new CCol(_('Items'), 'center'));
        foreach ($hostNames as $hostName) {
            $header[] = new CCol($hostName, 'vertical_rotation');
        }
        $table->setHeader($header, 'vertical_header');
        foreach ($items as $descr => $ithosts) {
            $tableRow = array(nbsp($descr));
            foreach ($hostNames as $hostName) {
                $tableRow = getItemDataOverviewCells($tableRow, $ithosts, $hostName);
            }
            $table->addRow($tableRow);
        }
    } else {
        $scripts = API::Script()->getScriptsByHosts(zbx_objectValues($hosts, 'hostid'));
        $header = array(new CCol(_('Hosts'), 'center'));
        foreach ($items as $descr => $ithosts) {
            $header[] = new CCol($descr, 'vertical_rotation');
        }
        $table->setHeader($header, 'vertical_header');
        foreach ($hostNames as $hostId => $hostName) {
            $host = $hosts[$hostId];
            $name = new CSpan($host['name'], 'link_menu');
            $name->setMenuPopup(getMenuPopupHost($host, $scripts[$hostId]));
            $tableRow = array(new CCol($name));
            foreach ($items as $ithosts) {
                $tableRow = getItemDataOverviewCells($tableRow, $ithosts, $hostName);
            }
            $table->addRow($tableRow);
        }
    }
    return $table;
}
开发者ID:hujingguang,项目名称:work,代码行数:74,代码来源:items.inc.php

示例11: trim

         $expressions[$id]['view'] = trim($value);
     }
 } else {
     $description = get_request('description', '');
     $expressions = get_request('expressions', array());
     $type = get_request('type', 0);
     $priority = get_request('priority', 0);
     $comments = get_request('comments', '');
     $url = get_request('url', '');
     $status = get_request('status', 0);
 }
 $keys = get_request('keys', array());
 $frmTRLog->addRow(_('Description'), new CTextBox('description', $description, 80));
 $itemName = '';
 $dbItems = DBfetchArray(DBselect('SELECT itemid,hostid,name,key_,templateid' . ' FROM items' . ' WHERE itemid=' . zbx_dbstr($itemid)));
 $dbItems = CMacrosResolverHelper::resolveItemNames($dbItems);
 $dbItem = reset($dbItems);
 if ($dbItem['templateid']) {
     $template = get_realhost_by_itemid($dbItem['templateid']);
     $itemName = $template['host'] . NAME_DELIMITER . $dbItem['name_expanded'];
 } else {
     $itemName = $dbItem['name_expanded'];
 }
 $ctb = new CTextBox('item', $itemName, 80);
 $ctb->setAttribute('id', 'item');
 $ctb->setAttribute('disabled', 'disabled');
 $script = "javascript: return PopUp('popup.php?dstfrm=" . $frmTRLog->getName() . "&dstfld1=itemid&dstfld2=item&srctbl=items&srcfld1=itemid&srcfld2=name',800,450);";
 $cbtn = new CSubmit('select_item', _('Select'), $script);
 $frmTRLog->addRow(_('Item'), array($ctb, $cbtn));
 $frmTRLog->addVar('itemid', $itemid);
 $exp_select = new CComboBox('expr_type');
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:tr_logform.php

示例12: getTriggerOverviewCells

/**
 * Creates and returns a trigger status cell for the trigger overview table.
 *
 * @see getTriggersOverview()
 *
 * @param array  $trigger
 * @param string $pageFile		the page where the element is displayed
 * @param string $screenId
 *
 * @return CCol
 */
function getTriggerOverviewCells($trigger, $pageFile, $screenId = null)
{
    $ack = $css = $style = null;
    $desc = $menuPopup = $triggerItems = $acknowledge = array();
    // for how long triggers should blink on status change (set by user in administration->general)
    $config = select_config();
    if ($trigger) {
        $style = 'cursor: pointer; ';
        // problem trigger
        if ($trigger['value'] == TRIGGER_VALUE_TRUE) {
            $css = getSeverityStyle($trigger['priority']);
            $ack = null;
            if ($config['event_ack_enable'] == 1) {
                if ($event = get_last_event_by_triggerid($trigger['triggerid'])) {
                    if ($screenId) {
                        $acknowledge = array('eventid' => $event['eventid'], 'screenid' => $screenId, 'backurl' => $pageFile);
                    } else {
                        $acknowledge = array('eventid' => $event['eventid'], 'backurl' => 'overview.php');
                    }
                    if ($event['acknowledged'] == 1) {
                        $ack = new CImg('images/general/tick.png', 'ack');
                    }
                }
            }
        } else {
            $css = 'normal';
        }
        $dbItems = DBfetchArray(DBselect('SELECT DISTINCT i.itemid,i.hostid,i.name,i.key_,i.value_type' . ' FROM items i,functions f' . ' WHERE f.itemid=i.itemid' . ' AND f.triggerid=' . zbx_dbstr($trigger['triggerid'])));
        $dbItems = CMacrosResolverHelper::resolveItemNames($dbItems);
        foreach ($dbItems as $dbItem) {
            $triggerItems[] = array('name' => $dbItem['name_expanded'], 'params' => array('action' => in_array($dbItem['value_type'], array(ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64)) ? 'showgraph' : 'showlatest', 'itemid' => $dbItem['itemid'], 'period' => 3600));
        }
        // dependency: triggers on which depends this
        $triggerId = empty($trigger['triggerid']) ? 0 : $trigger['triggerid'];
        // trigger dependency DOWN
        $dependencyTable = new CTableInfo();
        $dependencyTable->setAttribute('style', 'width: 200px;');
        $dependencyTable->addRow(bold(_('Depends on') . NAME_DELIMITER));
        $isDependencyFound = false;
        $dbDependencies = DBselect('SELECT td.* FROM trigger_depends td WHERE td.triggerid_down=' . zbx_dbstr($triggerId));
        while ($dbDependency = DBfetch($dbDependencies)) {
            $dependencyTable->addRow(SPACE . '-' . SPACE . CMacrosResolverHelper::resolveTriggerNameById($dbDependency['triggerid_up']));
            $isDependencyFound = true;
        }
        if ($isDependencyFound) {
            $icon = new Cimg('images/general/arrow_down2.png', 'DEP_DOWN');
            $icon->setAttribute('style', 'vertical-align: middle; border: 0px;');
            $icon->setHint($dependencyTable, '', '', false);
            $desc[] = $icon;
        }
        // trigger dependency UP
        $dependencyTable = new CTableInfo();
        $dependencyTable->setAttribute('style', 'width: 200px;');
        $dependencyTable->addRow(bold(_('Dependent') . NAME_DELIMITER));
        $isDependencyFound = false;
        $dbDependencies = DBselect('SELECT td.* FROM trigger_depends td WHERE td.triggerid_up=' . zbx_dbstr($triggerId));
        while ($dbDependency = DBfetch($dbDependencies)) {
            $dependencyTable->addRow(SPACE . '-' . SPACE . CMacrosResolverHelper::resolveTriggerNameById($dbDependency['triggerid_down']));
            $isDependencyFound = true;
        }
        if ($isDependencyFound) {
            $icon = new Cimg('images/general/arrow_up2.png', 'DEP_UP');
            $icon->setAttribute('style', 'vertical-align: middle; border: none;');
            $icon->setHint($dependencyTable, '', '', false);
            $desc[] = $icon;
        }
    }
    $column = is_array($desc) && count($desc) > 0 || $ack ? new CCol(array($desc, $ack), $css . ' hosts') : new CCol(SPACE, $css . ' hosts');
    $column->setAttribute('style', $style);
    if ($trigger && $config['blink_period'] > 0 && time() - $trigger['lastchange'] < $config['blink_period']) {
        $column->addClass('blink');
        $column->setAttribute('data-toggle-class', $css);
    }
    if ($trigger) {
        $column->setMenuPopup(getMenuPopupTrigger($trigger, $triggerItems, $acknowledge));
    }
    return $column;
}
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:89,代码来源:triggers.inc.php

示例13: getScreen

 /**
  * Get particular screen object.
  *
  * @static
  *
  * @param array		$options
  * @param int		$options['resourcetype']
  * @param int		$options['screenitemid']
  * @param int		$options['hostid']
  * @param array		$options['screen']
  * @param int		$options['screenid']
  *
  * @return CScreenBase
  */
 public static function getScreen(array $options = array())
 {
     // get resourcetype from screenitem
     if (empty($options['screenitem']) && !empty($options['screenitemid'])) {
         if (!empty($options['hostid'])) {
             $options['screenitem'] = API::TemplateScreenItem()->get(array('screenitemids' => $options['screenitemid'], 'hostids' => $options['hostid'], 'output' => API_OUTPUT_EXTEND));
         } else {
             $options['screenitem'] = API::ScreenItem()->get(array('screenitemids' => $options['screenitemid'], 'output' => API_OUTPUT_EXTEND));
         }
         $options['screenitem'] = reset($options['screenitem']);
     }
     if (zbx_empty($options['resourcetype']) && !zbx_empty($options['screenitem']['resourcetype'])) {
         $options['resourcetype'] = $options['screenitem']['resourcetype'];
     }
     if (zbx_empty($options['resourcetype'])) {
         return null;
     }
     // get screen
     switch ($options['resourcetype']) {
         case SCREEN_RESOURCE_GRAPH:
             return new CScreenGraph($options);
         case SCREEN_RESOURCE_SIMPLE_GRAPH:
             return new CScreenSimpleGraph($options);
         case SCREEN_RESOURCE_MAP:
             return new CScreenMap($options);
         case SCREEN_RESOURCE_PLAIN_TEXT:
             return new CScreenPlainText($options);
         case SCREEN_RESOURCE_HOSTS_INFO:
             return new CScreenHostsInfo($options);
         case SCREEN_RESOURCE_TRIGGERS_INFO:
             return new CScreenTriggersInfo($options);
         case SCREEN_RESOURCE_SERVER_INFO:
             return new CScreenServerInfo($options);
         case SCREEN_RESOURCE_CLOCK:
             return new CScreenClock($options);
         case SCREEN_RESOURCE_SCREEN:
             return new CScreenScreen($options);
         case SCREEN_RESOURCE_TRIGGERS_OVERVIEW:
             return new CScreenTriggersOverview($options);
         case SCREEN_RESOURCE_DATA_OVERVIEW:
             return new CScreenDataOverview($options);
         case SCREEN_RESOURCE_URL:
             $options = self::appendTemplatedScreenOption($options);
             return new CScreenUrl($options);
         case SCREEN_RESOURCE_ACTIONS:
             return new CScreenActions($options);
         case SCREEN_RESOURCE_EVENTS:
             return new CScreenEvents($options);
         case SCREEN_RESOURCE_HOSTGROUP_TRIGGERS:
             return new CScreenHostgroupTriggers($options);
         case SCREEN_RESOURCE_SYSTEM_STATUS:
             return new CScreenSystemStatus($options);
         case SCREEN_RESOURCE_HOST_TRIGGERS:
             return new CScreenHostTriggers($options);
         case SCREEN_RESOURCE_HISTORY:
             // TODO: pass the items from the outside instead of retrieving them by ids
             if (isset($options['itemids'])) {
                 $items = API::Item()->get(array('itemids' => $options['itemids'], 'webitems' => true, 'selectHosts' => array('name'), 'output' => array('itemid', 'hostid', 'name', 'key_', 'value_type', 'valuemapid'), 'preservekeys' => true));
                 $items = CMacrosResolverHelper::resolveItemNames($items);
                 $options['items'] = $items;
                 unset($options['itemids']);
             }
             return new CScreenHistory($options);
         case SCREEN_RESOURCE_CHART:
             return new CScreenChart($options);
         case SCREEN_RESOURCE_LLD_GRAPH:
             $options = self::appendTemplatedScreenOption($options);
             return new CScreenLldGraph($options);
         case SCREEN_RESOURCE_LLD_SIMPLE_GRAPH:
             $options = self::appendTemplatedScreenOption($options);
             return new CScreenLldSimpleGraph($options);
         default:
             return null;
     }
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:89,代码来源:CScreenBuilder.php

示例14: dirname

**/
require_once dirname(__FILE__) . '/include/config.inc.php';
require_once dirname(__FILE__) . '/include/triggers.inc.php';
require_once dirname(__FILE__) . '/include/js.inc.php';
$dstfrm = get_request('dstfrm', 0);
$page['title'] = _('Graph item');
$page['file'] = 'popup_bitem.php';
define('ZBX_PAGE_NO_MENU', 1);
require_once dirname(__FILE__) . '/include/page_header.php';
//		VAR			TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION
$fields = array('dstfrm' => array(T_ZBX_STR, O_MAND, P_SYS, NOT_EMPTY, null), 'config' => array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1,2,3'), null), 'gid' => array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0, 65535), null), 'list_name' => array(T_ZBX_STR, O_OPT, P_SYS, NOT_EMPTY, 'isset({save})&&isset({gid})'), 'caption' => array(T_ZBX_STR, O_OPT, null, null, null), 'itemid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID . '({}!=0)', 'isset({save})', _('Parameter')), 'color' => array(T_ZBX_CLR, O_OPT, null, null, 'isset({save})', _('Colour')), 'calc_fnc' => array(T_ZBX_INT, O_OPT, null, IN('0,1,2,4,7,9'), 'isset({save})'), 'axisside' => array(T_ZBX_INT, O_OPT, null, IN(GRAPH_YAXIS_SIDE_LEFT . ',' . GRAPH_YAXIS_SIDE_RIGHT), null), 'add' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'save' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'form' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form_refresh' => array(T_ZBX_STR, O_OPT, null, null, null), 'host' => array(T_ZBX_STR, O_OPT, null, null, null), 'name' => array(T_ZBX_STR, O_OPT, null, null, null));
check_fields($fields);
$_REQUEST['caption'] = get_request('caption', '');
$_REQUEST['axisside'] = get_request('axisside', GRAPH_YAXIS_SIDE_LEFT);
if (zbx_empty($_REQUEST['caption']) && isset($_REQUEST['itemid']) && $_REQUEST['itemid'] > 0) {
    $items = CMacrosResolverHelper::resolveItemNames(array(get_item_by_itemid($_REQUEST['itemid'])));
    $item = reset($items);
    $_REQUEST['caption'] = $item['name_expanded'];
}
insert_js_function('add_bitem');
insert_js_function('update_bitem');
if (isset($_REQUEST['save']) && !isset($_REQUEST['gid'])) {
    insert_js("add_bitem(" . zbx_jsvalue($_REQUEST['dstfrm']) . "," . zbx_jsvalue($_REQUEST['caption']) . ",'" . $_REQUEST['itemid'] . "','" . $_REQUEST['color'] . "'," . $_REQUEST['calc_fnc'] . "," . $_REQUEST['axisside'] . ");\n");
}
if (isset($_REQUEST['save']) && isset($_REQUEST['gid'])) {
    insert_js("update_bitem(" . zbx_jsvalue($_REQUEST['dstfrm']) . "," . zbx_jsvalue($_REQUEST['list_name']) . ",'" . $_REQUEST['gid'] . "'," . zbx_jsvalue($_REQUEST['caption']) . ",'" . $_REQUEST['itemid'] . "','" . $_REQUEST['color'] . "'," . $_REQUEST['calc_fnc'] . "," . $_REQUEST['axisside'] . ");\n");
} else {
    echo SBR;
    $frmGItem = new CFormTable(_('New item for the graph'));
    $frmGItem->setName('graph_item');
    $frmGItem->setHelp('web.graph.item.php');
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:popup_bitem.php

示例15: getItemsDataOverview

/**
 * Retrieve overview table object for items.
 *
 * @param array  		$hostIds
 * @param array|null	$applicationIds		IDs of applications to filter items by
 * @param int    		$viewMode
 *
 * @return CTableInfo
 */
function getItemsDataOverview($hostIds, array $applicationIds = null, $viewMode)
{
    $sqlFrom = '';
    $sqlWhere = '';
    if ($applicationIds !== null) {
        $sqlFrom = 'items_applications ia,';
        $sqlWhere = ' AND i.itemid=ia.itemid AND ' . dbConditionInt('ia.applicationid', $applicationIds);
    }
    $dbItems = DBfetchArray(DBselect('SELECT DISTINCT h.hostid,h.name AS hostname,i.itemid,i.key_,i.value_type,i.units,' . 'i.name,t.priority,i.valuemapid,t.value AS tr_value,t.triggerid' . ' FROM hosts h,' . $sqlFrom . 'items i' . ' LEFT JOIN functions f ON f.itemid=i.itemid' . ' LEFT JOIN triggers t ON t.triggerid=f.triggerid AND t.status=' . TRIGGER_STATUS_ENABLED . ' WHERE ' . dbConditionInt('h.hostid', $hostIds) . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . dbConditionInt('i.flags', [ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED]) . $sqlWhere));
    $dbItems = CMacrosResolverHelper::resolveItemNames($dbItems);
    CArrayHelper::sort($dbItems, [['field' => 'name_expanded', 'order' => ZBX_SORT_UP], ['field' => 'itemid', 'order' => ZBX_SORT_UP]]);
    // fetch latest values
    $history = Manager::History()->getLast(zbx_toHash($dbItems, 'itemid'), 1, ZBX_HISTORY_PERIOD);
    // fetch data for the host JS menu
    $hosts = API::Host()->get(['output' => ['name', 'hostid', 'status'], 'monitored_hosts' => true, 'hostids' => $hostIds, 'with_monitored_items' => true, 'preservekeys' => true, 'selectGraphs' => API_OUTPUT_COUNT, 'selectScreens' => $viewMode == STYLE_LEFT ? API_OUTPUT_COUNT : null]);
    $items = [];
    $item_counter = [];
    $host_items = [];
    foreach ($dbItems as $dbItem) {
        $item_name = $dbItem['name_expanded'];
        $host_name = $dbItem['hostname'];
        $hostNames[$dbItem['hostid']] = $host_name;
        if (!array_key_exists($host_name, $item_counter)) {
            $item_counter[$host_name] = [];
        }
        if (!array_key_exists($item_name, $item_counter[$host_name])) {
            $item_counter[$host_name][$item_name] = 0;
        }
        if (!array_key_exists($item_name, $host_items) || !array_key_exists($host_name, $host_items[$item_name])) {
            $host_items[$item_name][$host_name] = [];
        }
        // a little tricky check for attempt to overwrite active trigger (value=1) with
        // inactive or active trigger with lower priority.
        if (!array_key_exists($dbItem['itemid'], $host_items[$item_name][$host_name]) || ($host_items[$item_name][$host_name][$dbItem['itemid']]['tr_value'] == TRIGGER_VALUE_FALSE && $dbItem['tr_value'] == TRIGGER_VALUE_TRUE || ($host_items[$item_name][$host_name][$dbItem['itemid']]['tr_value'] == TRIGGER_VALUE_FALSE || $dbItem['tr_value'] == TRIGGER_VALUE_TRUE) && $dbItem['priority'] > $host_items[$item_name][$host_name][$dbItem['itemid']]['severity'])) {
            if (array_key_exists($dbItem['itemid'], $host_items[$item_name][$host_name])) {
                $item_place = $host_items[$item_name][$host_name][$dbItem['itemid']]['item_place'];
            } else {
                $item_place = $item_counter[$host_name][$item_name];
                $item_counter[$host_name][$item_name]++;
            }
            $items[$item_name][$item_place][$host_name] = ['itemid' => $dbItem['itemid'], 'value_type' => $dbItem['value_type'], 'value' => isset($history[$dbItem['itemid']]) ? $history[$dbItem['itemid']][0]['value'] : null, 'units' => $dbItem['units'], 'valuemapid' => $dbItem['valuemapid'], 'severity' => $dbItem['priority'], 'tr_value' => $dbItem['tr_value'], 'triggerid' => $dbItem['triggerid'], 'item_place' => $item_place];
            $host_items[$item_name][$host_name][$dbItem['itemid']] = $items[$item_name][$item_place][$host_name];
        }
    }
    $table = new CTableInfo();
    if (empty($hostNames)) {
        return $table;
    }
    $table->makeVerticalRotation();
    order_result($hostNames);
    if ($viewMode == STYLE_TOP) {
        $header = [_('Items')];
        foreach ($hostNames as $hostName) {
            $header[] = (new CColHeader($hostName))->addClass('vertical_rotation');
        }
        $table->setHeader($header);
        foreach ($items as $item_name => $item_data) {
            foreach ($item_data as $ithosts) {
                $tableRow = [nbsp($item_name)];
                foreach ($hostNames as $hostName) {
                    $tableRow = getItemDataOverviewCells($tableRow, $ithosts, $hostName);
                }
                $table->addRow($tableRow);
            }
        }
    } else {
        $scripts = API::Script()->getScriptsByHosts(zbx_objectValues($hosts, 'hostid'));
        $header = [_('Hosts')];
        foreach ($items as $item_name => $item_data) {
            foreach ($item_data as $ithosts) {
                $header[] = (new CColHeader($item_name))->addClass('vertical_rotation');
            }
        }
        $table->setHeader($header);
        foreach ($hostNames as $hostId => $hostName) {
            $host = $hosts[$hostId];
            $name = (new CSpan($host['name']))->addClass(ZBX_STYLE_LINK_ACTION)->setMenuPopup(CMenuPopupHelper::getHost($host, $scripts[$hostId]));
            $tableRow = [(new CCol($name))->addClass(ZBX_STYLE_NOWRAP)];
            foreach ($items as $item_data) {
                foreach ($item_data as $ithosts) {
                    $tableRow = getItemDataOverviewCells($tableRow, $ithosts, $hostName);
                }
            }
            $table->addRow($tableRow);
        }
    }
    return $table;
}
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:97,代码来源:items.inc.php


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