Discovery 1.5 - autocreate graphs not working as expected

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

Post Reply
ripperza
Posts: 14
Joined: Thu Aug 02, 2012 9:09 am

Discovery 1.5 - autocreate graphs not working as expected

Post by ripperza »

Hi,
So the plugin works as advertised, awesomly at that. I have, like most people, devices I've had to create my own data queries for. In this case the devices switches with many ports and so far all is ok. Now when I tick "Only create graphs for "up" interfaces I encounter 2 problems, first is that only one kind of graph is creates (port errors in my case) and the bytes in and out graph is not auto created. Second problem is all the ports irespective of the port status have graphs created for the errors query.

I had a look at the code and I can see why it's mistaking interface status and just graphing, I can't see how easily to fix the "only graphing one instance in the data_query"

First, my quick and dirty fix on detecting the port up/down:
on line 666 of findhosts.php
if ($snmp_query["id"] == 1 && $graph_interface_only_up) {
needs to include my query
if (($snmp_query["id"] == 16 || $snmp_query["id"] == 1) && $graph_interface_only_up) {

Then line
and host_id=" . $host_id . " and field_name = 'ifOperStatus' and field_value = 'Up' and snmp_query_id=" . $snmp_query["id"] .")
needs to allow for the vendor spesific tags
and host_id=" . $host_id . " and field_name in ('ifOperStatus','EtherPortOperStatus') and field_value in ('Up','up(1)') and snmp_query_id=" . $snmp_query["id"] .")

Obviously this is just as hard coded as the original and I'm sure there is a better way to do this...?

Now the second problem, only creating the 1 instance of graphs for the set proveded by the data query.
In my data query in exactly the same way as "SNMP - Interface Statistics" there are mutiple "associated graph templates" and the discovery plug only creates the graphs for one of them.

Again in the code, line 657 we select for all the queries
$data_query_graphs = db_fetch_assoc("select snmp_query_graph.id,snmp_query_graph.name,snmp_query_graph.graph_template_id from snmp_query_graph where snmp_query_graph.snmp_query_id=" . $snmp_query["id"] . " order by snmp_query_graph.name");
just in the case of this arry are don't loop through it for all the rows only act on the first one.

I think the way to allow for this is to add a foreach after line 658 where we'd loop all the associated graph templates.

In my case I have hundreds of these devices that need graphs created so it's got to be scripted. I could use the command line apps to gen the relevant graphs but that's manual and defeats the point of being able to schedule the dicovery poller unless one was to write a "auto_gen_missing_graphs" plugin which could be automated too.

Ian
ripperza
Posts: 14
Joined: Thu Aug 02, 2012 9:09 am

Re: Discovery 1.5 - autocreate graphs not working as expecte

Post by ripperza »

As an aside thought, if I was going to do the graph creation from the command line scripts then it would be useful to have a options check box to allow for disabling the creation of any graphs, just add the device and detect the Host Template.

And while on opions if you were to add the function to auto_create all assiciated graphs templates of a data query (very useful) then it would be best to have a check box allowing a user to choose the current functionality or allow "create all"
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest