Cacti / plugin_syslog

Syslog Plugin for Cacti
GNU General Public License v2.0
21 stars 16 forks source link

2bugs on removal filter with SQL expression, but can't find an explanation for it, yet #218

Closed arno-st closed 7 months ago

arno-st commented 7 months ago

Hello, I try to setup a few filter based on SQL command like tht: message REGEXP 'LINEPROTO-5-UPDOWN|LINK-3-UPDOWN'

Where I want all message containing one of this message to be transferred. When I do so I got the following to error messages, and the SQL query related to it:

01/12/2023 14:50:59 - SYSLOG error mysql1: INSERT INTO `syslog`.`syslog_removed` (logtime, priority_id, facility_id, program_id, host_id, message) SELECT logtime, priority_id, facility_id, host_id, message FROM `syslog`.`syslog` WHERE message REGEXP 'LINEPROTO-5-UPDOWN|LINK-3-UPDOWN'
01/12/2023 14:50:59 - CMDPHP ERROR: A DB Exec Failed!, Error: Column count doesn't match value count at row 1
01/12/2023 14:50:59 - CMDPHP SQL Backtrace: (/plugins/syslog/syslog_removal.php[61]:form_actions(), /plugins/syslog/syslog_removal.php[140]:api_syslog_removal_reprocess(), /plugins/syslog/syslog_removal.php[333]:syslog_remove_items(), /plugins/syslog/functions.php[619]:syslog_db_execute(), /plugins/syslog/database.php[69]:db_execute(), /lib/database.php[362]:db_execute_prepared())

01/12/2023 14:50:59 - SYSLOG error mysql: DELETE syslog FROM `syslog`.`syslog` INNER JOIN `syslog`.`syslog_facilities` AS sf ON sf.facility_id = si.facility_id INNER JOIN `syslog`.`syslog_priorities` AS sp ON sp.priority_id = si.priority_id INNER JOIN `syslog`.`syslog_programs` AS spg ON spg.program = si.program INNER JOIN `syslog`.`syslog_hosts` AS sh ON sh.host = si.host WHERE (message REGEXP 'LINEPROTO-5-UPDOWN|LINK-3-UPDOWN')
01/12/2023 14:50:59 - CMDPHP ERROR: A DB Exec Failed!, Error: Unknown column 'si.facility_id' in 'on clause'
01/12/2023 14:50:59 - CMDPHP SQL Backtrace: (/plugins/syslog/syslog_removal.php[61]:form_actions(), /plugins/syslog/syslog_removal.php[140]:api_syslog_removal_reprocess(), /plugins/syslog/syslog_removal.php[333]:syslog_remove_items(), /plugins/syslog/functions.php[624]:syslog_db_execute(), /plugins/syslog/database.php[69]:db_execute(), /lib/database.php[362]:db_execute_prepared())

The 'SYSLOG error mysql1' and 'SYSLOG error mysql' is a log I add on function.php line 618 and 623

Maybe I do the SQL command in a bad way, I don't understand the error message on 'SYSLOG error mysql1' As for the 'SYSLOG error mysql' somehow the table alias si for the facility_id is missing

xmacan commented 7 months ago

Which plugin version? Or actual develop branch version?

arno-st commented 7 months ago

The latest develop branch. That's my command: git clone -b develop https://github.com/Cacti/plugin_syslog.git

It's indicated as version 4.1 last update was the 6 December.

xmacan commented 7 months ago

Please try this fix

arno-st commented 7 months ago

Yes good job, it's working as expected now. Thanks for your help