Cacti / plugin_syslog

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

Error when removing record based on syslog removal rule #217

Closed arno-st closed 5 months ago

arno-st commented 7 months ago

Hello, When you create a rule to remove messages from a 'host', there is a missing precision on a SQL query, that cause an error.

The following message is the error:

28/11/2023 09:47:16 - CMDPHP SQL Backtrace: (/plugins/syslog/syslog_process.php[191]: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())
28/11/2023 09:47:16 - CMDPHP ERROR: A DB Exec Failed!, Error: Column 'host' in where clause is ambiguous

The following is just a print of the event during the insert who provoke the previous error message.

28/11/2023 09:47:16 - SYSLOG error mysql: INSERT INTO `syslog`.`syslog_removed` (logtime, priority_id, facility_id, program_id, host_id, message) SELECT logtime, priority_id, facility_id, program_id, host_id, message FROM (SELECT si.logtime, si.priority_id, si.facility_id, spg.program_id, sh.host_id, si.message FROM `syslog`.`syslog_incoming` AS si 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 host = 'lslcacp02' AND `status` = 46 ) AS merge

And the error come on line 418 of function.php where the 'host' after the WHERE should be 'si.host' instead of just 'host' It's on the current version 4.1, dev branch.

arno-st commented 7 months ago

Resolved in the same time as #218

arno-st commented 7 months ago

Damn sorry no this issue is not resolve with the latest dev version

TheWitness commented 5 months ago

It should be all set now.

TheWitness commented 5 months ago

Fixed here: https://github.com/Cacti/plugin_syslog/commit/cce66db044b92a71deee3e919463c63dba329497

arno-st commented 5 months ago

I'm gona close this one, I think it's ok now

TheWitness commented 5 months ago

Cool thanks!