Script data query - graphs not working

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

Moderators: Developers, Moderators

Post Reply
sauron
Posts: 42
Joined: Wed Jul 05, 2006 8:24 am
Location: London, UK

Script data query - graphs not working

Post by sauron »

I'm trying to graph output from Zeus load balancers, and I've got a script data query which retrieves information about bac end nodes served by the ZXTM software.

I've written a perl script which accepts "index", "query", and "get" arguments, and produces what I think is the correct output. I've also put together an appropriate XML file and I can run the data query, with Cacti giving the right number of rows as the output.

Following on from that, I've built a data template to record all the data, and a graph template (first of two I intended to create). All went fine until I got as far as trying to actually create the graphs. I selected the items from the list that I wanted to graph, and hit create. I then got an error message sent back to the browser saying:-

Code: Select all

Notice: Undefined index: sgg_14 in /usr/share/cacti/site/graphs_new.php on line 71

Warning: Cannot modify header information - headers already sent by (output started at /usr/share/cacti/site/graphs_new.php:71) in /usr/share/cacti/site/graphs_new.php on line 322
The log show that the SQL statement failed as the graph_template_id is null in all the statements Cacti tried to run:-

Code: Select all

07/31/2006 04:24:08 PM - CMDPHP: Poller[0] ERROR: SQL Cell Failed "select graph_template_id from snmp_query_graph where id="
07/31/2006 04:24:08 PM - CMDPHP: Poller[0] ERROR: SQL Assoc Failed "select    data_template.name as data_template_name,    data_template_rrd.data_source_name,    data_template_data.*    from (data_te
mplate, data_template_rrd, data_template_data, graph_templates_item)    where graph_templates_item.task_item_id=data_template_rrd.id    and data_template_rrd.data_template_id=data_template.id    and 
data_template_data.data_template_id=data_template.id    and data_template_rrd.local_data_id=0    and data_template_data.local_data_id=0    and graph_templates_item.local_graph_id=0    and graph_templ
ates_item.graph_template_id=    group by data_template.id    order by data_template.name"
07/31/2006 04:24:08 PM - CMDPHP: Poller[0] ERROR: SQL Row Failed "select    graph_templates.name as graph_template_name,    graph_templates_graph.*    from (graph_templates, graph_templates_graph)   
 where graph_templates.id=graph_templates_graph.graph_template_id    and graph_templates.id=    and graph_templates_graph.local_graph_id=0"
07/31/2006 04:24:08 PM - CMDPHP: Poller[0] ERROR: SQL Cell Failed "select name from graph_templates where id="
07/31/2006 04:24:08 PM - CMDPHP: Poller[0] ERROR: SQL Row Failed "select * from graph_templates_graph where graph_template_id= and local_graph_id=0"
07/31/2006 04:24:08 PM - CMDPHP: Poller[0] ERROR: SQL Assoc Failed "select * from graph_template_input where graph_template_id= order by column_name,name"
07/31/2006 04:24:08 PM - CMDPHP: Poller[0] ERROR: SQL Cell Failed "select graph_template_id from snmp_query_graph where id="
07/31/2006 04:24:08 PM - CMDPHP: Poller[0] ERROR: SQL Exec Failed "update graph_local set graph_template_id= where id=163"
07/31/2006 04:24:08 PM - CMDPHP: Poller[0] ERROR: SQL Row Failed "select * from graph_templates_graph where local_graph_id=0 and graph_template_id="
07/31/2006 04:24:08 PM - CMDPHP: Poller[0] ERROR: SQL Assoc Failed "select * from graph_templates_item where local_graph_id=0 and graph_template_id= order by sequence"
07/31/2006 04:24:08 PM - CMDPHP: Poller[0] ERROR: SQL Assoc Failed "select  graph_template_input.column_name,  graph_template_input_defs.graph_template_item_id  from (graph_template_input,graph_templ
ate_input_defs)  where graph_template_input.id=graph_template_input_defs.graph_template_input_id  and graph_template_input.graph_template_id="
07/31/2006 04:24:08 PM - CMDPHP: Poller[0] ERROR: SQL Assoc Failed "select text,field_name from snmp_query_graph_sv where snmp_query_graph_id= order by sequence"
07/31/2006 04:24:08 PM - CMDPHP: Poller[0] ERROR: SQL Assoc Failed "select  data_template.id,  data_template.name,  data_template_rrd.data_source_name  from (data_template, data_template_rrd, graph_t
emplates_item)  where graph_templates_item.task_item_id=data_template_rrd.id  and data_template_rrd.data_template_id=data_template.id  and data_template_rrd.local_data_id=0  and graph_templates_item.
local_graph_id=0  and graph_templates_item.graph_template_id=  group by data_template.id  order by data_template.name"
07/31/2006 04:24:08 PM - CMDPHP: Poller[0] ERROR: SQL Assoc Failed "select  graph_templates_item.id,  data_template_rrd.id as data_template_rrd_id,  data_template_rrd.data_template_id  from (graph_te
mplates_item,data_template_rrd)  where graph_templates_item.task_item_id=data_template_rrd.id  and graph_templates_item.graph_template_id=  and local_graph_id=0  and task_item_id>0"
07/31/2006 04:24:08 PM - CMDPHP: Poller[0] ERROR: SQL Assoc Failed "select  data_input_fields.type_code,  data_input_data.value  from (data_input_fields,data_input_data)  where data_input_fields.id=d
ata_input_data.data_input_field_id  and data_input_data.data_template_data_id=  and (data_input_fields.type_code='index_type' or data_input_fields.type_code='index_value' or data_input_fields.type_co
de='output_type')"
Any ideas on what I've done wrong would be appreciated.....

Mike[/code]
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

1) have you fully patched cacti?
2) Do you only get that graph error 'Cannot modify header information ' only when using your template or with others too? Could possibly be a permissions issue with that (at least thats what that error typically is for Windows).
sauron
Posts: 42
Joined: Wed Jul 05, 2006 8:24 am
Location: London, UK

Post by sauron »

The Cacti I'm running is 0.86h with all the patches applied, so it should be up to date.

I've not as yet seen that error with any other templates, apart from the one I've just created. As far as permissions go - my XML file was in fact wrong, but was readable by the cacti user, so that shouldn't have mattered.

The graphs have actually been created, but they're not showing up in the graph management console, and in the list they're titled "Graph Template: (No Graph Template)". I guess I'll have to manually delete them from the database.

When I try to create the graph, the HTTP request contains the following parameters:-

cg_g=0
sg_14_cb4e166c027db1b7016d26a856f70b7f=on
save_component_graph=1
host_id=14
host_template_id=13
action=save
x=49
y=12

which is interesting, as the error message referred to sgg_14 being undefined, and the second param above looks similar - but I'm not quite sure what it's doing there yet. The rest are obvious, but the first two aren't...
sauron
Posts: 42
Joined: Wed Jul 05, 2006 8:24 am
Location: London, UK

Post by sauron »

Following up on this, I've now compared it with some working data queries, and the problem seems to stem from a missing form parameter in the POST request. There should be an sgg_* parameter, but isn't - there's just the sg_* one.

When I look at the form, the sgg_* parameter is tagged to the drop down dialog captioned "Select a graph type" under the list of graphable items. On a working data query, this is there, but on mine, it's absent. When I choose the device, and click on the link to create new graphs, I see the output of the data query, but the "Select a graph type" isn't defined.

I've defined a data template and a graph template for this, but for some reason Cacti doesn't know which graph template it should be using. Any idea on what I could have missed when setting these up?

Thanks,

Mike
sauron
Posts: 42
Joined: Wed Jul 05, 2006 8:24 am
Location: London, UK

Post by sauron »

And following up again, the problem was that I hadn't gone back after creating the graph template and associated it with the data query. The lack of that meant that the form field referencing it was missing from the page, and so the PHP code blew up with the undefined index error.

I still haven't got it working though - I've added graphs but there's no data associated with them. Looking at the log, the poll is definitely retrieving data from the scrip, but it doesn't appear to be putting it into an RRD (or in fact doing anything with it. This a log file extract:-

Code: Select all

08/02/2006 12:35:24 PM - CACTID: Poller[0] DEBUG: MySQL Insert ID '52': 'INSERT INTO poller_output (local_data_id,rrd_name,time,output) VALUES (242,'','2006-08-02 12:35:02','totalBytesIn:297551030177 totalBytesOut:7297202892065'),(245,'bytesfromnode','2006-08-02 12:35:02','10.0.0.26.80:1283785109614'),(246,'bytesfromnode','2006-08-02  12:35:02','10.0.1.26.80:531481120259'),(245,'bytestonode','2006-08-02 12:35:02','10.0.0.26.80:46501656373'),(246,'bytestonode','2006-08-02 12:35:02','10.0.1.26.80:20037068793'),(245,'conns','2006-08-02 12:35:02','10.0.0.26.80:113837298'),(246,'conns','2006-08-02 12:35:02','10.0.1.26.80:49442336'),(245,'failures','2006-08-02 12:35:02','10.0.0.26.80:51'),(246,'failures','2006-08-02 12:35:02','10.0.1.26.80:129'),(245,'new_conns','2006-08-02 12:35:02','10.0.0.26.80:113837724'),(246,'new_conns','2006-08-02 12:35:02','10.0.1.26.80:49442638'),(245,'pool_conns','2006-08-02 12:35:02','10.0.0.26.80:0'),(246,'pool_conns','2006-08-02 12:35:02','10.
0.1.26.80:0')'
08/02/2006 12:35:24 PM - CACTID: Poller[0] DEBUG: MySQL Insert ID '52': OK
The totlaBytesIn and totalBytes out figures, which are from a different script, work fine. I see them being inserted into the RRD a few lines later. The rest don't work properly - there's no sign that Cacti is actually doing anything with them.

RRDtool show that the rrd files have been created, but there's no data in them.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please try to follow http://forums.cacti.net/viewtopic.php?t=15136 or post, if it does not help (so I'll try to extend it)
Reinhard
sauron
Posts: 42
Joined: Wed Jul 05, 2006 8:24 am
Location: London, UK

Post by sauron »

That guide walks through the data gathering steps, but doesn't really help for me. I already know the problem is between steps 2 and 3 - I see cactid getting the data, and I see it being inserted into the poller_output table OK. It just never gets to step 3 - there are no RRD update statements, and I don't know why not at the moment....
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Hm, the poller should fetch all data from poller_output later to put it into rrd files. So please pm TheWitness, perhaps he can help
Reinhard
sauron
Posts: 42
Joined: Wed Jul 05, 2006 8:24 am
Location: London, UK

Post by sauron »

I've now got it working. The problem was that I'd misunderstood the required output from the script, so was returning data to get queries in the form of node:value, which wasn't acceptable to Cacti and was getting dropped.

Looking through poller.php made it clear what Cacti was actually expecting, and as soon as I changed the script output it started working.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests