Data source and graph title expansion

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
rbmore
Posts: 5
Joined: Mon Apr 12, 2004 11:40 am

Data source and graph title expansion

Post by rbmore »

Hi!

I've got a problem when I do an update on the interfaces section of my "polling host" ("device" since last version) and some changes/reordering of interfaces occur. Currently, I'm using ifName as index for my Data Sources to prevent some of the problems, but I've noticed that my titles (both in data sources and graphs) don't update correctly.

Looking at the php code and the db interactions I think that the problem is around the local_data table, not updating from the snmp query cache when I do a "save" on the host.php page. To solve that, I've made the next modification to the code of 0.8.3a on the push_out_host function:

Code: Select all

--- cacti-orig/include/utility_functions.php  2004-04-0713:36:10.000000000  +0200
+++ cacti/include/utility_functions.php 2004-04-20 21:36:52.000000000 +0200
@@ -408,6 +408,9 @@
                }
                }

+               /* update local_data from last snmp query cache */
+               update_data_source_snmp_query_cache($data_source["local_data_id"]);
+
                /* make sure to update the poller cache as well */
                update_poller_cache($data_source["local_data_id"]);
        }
This, effectively solves my title/polled-interface dissonance problem.
I'm missing (again) the point?

Rober
rbmore
Posts: 5
Joined: Mon Apr 12, 2004 11:40 am

Re: Data source and graph title expansion

Post by rbmore »

Once again, some more testing and another patch to solve my problem. This patch deprecates the former one.

My testbed is a linux host where I'm forcing the interfaces renumbering creating/deleting tap interfaces in different order. If you try to work with a "polling host" like that you could see the problem: the rearrangement of interfaces indexed by ifDesc is correct from the point of view of the poller (same ifDesc indexed interface updates always the correct rrd file), but the ds's and graphs titles are wrong... all that after a query reload.

To solve that, my approximation is a patch to ensure the titles upgrade from the last snmp query after a "query reload" and "save" in the host page.

Code: Select all

--- cacti-orig/host.php 2003-10-03 18:01:44.000000000 +0200
+++ cacti/host.php      2004-04-21 13:04:15.000000000 +0200
@@ -116,7 +116,29 @@

                                /* the host subsitution cache is now stale; purge it */
                                kill_session_var("sess_host_cache_array");
-
+
+                               /* update the snmp cache for ds's */
+                               $data_sources = db_fetch_assoc("select
+                                       id
+                                       from data_local
+                                       where host_id=$host_id");
+                               if (sizeof($data_sources) > 0) {
+                               foreach ($data_sources as $data_source) {
+                                       update_data_source_snmp_query_cache($data_source["id"]);
+                               }
+                               }
+
+                               /* update the snmp cache for graphs */
+                               $graphs = db_fetch_assoc("select
+                                       id
+                                       from graph_local
+                                       where host_id=$host_id");
+                               if (sizeof($graphs) > 0) {
+                               foreach ($graphs as $graph) {
+                                       update_graph_snmp_query_cache($graph["id"]);
+                               }
+                               }
+
                                /* update title cache for graph and data source */
                                update_data_source_title_cache_from_host($host_id);
                                update_graph_title_cache_from_host($host_id);
rbmore
Posts: 5
Joined: Mon Apr 12, 2004 11:40 am

Patch for host.php in cacti 0.8.5a

Post by rbmore »

Hi.

Just installed cacti-0.8.5a to see if it solves the problem of data source / titles synch without my patch... and no luck :(

I'll try to put it clear with a simple example:

1. Start with a fresh install of cacti-0.8.5a
2. In a shell, create with tunctl some tap interfaces: tunctl -t tap0, tunctl -t tap1, tunctl -t tap2, ... in that order
3. Get the interfaces of Device localhost and create the network graphs for them using ifDesc as index
4. In a shell, delete with tunctl all the tap interfaces: tunctl -d tap0, tunctl -d tap1, tunctl -d tap2, ...
5. In a shell, recreate with tunctl the tap interfaces in *different* order: tunctl -t tap2, tunctl -t tap1, tunctl -t tap0, ...
6. Reload the query about interfaces in the Device localhost.
7. Looking at the Data Sources details of interfaces tap*... there's a mistmatch between the index (ifDesc) and the title of the Data Source. You can expect this mismatch in the Graph title... :-(

Yeah, I know, the problem only arises when the SNMP agent of the device changes the index of his interfaces... but I guarantee you a good nightmare if you find a Cisco 7200 with > 300 data sources whose titles and sources don't match :-)

The patch included, against host.php in cacti 0.8.5a, solves this by forcing a title refresh when you do a "save" in the Device page.
Rax, please, consider including it in the mainstream version if it's correct and thanks for your effort.

Greets

Rober
Attachments
cacti-0.8.5a-patch_host-save.diff.gz
(433 Bytes) Downloaded 111 times
raX
Lead Developer
Posts: 2243
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

Post by raX »

I definitely see the problem that you are pointing out here, and I intend on adding your fix. Wouldn't it make more sense to include this bit of code in the data_query() function that gets called whenever you click the "reload query" button? You could also make things slightly more efficent by adding a "and snmp_query_id=XX" to each query if you put the code here.

Let me know what you think and if I am missing something.

On a related note, it would really be nice to have a global "refresh title cache" link on the utilities screen. In fact, I might add that.

-Ian
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests