Cacti / plugin_syslog

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

When removing a rule, wrong database connection is used #154

Closed bmfmancini closed 3 years ago

bmfmancini commented 3 years ago

Hey Guys,

I found that when you make a removal rule the following backtrace and sql error comes up

2021-06-11 14:41:47 - CMDPHP SQL Backtrace: (/plugins/syslog/syslog_removal.php[57]:form_actions(), /plugins/syslog/syslog_removal.php[136]:api_syslog_removal_reprocess(), /plugins/syslog/syslog_removal.php[342]:db_fetch_cell_prepared(), /lib/database.php[427]:db_execute_prepared())
2021-06-11 14:41:47 - CMDPHP ERROR: A DB Cell Failed!, Error: Table 'cacti.syslog_remove' doesn't exist
2021-06-11 14:41:23 - CMDPHP SQL Backtrace: (/plugins/syslog/syslog_removal.php[57]:form_actions(), /plugins/syslog/syslog_removal.php[136]:api_syslog_removal_reprocess(), /plugins/syslog/syslog_removal.php[342]:db_fetch_cell_prepared(), /lib/database.php[427]:db_execute_prepared())
2021-06-11 14:41:23 - CMDPHP ERROR: A DB Cell Failed!, Error: Table 'cacti.syslog_remove' doesn't exist

No issue with functionality while looking deeper into this the plugin attempts to go to cacti.syslog_removal which doesn't exist I am using a separate DB and the table does exist in that DB I don't see in the code where it may be hard coded to use the Cacti DB

I see the removal rule populated in the syslog db and the rule works as expected

netniV commented 3 years ago

It could be that the syslog database id wasn't passed with the query. Since it is in a separate db, it will not use the default conn id.

netniV commented 3 years ago

Or rather that it's using the play db_fetch functions rather than the syslog_fetch ones.

bmfmancini commented 3 years ago

Cool! good catch I will test it out

bmfmancini commented 3 years ago

Looks good !