Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


small bug and a fix

 
Post new topic   Reply to topic    Cacti Forum Index -> Help: Unstable Development Versions
Author Message
moonman
Cacti User


Joined: 06 Sep 2003
Posts: 94

PostPosted: Sun Aug 29, 2004 5:02 pm    Post subject: small bug and a fix Reply with quote

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



graph2.jpg
 Description:
fixed graph
 Filesize:  158.2 KB
 Viewed:  1200 Time(s)

graph2.jpg



graph1.jpg
 Description:
bad graph
 Filesize:  157.89 KB
 Viewed:  1200 Time(s)

graph1.jpg



cacti_graph_template_total_similar.xml
 Description:
the graph template

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

PostPosted: Thu Sep 02, 2004 7:38 pm    Post subject: Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Help: Unstable Development Versions All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group