--- cacti-release-0.8.6/lib/rrd.php 2004-10-06 19:17:19.000000000 -0400 +++ cacti-unstable/lib/rrd.php 2004-10-20 17:44:50.000000000 -0400 @@ -798,7 +798,7 @@ /* 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_total = ""; $cdef_similar_ds = ""; $cdef_similar = ""; + $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"]); @@ -811,7 +811,7 @@ /* 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 .= "TIME," . (time() - $seconds_between_graph_updates) . ",GT,$def_name,$def_name,UN,0,$def_name,IF,IF,"; /* convert unknowns to '0' first */ + $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++; } } @@ -819,10 +819,8 @@ /* 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 = str_replace(",", "", $cdef_total_ds); - }else{ - $cdef_total = $cdef_total_ds . str_repeat("+,", max(0, ($item_count - 2))) . "+"; + if ($item_count > 1) { + $cdef_total_ds .= str_repeat(",+", ($item_count - 2)) . ",+"; } } @@ -836,7 +834,7 @@ /* 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])); - $cdef_similar_ds .= "TIME," . (time() - $seconds_between_graph_updates) . ",GT,$def_name,$def_name,UN,0,$def_name,IF,IF,"; /* convert unknowns to '0' first */ + $cdef_similar_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 */ $sources_seen{$graph_items[$t]["data_template_rrd_id"]} = 1; $item_count++; } @@ -845,16 +843,14 @@ /* 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_similar = str_replace(",", "", $cdef_similar_ds); - }else{ - $cdef_similar = $cdef_similar_ds . str_repeat("+,", ($item_count - 2)) . "+"; + if ($item_count > 1) { + $cdef_similar_ds .= str_repeat(",+", ($item_count - 2)) . ",+"; } } $cdef_string = str_replace("CURRENT_DATA_SOURCE", generate_graph_def_name(strval((isset($cf_ds_cache{$graph_item["data_template_rrd_id"]}[$cf_id]) ? $cf_ds_cache{$graph_item["data_template_rrd_id"]}[$cf_id] : "0"))), $cdef_string); - $cdef_string = str_replace("ALL_DATA_SOURCES_NODUPS", $cdef_total, $cdef_string); - $cdef_string = str_replace("SIMILAR_DATA_SOURCES_NODUPS", $cdef_similar, $cdef_string); + $cdef_string = str_replace("ALL_DATA_SOURCES_NODUPS", $cdef_total_ds, $cdef_string); + $cdef_string = str_replace("SIMILAR_DATA_SOURCES_NODUPS", $cdef_similar_ds, $cdef_string); /* data source item variables */ $cdef_string = str_replace("CURRENT_DS_MINIMUM_VALUE", (empty($graph_item["rrd_minimum"]) ? "0" : $graph_item["rrd_minimum"]), $cdef_string);