Cacti / plugin_thold

Thold Plugin for Cacti
GNU General Public License v2.0
61 stars 60 forks source link

Filter selection SQL error #612

Closed unka65 closed 10 months ago

unka65 commented 10 months ago

It was a pleasant surprise to find the enhancements and fixes. In testing the develop version as of a few days ago, I noted something minor while debugging another issue with RPN expressions.

On the Thold tab (/plugins/thold/thold_graph.php) Thresholds list, if Status All is selected (nothing added to the WHERE clause) and any other search selections are specified, the list is empty. The log has an SQL error.

CMDPHP ERROR: A DB Row Failed!, Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BYname_cacheASC LIMIT 0,25' at line 1

In debugging it, the WHERE clause has the following (missing the closing parenthesis).

WHERE ( td.host_id = 83

If a different status is selected such as Breached so that the WHERE clause is populated before adding the other selections, the WHERE clause has the following and returns a list.

WHERE ((td.thold_enabled = "on" AND td.thold_per_enabled = "on") AND (td.thold_alert != 0 OR td.bl_alert > 0)) AND td.host_id = 83

I worked around it in function tholds() by not adding the opening parenthesis for each of the other selections if $sql_where is empty.

TheWitness commented 10 months ago

Thanks for reporting. Will get to it this weekend.

TheWitness commented 10 months ago

Fixed.