|
|
| Author |
Message |
moonman Cacti User
Joined: 06 Sep 2003 Posts: 94
|
Posted: Sun Aug 29, 2004 5:02 pm Post subject: small bug and a fix |
|
|
if i create a graph template and in the graph items Text Format I put a variable like |query_ifName| all the graph items get the same ifName. you can see the problem if you import the xml and look on the attached graphs.
the problem is because the function substitute_snmp_query_data in lib/rrd.php get the variable $graph["snmp_index"] that contain only one index per graph and not one index per graph item
the fix is to use the snmp index from data_local and not from graph_local
i do it by
| Code: | if (preg_match("/\|query_[a-zA-Z0-9_]+\|/", $graph_variables[$field_name][$graph_item_id])) {
$graph_item_local_data_id = $graph_item["local_data_id"];
$data_local = db_fetch_row("select snmp_index from data_local where id=$graph_item_local_data_id");
$graph_variables[$field_name][$graph_item_id] = substitute_snmp_query_data($graph_variables[$field_name][$graph_item_id], $graph["host_id"], $graph["snmp_query_id"], $data_local["snmp_index"]);
} |
but my be there is better way
Thanks
| Description: |
|
| Filesize: |
158.2 KB |
| Viewed: |
1200 Time(s) |

|
| Description: |
|
| Filesize: |
157.89 KB |
| Viewed: |
1200 Time(s) |

|
| Description: |
|
 Download |
| Filename: |
cacti_graph_template_total_similar.xml |
| Filesize: |
22.83 KB |
| Downloaded: |
132 Time(s) |
|
|
| Back to top |
|
 |
raX Lead Developer
Joined: 13 Oct 2001 Posts: 2234 Location: Carlisle, PA
|
Posted: Thu Sep 02, 2004 7:38 pm Post subject: |
|
|
Good catch! I adapted your fix slightly to take into account the situation where the user does not specify a data source for the graph item. It will fall back on the data query information stored with the graph in this case. If a data source is specified, the data query information stored with the data source selected will be used.
| Code: | /* data query variables */
if (preg_match("/\|query_[a-zA-Z0-9_]+\|/", $graph_variables[$field_name][$graph_item_id])) {
/* default to the graph data query information from the graph */
if (empty($graph_item["local_data_id"])) {
$graph_variables[$field_name][$graph_item_id] = substitute_snmp_query_data($graph_variables[$field_name][$graph_item_id], $graph["host_id"], $graph["snmp_query_id"], $graph["snmp_index"]);
/* use the data query information from the data source if possible */
}else{
$data_local = db_fetch_row("select snmp_index,snmp_query_id,host_id from data_local where id='" . $graph_item["local_data_id"] . "'");
$graph_variables[$field_name][$graph_item_id] = substitute_snmp_query_data($graph_variables[$field_name][$graph_item_id], $data_local["host_id"], $data_local["snmp_query_id"], $data_local["snmp_index"]);
}
} |
-Ian
|
|
| Back to top |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|