本文整理汇总了PHP中get_item_by_itemid函数的典型用法代码示例。如果您正苦于以下问题:PHP get_item_by_itemid函数的具体用法?PHP get_item_by_itemid怎么用?PHP get_item_by_itemid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_item_by_itemid函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: insert_graph_form
//.........这里部分代码省略.........
$frmGraph->addRow(S_SHOW_TRIGGERS, new CCheckBox('showtriggers', $showtriggers, null, 1));
if ($graphtype == GRAPH_TYPE_NORMAL) {
$percent_left = sprintf("%2.2f", $percent_left);
$percent_right = sprintf("%2.2f", $percent_right);
$pr_left_input = new CTextBox('percent_left', $percent_left, '5');
$pr_left_chkbx = new CCheckBox('visible[percent_left]', 1, "javascript: ShowHide('percent_left');", 1);
if ($percent_left == 0) {
$pr_left_input->addOption('style', 'display: none;');
$pr_left_chkbx->SetChecked(0);
}
$pr_right_input = new CTextBox('percent_right', $percent_right, '5');
$pr_right_chkbx = new CCheckBox('visible[percent_right]', 1, "javascript: ShowHide('percent_right');", 1);
if ($percent_right == 0) {
$pr_right_input->addOption('style', 'display: none;');
$pr_right_chkbx->SetChecked(0);
}
$frmGraph->addRow(S_PERCENTILE_LINE . ' (' . S_LEFT . ')', array($pr_left_chkbx, $pr_left_input));
$frmGraph->addRow(S_PERCENTILE_LINE . ' (' . S_RIGHT . ')', array($pr_right_chkbx, $pr_right_input));
}
$yaxis_min = array();
$cmbYType = new CComboBox('ymin_type', $ymin_type, 'javascript: submit();');
$cmbYType->addItem(GRAPH_YAXIS_TYPE_CALCULATED, S_CALCULATED);
$cmbYType->addItem(GRAPH_YAXIS_TYPE_FIXED, S_FIXED);
$cmbYType->addItem(GRAPH_YAXIS_TYPE_ITEM_VALUE, S_ITEM);
$yaxis_min[] = $cmbYType;
if ($ymin_type == GRAPH_YAXIS_TYPE_FIXED) {
$yaxis_min[] = new CTextBox("yaxismin", $yaxismin, 9);
} else {
if ($ymin_type == GRAPH_YAXIS_TYPE_ITEM_VALUE) {
$frmGraph->addVar('yaxismin', $yaxismin);
$ymin_name = '';
if ($ymin_itemid > 0) {
$min_host = get_host_by_itemid($ymin_itemid);
$min_item = get_item_by_itemid($ymin_itemid);
$ymin_name = $min_host['host'] . ':' . item_description($min_item);
}
$yaxis_min[] = new CTextBox("ymin_name", $ymin_name, 80, 'yes');
$yaxis_min[] = new CButton('yaxis_min', S_SELECT, 'javascript: ' . "return PopUp('popup.php?dstfrm=" . $frmGraph->getName() . "&dstfld1=ymin_itemid" . "&dstfld2=ymin_name" . "&srctbl=items" . "&srcfld1=itemid" . "&srcfld2=description',0,0,'zbx_popup_item');");
} else {
$frmGraph->addVar('yaxismin', $yaxismin);
}
}
$frmGraph->addRow(S_YAXIS_MIN_VALUE, $yaxis_min);
$yaxis_max = array();
$cmbYType = new CComboBox("ymax_type", $ymax_type, "submit()");
$cmbYType->addItem(GRAPH_YAXIS_TYPE_CALCULATED, S_CALCULATED);
$cmbYType->addItem(GRAPH_YAXIS_TYPE_FIXED, S_FIXED);
$cmbYType->addItem(GRAPH_YAXIS_TYPE_ITEM_VALUE, S_ITEM);
$yaxis_max[] = $cmbYType;
if ($ymax_type == GRAPH_YAXIS_TYPE_FIXED) {
$yaxis_max[] = new CTextBox("yaxismax", $yaxismax, 9);
} else {
if ($ymax_type == GRAPH_YAXIS_TYPE_ITEM_VALUE) {
$frmGraph->addVar('yaxismax', $yaxismax);
$ymax_name = '';
if ($ymax_itemid > 0) {
$max_host = get_host_by_itemid($ymax_itemid);
$max_item = get_item_by_itemid($ymax_itemid);
$ymax_name = $max_host['host'] . ':' . item_description($max_item);
}
$yaxis_max[] = new CTextBox("ymax_name", $ymax_name, 80, 'yes');
$yaxis_max[] = new CButton('yaxis_max', S_SELECT, 'javascript: ' . "return PopUp('popup.php?dstfrm=" . $frmGraph->getName() . "&dstfld1=ymax_itemid" . "&dstfld2=ymax_name" . "&srctbl=items" . "&srcfld1=itemid" . "&srcfld2=description',0,0,'zbx_popup_item');");
} else {
$frmGraph->addVar('yaxismax', $yaxismax);
}
}
开发者ID:rennhak,项目名称:zabbix,代码行数:67,代码来源:forms.inc.php
示例4: getSameGraphItemsForHost
/**
* Search items by same key in destination host.
*
* @param array $gitems
* @param string $destinationHostId
* @param bool $error if false error won't be thrown when item does not exist
* @param array $flags
*
* @return array|bool
*/
function getSameGraphItemsForHost($gitems, $destinationHostId, $error = true, array $flags = array())
{
$result = array();
$flagsSql = $flags ? ' AND ' . dbConditionInt('dest.flags', $flags) : '';
foreach ($gitems as $gitem) {
$dbItem = DBfetch(DBselect('SELECT dest.itemid,src.key_' . ' FROM items dest,items src' . ' WHERE dest.key_=src.key_' . ' AND dest.hostid=' . zbx_dbstr($destinationHostId) . ' AND src.itemid=' . zbx_dbstr($gitem['itemid']) . $flagsSql));
if ($dbItem) {
$gitem['itemid'] = $dbItem['itemid'];
$gitem['key_'] = $dbItem['key_'];
} elseif ($error) {
$item = get_item_by_itemid($gitem['itemid']);
$host = get_host_by_hostid($destinationHostId);
error(_s('Missing key "%1$s" for host "%2$s".', $item['key_'], $host['host']));
return false;
} else {
continue;
}
$result[] = $gitem;
}
return $result;
}
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:graphs.inc.php
示例5: getById
/**
* Gets all item data from DB by itemid
*
* {@source}
* @access public
* @static
* @since 1.8
* @version 1
*
* @static
* @param int $item_data
* @param int $item_data['itemid']
* @return array|boolean item data || false if error
*/
public static function getById($item_data)
{
$item = get_item_by_itemid($item_data['itemid']);
$result = $item ? true : false;
if ($result) {
return $item;
} else {
self::$error = array('error' => ZBX_API_ERROR_NO_HOST, 'data' => 'Item with id: ' . $itemid . ' doesn\'t exists.');
return false;
}
}
开发者ID:phedders,项目名称:zabbix,代码行数:25,代码来源:class.citem.php
示例6: selectData
protected function selectData()
{
$this->data = array();
$now = time(null);
if (isset($this->stime)) {
$this->from_time = $this->stime;
$this->to_time = $this->stime + $this->period;
} else {
$this->to_time = $now - SEC_PER_HOUR * $this->from;
$this->from_time = $this->to_time - $this->period;
}
$strvaluelength = 0;
// we need to know how long in px will be our legend
for ($i = 0; $i < $this->num; $i++) {
$real_item = get_item_by_itemid($this->items[$i]['itemid']);
$type = $this->items[$i]['calc_type'];
$from_time = $this->from_time;
$to_time = $this->to_time;
$sql_arr = array();
if (ZBX_HISTORY_DATA_UPKEEP > -1) {
$real_item['history'] = ZBX_HISTORY_DATA_UPKEEP;
}
if ($real_item['history'] * SEC_PER_DAY > time() - ($from_time + $this->period / 2) && $this->period / $this->sizeX <= ZBX_MAX_TREND_DIFF / ZBX_GRAPH_MAX_SKIP_CELL) {
// is reasonable to take data from history?
$this->dataFrom = 'history';
array_push($sql_arr, 'SELECT h.itemid,' . 'AVG(h.value) AS avg,MIN(h.value) AS min,' . 'MAX(h.value) AS max,MAX(h.clock) AS clock,' . 'MAX(i.lastvalue) AS lst' . ' FROM history h' . ' LEFT JOIN items i ON h.itemid=i.itemid' . ' WHERE h.itemid=' . zbx_dbstr($this->items[$i]['itemid']) . ' AND h.clock>=' . zbx_dbstr($from_time) . ' AND h.clock<=' . zbx_dbstr($to_time) . ' GROUP BY h.itemid', 'SELECT hu.itemid,' . 'AVG(hu.value) AS avg,MIN(hu.value) AS min,' . 'MAX(hu.value) AS max,MAX(hu.clock) AS clock,' . 'MAX(i.lastvalue) AS lst' . ' FROM history_uint hu' . ' LEFT JOIN items i ON hu.itemid=i.itemid' . ' WHERE hu.itemid=' . zbx_dbstr($this->items[$i]['itemid']) . ' AND hu.clock>=' . zbx_dbstr($from_time) . ' AND hu.clock<=' . zbx_dbstr($to_time) . ' GROUP BY hu.itemid');
} else {
$this->dataFrom = 'trends';
array_push($sql_arr, 'SELECT t.itemid,' . 'AVG(t.value_avg) AS avg,MIN(t.value_min) AS min,' . 'MAX(t.value_max) AS max,MAX(t.clock) AS clock,' . 'MAX(i.lastvalue) AS lst' . ' FROM trends t' . ' LEFT JOIN items i ON t.itemid=i.itemid' . ' WHERE t.itemid=' . zbx_dbstr($this->items[$i]['itemid']) . ' AND t.clock>=' . zbx_dbstr($from_time) . ' AND t.clock<=' . zbx_dbstr($to_time) . ' GROUP BY t.itemid', 'SELECT t.itemid,' . 'AVG(t.value_avg) AS avg,MIN(t.value_min) AS min,' . 'MAX(t.value_max) AS max,MAX(t.clock) AS clock,' . 'MAX(i.lastvalue) AS lst' . ' FROM trends_uint t' . ' LEFT JOIN items i ON t.itemid=i.itemid' . ' WHERE t.itemid=' . zbx_dbstr($this->items[$i]['itemid']) . ' AND t.clock>=' . zbx_dbstr($from_time) . ' AND t.clock<=' . zbx_dbstr($to_time) . ' GROUP BY t.itemid');
}
$curr_data =& $this->data[$this->items[$i]['itemid']][$type];
$curr_data->min = null;
$curr_data->max = null;
$curr_data->avg = null;
$curr_data->clock = null;
foreach ($sql_arr as $sql) {
$result = DBselect($sql);
while ($row = DBfetch($result)) {
$curr_data->min = $row['min'];
$curr_data->max = $row['max'];
$curr_data->avg = $row['avg'];
$curr_data->lst = $row['lst'];
$curr_data->clock = $row['clock'];
$curr_data->shift_min = 0;
$curr_data->shift_max = 0;
$curr_data->shift_avg = 0;
}
unset($row);
}
switch ($this->items[$i]['calc_fnc']) {
case CALC_FNC_MIN:
$item_value = abs($curr_data->min);
break;
case CALC_FNC_MAX:
$item_value = abs($curr_data->max);
break;
case CALC_FNC_LST:
$item_value = abs($curr_data->lst);
break;
case CALC_FNC_AVG:
default:
$item_value = abs($curr_data->avg);
}
if ($type == GRAPH_ITEM_SUM) {
$this->background = $i;
$graph_sum = $item_value;
}
$this->sum += $item_value;
$strvaluelength = max($strvaluelength, zbx_strlen(convert_units($item_value, $this->items[$i]['unit'])));
}
if (isset($graph_sum)) {
$this->sum = $graph_sum;
}
$this->shiftlegendright += $strvaluelength * 7;
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:75,代码来源:class.cpie.php
示例7: calculateMaxY
protected function calculateMaxY($side)
{
if ($this->ymax_type == GRAPH_YAXIS_TYPE_FIXED) {
return $this->yaxismax;
} else {
if ($this->ymax_type == GRAPH_YAXIS_TYPE_ITEM_VALUE) {
$item = get_item_by_itemid($this->ymax_itemid);
if ($item && isset($item['lastvalue']) && !is_null($item['lastvalue'])) {
return $item['lastvalue'];
}
}
}
$maxY = null;
for ($i = 0; $i < $this->num; $i++) {
if ($this->items[$i]['axisside'] != $side) {
continue;
}
foreach (array(GRAPH_ITEM_SIMPLE, GRAPH_ITEM_AGGREGATED) as $type) {
if (!isset($this->data[$this->items[$i]['itemid']][$type])) {
continue;
}
$data =& $this->data[$this->items[$i]['itemid']][$type];
if (!isset($data)) {
continue;
}
if ($type == GRAPH_ITEM_AGGREGATED) {
$calc_fnc = CALC_FNC_ALL;
} else {
$calc_fnc = $this->items[$i]['calc_fnc'];
}
switch ($calc_fnc) {
case CALC_FNC_ALL:
/* use max */
/* use max */
case CALC_FNC_MAX:
$val = $data['max'];
$shift_val = $data['shift_max'];
break;
case CALC_FNC_MIN:
$val = $data['min'];
$shift_val = $data['shift_min'];
break;
case CALC_FNC_AVG:
default:
$val = $data['avg'];
$shift_val = $data['shift_avg'];
}
if (!isset($val)) {
continue;
}
for ($ci = 0; $ci < min(count($val), count($shift_val)); $ci++) {
if ($data['count'][$ci] == 0) {
continue;
}
$val[$ci] = bcadd($shift_val[$ci], $val[$ci]);
}
if (!isset($maxY)) {
if (isset($val) && count($val) > 0) {
$maxY = max($val);
}
} else {
$maxY = max($maxY, max($val));
}
}
}
return $maxY;
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:67,代码来源:class.cchart.php
示例8: DBstart
}
}
DBstart();
$go_result = copyItemsToHosts($_REQUEST['group_itemid'], $hosts_ids);
$go_result = DBend($go_result);
show_messages($go_result, _('Items copied'), _('Cannot copy items'));
$_REQUEST['go'] = 'none2';
} else {
show_error_message(_('No target selected.'));
}
} elseif ($_REQUEST['go'] == 'clean_history' && isset($_REQUEST['group_itemid'])) {
DBstart();
$go_result = delete_history_by_itemid($_REQUEST['group_itemid']);
DBexecute('UPDATE items SET lastvalue=null,lastclock=null,prevvalue=null WHERE ' . dbConditionInt('itemid', $_REQUEST['group_itemid']));
foreach ($_REQUEST['group_itemid'] as $id) {
if (!($item = get_item_by_itemid($id))) {
continue;
}
$host = get_host_by_hostid($item['hostid']);
add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ITEM, _('Item') . ' [' . $item['key_'] . '] [' . $id . '] ' . _('Host') . ' [' . $host['host'] . '] ' . _('History cleared'));
}
$go_result = DBend($go_result);
show_messages($go_result, _('History cleared'), $go_result);
} elseif ($_REQUEST['go'] == 'delete' && isset($_REQUEST['group_itemid'])) {
DBstart();
$group_itemid = $_REQUEST['group_itemid'];
$itemsToDelete = API::Item()->get(array('output' => array('key_', 'itemid'), 'selectHosts' => array('name'), 'itemids' => $group_itemid, 'preservekeys' => true));
$go_result = API::Item()->delete($group_itemid);
if ($go_result) {
foreach ($itemsToDelete as $item) {
$host = reset($item['hosts']);
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:31,代码来源:items.php
示例9: construct_expression
function construct_expression($itemid, $expressions)
{
$complite_expr = '';
$item = get_item_by_itemid($itemid);
$host = get_host_by_itemid($itemid);
$prefix = $host['host'] . ':' . $item['key_'] . '.';
if (empty($expressions)) {
error(_('Expression cannot be empty'));
return false;
}
$ZBX_PREG_EXPESSION_FUNC_FORMAT = '^([' . ZBX_PREG_PRINT . ']*)([&|]{1})[(]*(([a-zA-Z_.\\$]{6,7})(\\(([' . ZBX_PREG_PRINT . ']+?){0,1}\\)))([' . ZBX_PREG_PRINT . ']*)$';
$functions = array('regexp' => 1, 'iregexp' => 1);
$expr_array = array();
$cexpor = 0;
$startpos = -1;
foreach ($expressions as $expression) {
$expression['value'] = preg_replace('/\\s+(AND){1,2}\\s+/U', '&', $expression['value']);
$expression['value'] = preg_replace('/\\s+(OR){1,2}\\s+/U', '|', $expression['value']);
if ($expression['type'] == REGEXP_INCLUDE) {
if (!empty($complite_expr)) {
$complite_expr .= ' | ';
}
if ($cexpor == 0) {
$startpos = zbx_strlen($complite_expr);
}
$cexpor++;
$eq_global = '#0';
} else {
if ($cexpor > 1 & $startpos >= 0) {
$head = substr($complite_expr, 0, $startpos);
$tail = substr($complite_expr, $startpos);
$complite_expr = $head . '(' . $tail . ')';
}
$cexpor = 0;
$eq_global = '=0';
if (!empty($complite_expr)) {
$complite_expr .= ' & ';
}
}
$expr = '&' . $expression['value'];
$expr = preg_replace('/\\s+(\\&|\\|){1,2}\\s+/U', '$1', $expr);
$expr_array = array();
$sub_expr_count = 0;
$sub_expr = '';
$multi = preg_match('/.+(&|\\|).+/', $expr);
while (preg_match('/' . $ZBX_PREG_EXPESSION_FUNC_FORMAT . '/i', $expr, $arr)) {
$arr[4] = zbx_strtolower($arr[4]);
if (!isset($functions[$arr[4]])) {
error(_('Incorrect function is used') . '. [' . $expression['value'] . ']');
return false;
}
$expr_array[$sub_expr_count]['eq'] = trim($arr[2]);
$expr_array[$sub_expr_count]['regexp'] = zbx_strtolower($arr[4]) . $arr[5];
$sub_expr_count++;
$expr = $arr[1];
}
if (empty($expr_array)) {
error(_('Incorrect trigger expression') . '. [' . $expression['value'] . ']');
return false;
}
$expr_array[$sub_expr_count - 1]['eq'] = '';
$sub_eq = '';
if ($multi > 0) {
$sub_eq = $eq_global;
}
foreach ($expr_array as $id => $expr) {
if ($multi > 0) {
$sub_expr = $expr['eq'] . '({' . $prefix . $expr['regexp'] . '})' . $sub_eq . $sub_expr;
} else {
$sub_expr = $expr['eq'] . '{' . $prefix . $expr['regexp'] . '}' . $sub_eq . $sub_expr;
}
}
if ($multi > 0) {
$complite_expr .= '(' . $sub_expr . ')';
} else {
$complite_expr .= '((' . $sub_expr . ')' . $eq_global . ')';
}
}
if ($cexpor > 1 & $startpos >= 0) {
$head = substr($complite_expr, 0, $startpos);
$tail = substr($complite_expr, $startpos);
$complite_expr = $head . '(' . $tail . ')';
}
return $complite_expr;
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:85,代码来源:triggers.inc.php
示例10: CTimePeriodValidator
* Actions
*/
$result = false;
if (isset($_REQUEST['add_delay_flex']) && isset($_REQUEST['new_delay_flex'])) {
$timePeriodValidator = new CTimePeriodValidator(array('allowMultiple' => false));
$_REQUEST['delay_flex'] = getRequest('delay_flex', array());
if ($timePeriodValidator->validate($_REQUEST['new_delay_flex']['period'])) {
array_push($_REQUEST['delay_flex'], $_REQUEST['new_delay_flex']);
unset($_REQUEST['new_delay_flex']);
} else {
error($timePeriodValidator->getError());
show_messages(false, null, _('Invalid time period'));
}
} elseif (isset($_REQUEST['delete']) && isset($_REQUEST['itemid'])) {
$result = false;
if ($item = get_item_by_itemid($_REQUEST['itemid'])) {
$result = API::Item()->delete(array(getRequest('itemid')));
}
if ($result) {
uncheckTableRows(getRequest('hostid'));
}
unset($_REQUEST['itemid'], $_REQUEST['form']);
show_messages($result, _('Item deleted'), _('Cannot delete item'));
} elseif (isset($_REQUEST['clone']) && isset($_REQUEST['itemid'])) {
unset($_REQUEST['itemid']);
$_REQUEST['form'] = 'clone';
} elseif (hasRequest('add') || hasRequest('update')) {
$delay_flex = getRequest('delay_flex', array());
$db_delay_flex = '';
foreach ($delay_flex as $value) {
$db_delay_flex .= $value['delay'] . '/' . $value['period'] . ';';
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:31,代码来源:items.php
示例11: get_same_graphitems_for_host
/**
* Replace items for specified host.
*
* @param $gitems
* @param $dest_hostid
* @param bool $error if false error won't be thrown when item does not exist
* @return array|bool
*/
function get_same_graphitems_for_host($gitems, $dest_hostid, $error = true)
{
$result = array();
foreach ($gitems as $gitem) {
$dbItem = DBfetch(DBselect('SELECT dest.itemid,src.key_' . ' FROM items dest,items src' . ' WHERE dest.key_=src.key_' . ' AND dest.hostid=' . zbx_dbstr($dest_hostid) . ' AND src.itemid=' . zbx_dbstr($gitem['itemid'])));
if ($dbItem) {
$gitem['itemid'] = $dbItem['itemid'];
$gitem['key_'] = $dbItem['key_'];
} elseif ($error) {
$item = get_item_by_itemid($gitem['itemid']);
$host = get_host_by_hostid($dest_hostid);
error(_s('Missing key "%1$s" for host "%2$s".', $item['key_'], $host['host']));
return false;
} else {
continue;
}
$result[] = $gitem;
}
return $result;
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:28,代码来源:graphs.inc.php
示例12: selectData
protected function selectData()
{
$this->data = array();
$now = time(NULL);
if (isset($this->stime)) {
$this->from_time = $this->stime;
$this->to_time = $this->stime + $this->period;
} else {
$this->to_time = $now - 3600 * $this->from;
$this->from_time = $this->to_time - $this->period;
}
$p = $this->to_time - $this->from_time;
// graph size in time
$z = $p - $this->from_time % $p;
//<strong></strong>
$x = $this->sizeX;
// graph size in px
$strvaluelength = 0;
// we need to know how long in px will be our legend
for ($i = 0; $i < $this->num; $i++) {
$real_item = get_item_by_itemid($this->items[$i]['itemid']);
$type = $this->items[$i]['calc_type'];
$from_time = $this->from_time;
$to_time = $this->to_time;
$sql_arr = array();
if ($real_item['history'] * 86400 > time() - ($from_time + $this->period / 2) && $this->period / $this->sizeX <= ZBX_MAX_TREND_DIFF / ZBX_GRAPH_MAX_SKIP_CELL) {
array_push($sql_arr, 'SELECT h.itemid, ' . ' avg(h.value) AS avg,min(h.value) AS min, ' . ' max(h.value) AS max,max(h.clock) AS clock, max(i.lastvalue) as lst ' . ' FROM history h ' . ' LEFT JOIN items i ON h.itemid = i.itemid' . ' WHERE h.itemid=' . $this->items[$i]['itemid'] . ' AND h.clock>=' . $from_time . ' AND h.clock<=' . $to_time . ' GROUP BY h.itemid', 'SELECT hu.itemid, ' . ' avg(hu.value) AS avg,min(hu.value) AS min,' . ' max(hu.value) AS max,max(hu.clock) AS clock, max(i.lastvalue) as lst' . ' FROM history_uint hu ' . ' LEFT JOIN items i ON hu.itemid = i.itemid' . ' WHERE hu.itemid=' . $this->items[$i]['itemid'] . ' AND hu.clock>=' . $from_time . ' AND hu.clock<=' . $to_time . ' GROUP BY hu.itemid');
} else {
array_push($sql_arr, 'SELECT t.itemid, ' . ' avg(t.value_avg) AS avg,min(t.value_min) AS min,' . ' max(t.value_max) AS max,max(t.clock) AS clock, max(i.lastvalue) as lst' . ' FROM trends t ' . ' LEFT JOIN items i ON t.itemid = i.itemid' . ' WHERE t.itemid=' . $this->items[$i]['itemid'] . ' AND t.clock>=' . $from_time . ' AND t.clock<=' . $to_time . ' GROUP BY t.itemid', 'SELECT t.itemid, ' . ' avg(t.value_avg) AS avg,min(t.value_min) AS min,' . ' max(t.value_max) AS max,max(t.clock) AS clock, max(i.lastvalue) as lst' . ' FROM trends_uint t ' . ' LEFT JOIN items i ON t.itemid = i.itemid' . ' WHERE t.itemid=' . $this->items[$i]['itemid'] . ' AND t.clock>=' . $from_time . ' AND t.clock<=' . $to_time . ' GROUP BY t.itemid');
}
$curr_data =& $this->data[$this->items[$i]['itemid']][$type];
$curr_data->min = NULL;
$curr_data->max = NULL;
$curr_data->avg = NULL;
$curr_data->clock = NULL;
foreach ($sql_arr as $sql) {
$result = DBselect($sql);
while ($row = DBfetch($result)) {
$curr_data->min = $row['min'];
$curr_data->max = $row['max'];
$curr_data->avg = $row['avg'];
$curr_data->lst = $row['lst'];
$curr_data->clock = $row['clock'];
$curr_data->shift_min = 0;
$curr_data->shift_max = 0;
$curr_data->shift_avg = 0;
}
unset($row);
}
switch ($this->items[$i]['calc_fnc']) {
case CALC_FNC_MIN:
$item_value = abs($curr_data->min);
break;
case CALC_FNC_MAX:
$item_value = abs($curr_data->max);
break;
case CALC_FNC_LST:
$item_value = abs($curr_data->lst);
break;
case CALC_FNC_AVG:
default:
$item_value = abs($curr_data->avg);
}
if ($type == GRAPH_ITEM_SUM) {
$this->background = $i;
$graph_sum = $item_value;
}
$this->sum += $item_value;
$strvaluelength = max($strvaluelength, strlen(convert_units($item_value, $this->items[$i]['unit'])));
}
if (isset($graph_sum)) {
$this->sum = $graph_sum;
}
$this->shiftlegendright += $strvaluelength * 7;
}
开发者ID:rennhak,项目名称:zabbix,代码行数:75,代码来源:class.cpie.php
示例13: valueComparisonFormForMultiplePeriods
/**
* Create report bar for for "Compare values for multiple periods"
*
* @return object $reportForm
*/
function valueComparisonFormForMultiplePeriods()
{
$config = get_request('config', 1);
$title = get_request('title', _('Report 3'));
$xlabel = get_request('xlabel', '');
$ylabel = get_request('ylabel', '');
$scaletype = get_request('scaletype', TIMEPERIOD_TYPE_WEEKLY);
$avgperiod = get_request('avgperiod', TIMEPERIOD_TYPE_DAILY);
$report_timesince = get_request('report_timesince', date(TIMESTAMP_FORMAT_ZERO_TIME, time() - SEC_PER_DAY));
$report_timetill = get_request('report_timetill', date(TIMESTAMP_FORMAT_ZERO_TIME));
$itemId = get_request('itemid', 0);
$hostids = get_request('hostids', array());
$hostids = zbx_toHash($hostids);
$showlegend = get_request('showlegend', 0);
$palette = get_request('palette', 0);
$palettetype = get_request('palettetype', 0);
$reportForm = new CFormTable(null, null, 'get');
$reportForm->setAttribute('name', 'zbx_report');
$reportForm->setAttribute('id', 'zbx_report');
if (isset($_REQUEST['report_show']) && $itemId) {
$reportForm->addVar('report_show', 'show');
}
$reportForm->addVar('config', $config);
$reportForm->addVar('report_timesince', date(TIMESTAMP_FORMAT, $report_timesince));
$reportForm->addVar('report_timetill', date(TIMESTAMP_FORMAT, $report_timetill));
$reportForm->addRow(_('Title'), new CTextBox('title', $title, 40));
$reportForm->addRow(_('X label'), new CTextBox('xlabel', $xlabel, 40));
$reportForm->addRow(_('Y label'), new CTextBox('ylabel', $ylabel, 40));
$reportForm->addRow(_('Legend'), new CCheckBox('showlegend', $showlegend, null, 1));
$reportForm->addVar('sortorder', 0);
$groupids = get_request('groupids', array());
$group_tb = new CTweenBox($reportForm, 'groupids', $groupids, 10);
$options = array('real_hosts' => true, 'output' => 'extend');
$db_groups = API::HostGroup()->get($options);
order_result($db_groups, 'name');
foreach ($db_groups as $gnum => $group) {
$groupids[$group['groupid']] = $group['groupid'];
$group_tb->addItem($group['groupid'], $group['name']);
}
$reportForm->addRow(_('Groups'), $group_tb->Get(_('Selected groups'), _('Other groups')));
$groupid = get_request('groupid', 0);
$cmbGroups = new CComboBox('groupid', $groupid, 'submit()');
$cmbGroups->addItem(0, _('All'));
foreach ($db_groups as $gnum => $group) {
$cmbGroups->addItem($group['groupid'], $group['name']);
}
$td_groups = new CCol(array(_('Group'), SPACE, $cmbGroups));
$td_groups->setAttribute('style', 'text-align: right;');
$host_tb = new CTweenBox($reportForm, 'hostids', $hostids, 10);
$options = array('real_hosts' => true, 'output' => array('hostid', 'name'));
if ($groupid > 0) {
$options['groupids'] = $groupid;
}
$db_hosts = API::Host()->get($options);
$db_hosts = zbx_toHash($db_hosts, 'hostid');
order_result($db_hosts, 'name');
foreach ($db_hosts as $hnum => $host) {
$host_tb->addItem($host['hostid'], $host['name']);
}
$options = array('real_hosts' => true, 'output' => array('hostid', 'name'), 'hostids' => $hostids);
$db_hosts2 = API::Host()->get($options);
order_result($db_hosts2, 'name');
foreach ($db_hosts2 as $hnum => $host) {
if (!isset($db_hosts[$host['hostid']])) {
$host_tb->addItem($host['hostid'], $host['name']);
}
}
$reportForm->addRow(_('Hosts'), $host_tb->Get(_('Selected hosts'), array(_('Other hosts | Group') . SPACE, $cmbGroups)));
$reporttimetab = new CTable(null, 'calendar');
$timeSinceRow = createDateSelector('report_timesince', $report_timesince, 'report_timetill');
array_unshift($timeSinceRow, _('From'));
$reporttimetab->addRow($timeSinceRow);
$timeTillRow = createDateSelector('report_timetill', $report_timetill, 'report_timesince');
array_unshift($timeTillRow, _('Till'));
$reporttimetab->addRow($timeTillRow);
$reportForm->addRow(_('Period'), $reporttimetab);
$scale = new CComboBox('scaletype', $scaletype);
$scale->addItem(TIMEPERIOD_TYPE_HOURLY, _('Hourly'));
$scale->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
$scale->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
$scale->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
$scale->addItem(TIMEPERIOD_TYPE_YEARLY, _('Yearly'));
$reportForm->addRow(_('Scale'), $scale);
$avgcmb = new CComboBox('avgperiod', $avgperiod);
$avgcmb->addItem(TIMEPERIOD_TYPE_HOURLY, _('Hourly'));
$avgcmb->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
$avgcmb->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
$avgcmb->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
$avgcmb->addItem(TIMEPERIOD_TYPE_YEARLY, _('Yearly'));
$reportForm->addRow(_('Average by'), $avgcmb);
$itemName = '';
if ($itemId) {
$itemName = get_item_by_itemid($itemId);
$itemName = itemName($itemName);
}
//.........这里部分代码省略.........
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:101,代码来源:reports.inc.php
示例14: selectData
protected function selectData()
{
$this->data = array();
$now = time(NULL);
if (isset($this->stime)) {
$this->from_time = $this->stime;
$this->to_time = $this->stime + $this->period;
} else {
$this->to_time = $now - 3600 * $this->from;
$this->from_time = $this->to_time - $this->period;
}
$p = $this->to_time - $this->from_time;
// graph size in time
$z = $p - $this->from_time % $p;
// graphsize - mod(from_time,p) for Oracle...
$x = $this->sizeX;
// graph size in px
for ($i = 0; $i < $this->num; $i++) {
$real_item = get_item_by_itemid($this->items[$i]['itemid']);
if (!isset($this->axis_valuetype[$this->items[$i]['axisside']])) {
$this->axis_valuetype[$this->items[$i]['axisside']] = $real_item['value_type'];
} else {
if ($this->axis_valuetype[$this->items[$i]['axisside']] != $real_item['value_type']) {
$this->axis_valuetype[$this->items[$i]['axisside']] = ITEM_VALUE_TYPE_FLOAT;
}
}
$type = $this->items[$i]['calc_type'];
if ($type == GRAPH_ITEM_AGGREGATED) {
/* skip current period */
$from_time = $this->from_time - $this->period * $this->items[$i]['periods_cnt'];
$to_time = $this->from_time;
} else {
$from_time = $this->from_time;
$to_time = $this->to_time;
}
$calc_field = 'round(' . $x . '*(mod(' . zbx_dbcast_2bigint('clock') . '+' . $z . ',' . $p . '))/(' . $p . '),0)';
/* required for 'group by' support of Oracle */
$sql_arr = array();
if ($real_item['history'] * 86400 > time() - ($this->from_time + $this->period / 2) && $this->period / $this->sizeX <= ZBX_MAX_TREND_DIFF / ZBX_GRAPH_MAX_SKIP_CELL) {
$this->dataFrom = 'history';
array_push($sql_arr, 'SELECT itemid,' . $calc_field . ' as i,' . ' count(*) as count,avg(value) as avg,min(value) as min,' . ' max(value) as max,max(clock) as clock' . ' FROM history ' . ' WHERE itemid=' . $this->items[$i]['itemid'] . ' AND clock>=' . $from_time . ' AND clock<=' . $to_time . ' GROUP BY itemid,' . $calc_field, 'SELECT itemid,' . $calc_field . ' as i,' . ' count(*) as count,avg(value) as avg,min(value) as min,' . ' max(value) as max,max(clock) as clock' . ' FROM history_uint ' . ' WHERE itemid=' . $this->items[$i]['itemid'] . ' AND clock>=' . $from_time . ' AND clock<=' . $to_time . ' GROUP BY itemid,' . $calc_field);
} else {
$this->dataFrom = 'trends';
array_push($sql_arr, 'SELECT itemid,' . $calc_field . ' as i,' . ' sum(num) as count,avg(value_avg) as avg,min(value_min) as min,' . ' max(value_max) as max,max(clock) as clock' . ' FROM trends ' . ' WHERE itemid=' . $this->items[$i]['itemid'] . ' AND clock>=' . $from_time . ' AND clock<=' . $to_time . ' GROUP BY itemid,' . $calc_field, 'SELECT itemid,' . $calc_field . ' as i,' . ' sum(num) as count,avg(value_avg) as avg,min(value_min) as min,' . ' max(value_max) as max,max(clock) as clock' . ' FROM trends_uint ' . ' WHERE itemid=' . $this->items[$i]['itemid'] . ' AND clock>=' . $from_time . ' AND clock<=' . $to_time . ' GROUP BY itemid,' . $calc_field);
$this->items[$i]['delay'] = max($this->items[$i]['delay'], 3600);
}
//SDI($sql_arr);
$curr_data =& $this->data[$this->items[$i]['itemid']][$type];
$curr_data->count = NULL;
$curr_data->min = NULL;
$curr_data->max = NULL;
$curr_data->avg = NULL;
$curr_data->clock = NULL;
foreach ($sql_arr as $sql) {
$result = DBselect($sql);
while ($row = DBfetch($result)) {
$idx = $row['i'] - 1;
if ($idx < 0) {
continue;
}
/* --------------------------------------------------
We are taking graph on 1px more than we need,
and here we are skiping first px, because of MOD (in SELECT),
it combines prelast point (it would be last point if not that 1px in begining)
and first point, but we still losing prelast point :(
but now we've got the first point.
--------------------------------------------------*/
$curr_data->count[$idx] = $row['count'];
$curr_data->min[$idx] = $row['min'];
$curr_data->max[$idx] = $row['max'];
$curr_data->avg[$idx] = $row['avg'];
$curr_data->clock[$idx] = $row['clock'];
$curr_data->shift_min[$idx] = 0;
$curr_data->shift_max[$idx] = 0;
$curr_data->shift_avg[$idx] = 0;
if ($this->type == GRAPH_TYPE_STACKED) {
$this->CheckGraphOrientation($curr_data->min[$idx]);
}
}
unset($row);
}
/* calculate missed points */
$first_idx = 0;
/*
first_idx - last existed point
ci - current index
cj - count of missed in onetime
dx - offset to first value (count to last existed point)
//*/
for ($ci = 0, $cj = 0; $ci < $this->sizeX; $ci++) {
if (!isset($curr_data->count[$ci]) || $curr_data->count[$ci] == 0) {
$curr_data->count[$ci] = 0;
$curr_data->shift_min[$ci] = 0;
$curr_data->shift_max[$ci] = 0;
$curr_data->shift_avg[$ci] = 0;
$cj++;
} else {
if ($cj > 0) {
$dx = $cj + 1;
$first_idx = $ci - $dx;
//.........这里部分代码省略.........
开发者ID:phedders,项目名称:zabbix,代码行数:101,代码来源:class.cchart.php
示例15: get_resource_name
function get_resource_name($permission, $id)
{
$res = '-';
if ($permission == 'Graph') {
if (isset($id) && $id != 0) {
if ($graph = get_graph_by_graphid($id)) {
$res = $graph['name'];
}
} else {
if (!isset($id) || $id == 0) {
$res = 'All graphs';
}
}
} else {
if ($permission == 'Host') {
if (isset($id) && $id != 0) {
if ($host = get_host_by_hostid($id)) {
$res = $host['host'];
}
} else {
if (!isset($id) || $id == 0) {
$res = 'All hosts';
}
}
|
请发表评论