SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL synta

Hi,

We have over 50 alerts setup within our environment, however 2 of the alerts have started to produce constant event logs for a similar error advising of a syntax error or access violation. No chance have been made to have caused these errors.

EXAMPLE 1: The syntax has been taken from the LibreNMS website and has been working well, so I would say the syntax is ok, I could have a access violation, however I am not sure how to fault find, can the support team offer advice?

EXAMPLES BELOW
I have Override SQL - Enabled on these alerts and they are:

EXAMPLE 1: Alerts for Average CPU of all devices over 99%
SELECT *, AVG(processors.process_usage) as cpu_avg FROM WHERE devices.device_id = ? AND devices.device_id = processors.device_id AND ( processors.status = 1 & & (devices.disabled = 0 & & devices.ignore = 0) ) AND ( devices.status = 1 || (devices.disabled = 0 || devices.ignore = 0) ) HAVING AVG(processors.process_usage) > 99

EXAMPLE 2: Alerts for State Sensor Critical of all devices
Error in alert rule State Sensor Critical (12): SQLSTATE[42000]: Syntax error or access violation: 1064 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 ‘!= “Inactive”)’ at line 1 (Connection: mysql, SQL: SELECT * FROM devices,sensors,sensors_to_state_indexes,state_indexes,state_translations WHERE (devices.device_id = 37 AND devices.device_id = sensors.device_id AND sensors.sensor_id = sensors_to_state_indexes.sensor_id AND sensors_to_state_indexes.state_index_id = state_indexes.state_index_id AND state_indexes.state_index_id = state_translations.state_index_id) AND (sensors.sensor_current = state_translations.state_value && state_translations.state_generic_value = 2) = 1 AND (devices.status = 1 && (devices.disabled = 0 && devices.ignore = 0)) = 1 AND sensors.sensor_oid != “.1.3.6.1.4.1.9.9.500.1.1.3.0” AND sensors.sensor_descr != “tftp Status” AND sensors.sensor_descr != “http-file-dist Status” AND sensors.sensor_descr != “ftp Status” AND sensors.sensor_descr != “bloxtools Status” AND (devices.device_id = “.1.3.6.1.4.1.7779.1.1502” AND sensors.sensor_descr = “dhcp status” AND != “Inactive”))

version im using:
|PHP|8.1.2-1ubuntu2.14
|Python|3.10.12
|Database|MariaDB 10.6.12-MariaDB-0ubuntu0.22.04.1

@jag187 This is a new eventlog for LibreNMS to let you know when your alert rules are failing.

Before, they were failing and silently ignored.
Short term fix: disable the rules (this will restore to the previous behavior)
Long term fix: fix your rules.

Bonus tip AND != “Inactive” doesn’t have a column on the left side of the != to compare “Inactive” to.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.