本文整理汇总了PHP中get_cdef函数的典型用法代码示例。如果您正苦于以下问题:PHP get_cdef函数的具体用法?PHP get_cdef怎么用?PHP get_cdef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_cdef函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rrdtool_function_graph
//.........这里部分代码省略.........
/* +++++++++++++++++++++++ GRAPH ITEMS: CDEF's +++++++++++++++++++++++ */
$i = 0;
reset($graph_items);
if (sizeof($graph_items) > 0) {
foreach ($graph_items as $graph_item) {
/* first we need to check if there is a DEF for the current data source/cf combination. if so,
we will use that */
if (isset($cf_ds_cache{$graph_item["data_template_rrd_id"]}{$graph_item["consolidation_function_id"]})) {
$cf_id = $graph_item["consolidation_function_id"];
}else{
/* if there is not a DEF defined for the current data source/cf combination, then we will have to
improvise. choose the first available cf in the following order: AVERAGE, MAX, MIN, LAST */
if (isset($cf_ds_cache{$graph_item["data_template_rrd_id"]}[1])) {
$cf_id = 1; /* CF: AVERAGE */
}elseif (isset($cf_ds_cache{$graph_item["data_template_rrd_id"]}[3])) {
$cf_id = 3; /* CF: MAX */
}elseif (isset($cf_ds_cache{$graph_item["data_template_rrd_id"]}[2])) {
$cf_id = 2; /* CF: MIN */
}elseif (isset($cf_ds_cache{$graph_item["data_template_rrd_id"]}[4])) {
$cf_id = 4; /* CF: LAST */
}else{
$cf_id = 1; /* CF: AVERAGE */
}
}
/* make cdef string here; a note about CDEF's in cacti. A CDEF is neither unique to a
data source of global cdef, but is unique when those two variables combine. */
$cdef_graph_defs = ""; $cdef_total_ds = ""; $cdef_similar_ds = "";
if ((!empty($graph_item["cdef_id"])) && (!isset($cdef_cache{$graph_item["cdef_id"]}{$graph_item["data_template_rrd_id"]}[$cf_id]))) {
$cdef_string = get_cdef($graph_item["cdef_id"]);
/* create cdef string for "total all data sources" if requested */
if (ereg("ALL_DATA_SOURCES_(NO)?DUPS", $cdef_string)) {
$item_count = 0;
for ($t=0;($t<count($graph_items));$t++) {
if ((ereg("(AREA|STACK|LINE[123])", $graph_item_types{$graph_items[$t]["graph_type_id"]})) && (!empty($graph_items[$t]["data_template_rrd_id"]))) {
/* if the user screws up CF settings, PHP will generate warnings if left unchecked */
if (isset($cf_ds_cache{$graph_items[$t]["data_template_rrd_id"]}[$cf_id])) {
$def_name = generate_graph_def_name(strval($cf_ds_cache{$graph_items[$t]["data_template_rrd_id"]}[$cf_id]));
$cdef_total_ds .= ($item_count == 0 ? "" : ",") . "TIME," . (time() - $seconds_between_graph_updates) . ",GT,$def_name,$def_name,UN,0,$def_name,IF,IF"; /* convert unknowns to '0' first */
$item_count++;
}
}
}
/* if there is only one item to total, don't even bother with the summation. otherwise
cdef=a,b,c,+,+ is fine. */
if ($item_count > 1) {
$cdef_total_ds .= str_repeat(",+", ($item_count - 2)) . ",+";
}
}
/* create cdef string for "total similar data sources" if requested */
if (ereg("SIMILAR_DATA_SOURCES_(NO)?DUPS", $cdef_string) ) {
$sources_seen = array();
$item_count = 0;
for ($t=0;($t<count($graph_items));$t++) {
if ((ereg("(AREA|STACK|LINE[123])", $graph_item_types{$graph_items[$t]["graph_type_id"]})) && (!empty($graph_items[$t]["data_template_rrd_id"])) && ($graph_item["data_source_name"] == $graph_items[$t]["data_source_name"]) && ($graph_item["graph_templates_item_id"] != $graph_items[$t]["graph_templates_item_id"])) {
/* if the user screws up CF settings, PHP will generate warnings if left unchecked */
if (isset($cf_ds_cache{$graph_items[$t]["data_template_rrd_id"]}[$cf_id]) && (!isset($sources_seen{$graph_items[$t]["data_template_rrd_id"]}))) {
$def_name = generate_graph_def_name(strval($cf_ds_cache{$graph_items[$t]["data_template_rrd_id"]}[$cf_id]));
示例2: draw_cdef_preview
function draw_cdef_preview($cdef_id)
{
?>
<tr class='even'>
<td>
<pre>cdef=<?php
print get_cdef($cdef_id, true);
?>
</pre>
</td>
</tr>
<?php
}
示例3: draw_cdef_preview
function draw_cdef_preview($cdef_id)
{
global $colors;
?>
<tr bgcolor="#<?php
print $colors["panel"];
?>
">
<td>
<pre>cdef=<?php
print get_cdef($cdef_id, true);
?>
</pre>
</td>
</tr>
<?php
}
示例4: get_cdef
function get_cdef($cdef_id)
{
$cdef_items = db_fetch_assoc("select * from cdef_items where cdef_id={$cdef_id} order by sequence");
$i = 0;
$cdef_string = "";
if (sizeof($cdef_items) > 0) {
foreach ($cdef_items as $cdef_item) {
if ($i > 0) {
$cdef_string .= ",";
}
if ($cdef_item["type"] == 5) {
$current_cdef_id = $cdef_item["value"];
$cdef_string .= get_cdef($current_cdef_id);
} else {
$cdef_string .= get_cdef_item_name($cdef_item["id"]);
}
$i++;
}
}
return $cdef_string;
}
示例5: get_cdef
function get_cdef($cdef_id)
{
$cdef_items = db_fetch_assoc_prepared('SELECT * FROM cdef_items WHERE cdef_id = ? ORDER BY sequence', array($cdef_id));
$i = 0;
$cdef_string = '';
if (sizeof($cdef_items) > 0) {
foreach ($cdef_items as $cdef_item) {
if ($i > 0) {
$cdef_string .= ',';
}
if ($cdef_item['type'] == 5) {
$current_cdef_id = $cdef_item['value'];
$cdef_string .= get_cdef($current_cdef_id);
} else {
$cdef_string .= get_cdef_item_name($cdef_item['id']);
}
$i++;
}
}
return $cdef_string;
}
示例6: rrdtool_function_xport
//.........这里部分代码省略.........
}else{
/* all other types are based on the best matching CF */
$xport_cf = generate_graph_best_cf($xport_item["local_data_id"], $xport_item["consolidation_function_id"]);
/* remember this for second foreach loop */
$xport_items[$key]["cf_reference"] = $xport_cf;
}
if ((!empty($xport_item["local_data_id"])) &&
(!isset($cf_ds_cache{$xport_item["data_template_rrd_id"]}[$xport_cf]))) {
/* use a user-specified ds path if one is entered */
$data_source_path = get_data_source_path($xport_item["local_data_id"], true);
/* FOR WIN32: Escape all colon for drive letters (ex. D\:/path/to/rra) */
$data_source_path = str_replace(":", "\:", $data_source_path);
if (!empty($data_source_path)) {
/* NOTE: (Update) Data source DEF names are created using the graph_item_id; then passed
to a function that matches the digits with letters. rrdtool likes letters instead
of numbers in DEF names; especially with CDEF's. cdef's are created
the same way, except a 'cdef' is put on the beginning of the hash */
$xport_defs .= "DEF:" . generate_graph_def_name(strval($i)) . "=\"$data_source_path\":" . $xport_item["data_source_name"] . ":" . $consolidation_functions[$xport_cf] . RRD_NL;
$cf_ds_cache{$xport_item["data_template_rrd_id"]}[$xport_cf] = "$i";
$i++;
}
}
/* cache cdef value here to support data query variables in the cdef string */
if (empty($xport_item["cdef_id"])) {
$xport_item["cdef_cache"] = "";
$xport_items[$j]["cdef_cache"] = "";
}else{
$xport_item["cdef_cache"] = get_cdef($xport_item["cdef_id"]);
$xport_items[$j]["cdef_cache"] = get_cdef($xport_item["cdef_id"]);
}
/* +++++++++++++++++++++++ LEGEND: TEXT SUBSITUTION (<>'s) +++++++++++++++++++++++ */
/* note the current item_id for easy access */
$xport_item_id = $xport_item["graph_templates_item_id"];
/* the following fields will be searched for graph variables */
$variable_fields = array(
"text_format" => array(
"process_no_legend" => false
),
"value" => array(
"process_no_legend" => true
),
"cdef_cache" => array(
"process_no_legend" => true
)
);
/* loop through each field that we want to substitute values for:
currently: text format and value */
while (list($field_name, $field_array) = each($variable_fields)) {
/* certain fields do not require values when the legend is not to be shown */
if (($field_array["process_no_legend"] == false) && (isset($xport_data_array["graph_nolegend"]))) {
continue;
}
$xport_variables[$field_name][$xport_item_id] = $xport_item[$field_name];
/* date/time substitution */
示例7: rrdtool_function_graph
//.........这里部分代码省略.........
/* remember this for second foreach loop */
$graph_items[$key]["cf_reference"] = $graph_cf;
}
} else {
/* all other types are based on the best matching CF */
$graph_cf = generate_graph_best_cf($graph_item["local_data_id"], $graph_item["consolidation_function_id"]);
/* remember this for second foreach loop */
$graph_items[$key]["cf_reference"] = $graph_cf;
}
if (!empty($graph_item["local_data_id"]) && !isset($cf_ds_cache[$graph_item["data_template_rrd_id"]][$graph_cf])) {
/* use a user-specified ds path if one is entered */
if (isset($graph_data_array['export_realtime'])) {
$data_source_path = read_config_option("realtime_cache_path") . "/user_" . session_id() . "_" . $graph_item["local_data_id"] . ".rrd";
} else {
$data_source_path = get_data_source_path($graph_item["local_data_id"], true);
}
/* FOR WIN32: Escape all colon for drive letters (ex. D\:/path/to/rra) */
$data_source_path = str_replace(":", "\\:", $data_source_path);
if (!empty($data_source_path)) {
/* NOTE: (Update) Data source DEF names are created using the graph_item_id; then passed
to a function that matches the digits with letters. rrdtool likes letters instead
of numbers in DEF names; especially with CDEF's. cdef's are created
the same way, except a 'cdef' is put on the beginning of the hash */
$graph_defs .= "DEF:" . generate_graph_def_name(strval($i)) . "=" . cacti_escapeshellarg($data_source_path) . ":" . cacti_escapeshellarg($graph_item["data_source_name"], true) . ":" . $consolidation_functions[$graph_cf] . RRD_NL;
$cf_ds_cache[$graph_item["data_template_rrd_id"]][$graph_cf] = "{$i}";
$i++;
}
}
/* cache cdef value here to support data query variables in the cdef string */
if (empty($graph_item["cdef_id"])) {
$graph_item["cdef_cache"] = "";
$graph_items[$j]["cdef_cache"] = "";
} else {
$graph_item["cdef_cache"] = get_cdef($graph_item["cdef_id"]);
$graph_items[$j]["cdef_cache"] = get_cdef($graph_item["cdef_id"]);
}
/* +++++++++++++++++++++++ LEGEND: TEXT SUBSTITUTION (<>'s) +++++++++++++++++++++++ */
/* note the current item_id for easy access */
$graph_item_id = $graph_item["graph_templates_item_id"];
/* the following fields will be searched for graph variables */
$variable_fields = array("text_format" => array("process_no_legend" => false), "value" => array("process_no_legend" => true), "cdef_cache" => array("process_no_legend" => true));
/* loop through each field that we want to substitute values for:
currently: text format and value */
while (list($field_name, $field_array) = each($variable_fields)) {
/* certain fields do not require values when the legend is not to be shown */
if ($field_array["process_no_legend"] == false && isset($graph_data_array["graph_nolegend"])) {
continue;
}
$graph_variables[$field_name][$graph_item_id] = $graph_item[$field_name];
/* date/time substitution */
if (strstr($graph_variables[$field_name][$graph_item_id], "|date_time|")) {
$graph_variables[$field_name][$graph_item_id] = str_replace("|date_time|", date('D d M H:i:s T Y', strtotime(db_fetch_cell("SELECT value FROM settings WHERE name='date'"))), $graph_variables[$field_name][$graph_item_id]);
}
/* data source title substitution */
if (strstr($graph_variables[$field_name][$graph_item_id], "|data_source_title|")) {
$graph_variables[$field_name][$graph_item_id] = str_replace("|data_source_title|", get_data_source_title($graph_item["local_data_id"]), $graph_variables[$field_name][$graph_item_id]);
}
/* data query variables */
$graph_variables[$field_name][$graph_item_id] = rrd_substitute_host_query_data($graph_variables[$field_name][$graph_item_id], $graph, $graph_item);
/* Nth percentile */
if (preg_match_all("/\\|([0-9]{1,2}):(bits|bytes):(\\d):(current|total|max|total_peak|all_max_current|all_max_peak|aggregate_max|aggregate_sum|aggregate_current|aggregate):(\\d)?\\|/", $graph_variables[$field_name][$graph_item_id], $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
$graph_variables[$field_name][$graph_item_id] = str_replace($match[0], variable_nth_percentile($match, $graph_item, $graph_items, $graph_start, $graph_end), $graph_variables[$field_name][$graph_item_id]);
}
}
/* bandwidth summation */
示例8: rrdtool_function_graph_rt
//.........这里部分代码省略.........
}else{
/* all other types are based on the best matching CF */
$graph_cf = generate_graph_best_cf($graph_item["local_data_id"], $graph_item["consolidation_function_id"]);
/* remember this for second foreach loop */
$graph_items[$key]["cf_reference"] = $graph_cf;
}
if ((!empty($graph_item["local_data_id"])) && (!isset($cf_ds_cache{$graph_item["data_template_rrd_id"]}[$graph_cf]))) {
/* use a user-specified ds path if one is entered */
$data_source_path = read_config_option("realtime_cache_path") .
"/realtime_" . $graph_item["local_data_id"] . "_5.rrd";
/* FOR WIN32: Escape all colon for drive letters (ex. D\:/path/to/rra) */
$data_source_path = str_replace(":", "\:", $data_source_path);
if (!empty($data_source_path)) {
/* NOTE: (Update) Data source DEF names are created using the graph_item_id; then passed
to a function that matches the digits with letters. rrdtool likes letters instead
of numbers in DEF names; especially with CDEF's. cdef's are created
the same way, except a 'cdef' is put on the beginning of the hash */
$graph_defs .= "DEF:" . generate_graph_def_name(strval($i)) . "=\"$data_source_path\":" . $graph_item["data_source_name"] . ":" . $consolidation_functions[$graph_cf] . RRD_NL;
$cf_ds_cache{$graph_item["data_template_rrd_id"]}[$graph_cf] = "$i";
$i++;
}
}
/* cache cdef value here to support data query variables in the cdef string */
if (empty($graph_item["cdef_id"])) {
$graph_item["cdef_cache"] = "";
$graph_items[$j]["cdef_cache"] = "";
}else{
$graph_item["cdef_cache"] = get_cdef($graph_item["cdef_id"]);
$graph_items[$j]["cdef_cache"] = get_cdef($graph_item["cdef_id"]);
}
/* +++++++++++++++++++++++ LEGEND: TEXT SUBSITUTION (<>'s) +++++++++++++++++++++++ */
/* note the current item_id for easy access */
$graph_item_id = $graph_item["graph_templates_item_id"];
/* the following fields will be searched for graph variables */
$variable_fields = array(
"text_format" => array(
"process_no_legend" => false
),
"value" => array(
"process_no_legend" => true
),
"cdef_cache" => array(
"process_no_legend" => true
)
);
/* loop through each field that we want to substitute values for:
currently: text format and value */
while (list($field_name, $field_array) = each($variable_fields)) {
/* certain fields do not require values when the legend is not to be shown */
if (($field_array["process_no_legend"] == false) && (isset($graph_data_array["graph_nolegend"]))) {
continue;
}
$graph_variables[$field_name][$graph_item_id] = $graph_item[$field_name];
/* date/time substitution */
示例9: draw_cdef_preview
function draw_cdef_preview($cdef_id) {
global $colors; ?>
<tr>
<td>
<pre>cdef=<?php print get_cdef($cdef_id, true);?></pre>
</td>
</tr>
<?php }
示例10: rrdtool_function_xport
//.........这里部分代码省略.........
$i = 0;
$j = 0;
$nth = 0;
$sum = 0;
if (sizeof($xport_items) > 0) {
foreach ($xport_items as $xport_item) {
/* mimic the old behavior: LINE[123], AREA, and STACK items use the CF specified in the graph item */
if ($xport_item["graph_type_id"] == 4 || $xport_item["graph_type_id"] == 5 || $xport_item["graph_type_id"] == 6 || $xport_item["graph_type_id"] == 7 || $xport_item["graph_type_id"] == 8) {
$xport_cf = $xport_item["consolidation_function_id"];
/* all other types are based on the AVERAGE CF */
} else {
$xport_cf = 1;
}
if (!empty($xport_item["local_data_id"]) && !isset($cf_ds_cache[$xport_item["data_template_rrd_id"]][$xport_cf])) {
/* use a user-specified ds path if one is entered */
$data_source_path = get_data_source_path($xport_item["local_data_id"], true);
/* FOR WIN32: Escape all colon for drive letters (ex. D\:/path/to/rra) */
$data_source_path = str_replace(":", "\\:", $data_source_path);
if (!empty($data_source_path)) {
/* NOTE: (Update) Data source DEF names are created using the graph_item_id; then passed
to a function that matches the digits with letters. rrdtool likes letters instead
of numbers in DEF names; especially with CDEF's. cdef's are created
the same way, except a 'cdef' is put on the beginning of the hash */
$xport_defs .= "DEF:" . generate_graph_def_name(strval($i)) . "=\"{$data_source_path}\":" . $xport_item["data_source_name"] . ":" . $consolidation_functions[$xport_cf] . RRD_NL;
$cf_ds_cache[$xport_item["data_template_rrd_id"]][$xport_cf] = "{$i}";
$i++;
}
}
/* cache cdef value here to support data query variables in the cdef string */
if (empty($xport_item["cdef_id"])) {
$xport_item["cdef_cache"] = "";
$xport_items[$j]["cdef_cache"] = "";
} else {
$xport_item["cdef_cache"] = get_cdef($xport_item["cdef_id"]);
$xport_items[$j]["cdef_cache"] = get_cdef($xport_item["cdef_id"]);
}
/* +++++++++++++++++++++++ LEGEND: TEXT SUBSITUTION (<>'s) +++++++++++++++++++++++ */
/* note the current item_id for easy access */
$xport_item_id = $xport_item["graph_templates_item_id"];
/* the following fields will be searched for graph variables */
$variable_fields = array("text_format" => array("process_no_legend" => false), "value" => array("process_no_legend" => true), "cdef_cache" => array("process_no_legend" => true));
/* loop through each field that we want to substitute values for:
currently: text format and value */
while (list($field_name, $field_array) = each($variable_fields)) {
/* certain fields do not require values when the legend is not to be shown */
if ($field_array["process_no_legend"] == false && isset($xport_data_array["graph_nolegend"])) {
continue;
}
$xport_variables[$field_name][$xport_item_id] = $xport_item[$field_name];
/* date/time substitution */
if (strstr($xport_variables[$field_name][$xport_item_id], "|date_time|")) {
$xport_variables[$field_name][$xport_item_id] = str_replace("|date_time|", date('D d M H:i:s T Y', strtotime(db_fetch_cell("select value from settings where name='date'"))), $xport_variables[$field_name][$xport_item_id]);
}
/* data query variables */
$xport_variables[$field_name][$xport_item_id] = rrd_substitute_host_query_data($xport_variables[$field_name][$xport_item_id], $graph, $xport_item);
/* Nth percentile */
if (preg_match_all("/\\|([0-9]{1,2}):(bits|bytes):(\\d):(current|total|max|total_peak|all_max_current|all_max_peak|aggregate_max|aggregate_sum|aggregate_current|aggregate):(\\d)?\\|/", $xport_variables[$field_name][$xport_item_id], $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
if ($field_name == "value") {
$xport_meta["NthPercentile"][$nth]["format"] = $match[0];
$xport_meta["NthPercentile"][$nth]["value"] = str_replace($match[0], variable_nth_percentile($match, $xport_item, $xport_items, $graph_start, $graph_end), $xport_variables[$field_name][$xport_item_id]);
$nth++;
}
}
}
/* bandwidth summation */