THOLD - fails for DS that has non-graphed DS items

Support questions about the Threshold plugin

Moderators: Developers, Moderators

Post Reply
durotan
Posts: 4
Joined: Fri Aug 03, 2012 1:08 pm

THOLD - fails for DS that has non-graphed DS items

Post by durotan »

Not sure if this issue is already addressed elsewhere in the forum but here is the problem I had and the way I solved it:

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");
Result is that thold creation fails with wrong message ("Already Exists").

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");
Note:
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`)
Durotan.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: THOLD - fails for DS that has non-graphed DS items

Post by gandalf »

Moved to correct forum
R.
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests