description:
If data template has some items that are not graphed, thold create fails with wrong message "Already Exists - No Threshold Created".
file:
plugins/thold/setup.php
function:
thold_data_source_action_execute
problem:
when the data template has an item that is not graphed, then the following sql:
Code: Select all
$rrdlookup = db_fetch_cell("SELECT id
FROM data_template_rrd
WHERE local_data_id=$local_data_id
ORDER BY id
LIMIT 1");
may return an id that is not graphed, that would happen if the first data source item in the list is not graphed.
This subsequent query for a corresponding graph items return nothing:
Code: Select all
$grapharr = db_fetch_row("SELECT local_graph_id, graph_template_id
FROM graph_templates_item
WHERE task_item_id=$rrdlookup
AND local_graph_id<>''
LIMIT 1");
Solution:
replace the $grapharr query with this:
Code: Select all
$grapharr = db_fetch_row("SELECT gti.local_graph_id, gti.graph_template_id
FROM graph_templates_item gti join data_template_rrd dtr on (gti.task_item_id = dtr.id)
WHERE dtr.local_data_id=$local_data_id
AND gti.local_graph_id<>''
LIMIT 1");
I have an index on data_template_rrd table that may (or may not) be helping execution time for the above join:
Code: Select all
create index `data_template_rrd_ash1` on `data_template_rrd` (`id`,`local_data_id`,`data_template_id`)