function get_rra_max($local_graph_id) {
$sql = "SELECT
rra_max_order.rra_value
FROM
data_template_data,graph_templates_item,data_template_rrd,rra_max_order
WHERE
data_template_data.local_data_id=data_template_rrd.local_data_id
AND graph_templates_item.task_item_id=data_template_rrd.id
AND rra_max_order.id=data_template_data.local_data_id
AND graph_templates_item.local_graph_id=".$local_graph_id." limit 1";
$graphs_sql = "SELECT
distinct(graph_templates_graph.title_cache),graph_templates_graph.local_graph_id
FROM (graph_local,graph_templates_graph,data_template_data,graph_templates_item,data_template_rrd,rra_max_order)
$sql_join
WHERE
graph_local.id=graph_templates_graph.local_graph_id
AND graph_templates_graph.local_graph_id=graph_templates_item.local_graph_id
AND rra_max_order.id=data_template_data.local_data_id
AND graph_templates_item.task_item_id=data_template_rrd.id
AND data_template_data.local_data_id=data_template_rrd.local_data_id
AND graph_local.graph_template_id=" . $graph_template["id"] . "
AND graph_local.host_id=" . $leaf["host_id"] . "
AND rra_max_order.rra_value ".$judge.$traffic_perc."
$sql_where
ORDER BY graph_templates_graph.title_cache";
//echo $graphs_sql;
}
else
{
$graphs_sql = "SELECT
graph_templates_graph.title_cache,
graph_templates_graph.local_graph_id
FROM (graph_local,graph_templates_graph)
$sql_join
WHERE graph_local.id=graph_templates_graph.local_graph_id
AND graph_local.graph_template_id=" . $graph_template["id"] . "
AND graph_local.host_id=" . $leaf["host_id"] . "
$sql_where
ORDER BY graph_templates_graph.title_cache";
}