Cacti / plugin_syslog

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

Error when creating an Alert Rules based on program name #220

Closed arno-st closed 6 months ago

arno-st commented 9 months ago

Describe the bug When creating an Alet Rules, based on a program name, and SQL error it prompted emtpy:

Note, we could not process all your actions. Details are below.

The SQL Syntax Entered is invalid. Please correct your SQL.

The Pre-processed SQL is:

To Reproduce 1: create an Alert Rules 2: select Match type as program name 3: enter a program name as displayed on the 'System Logs' page 4 click save

Expected behavior Not an error, just a OK filter saved!

Plugin (please complete the following information):

Desktop (please complete the following information):

arno-st commented 9 months ago

Whe I do a test with hostname is the SQL query is the following: SELECT * FROM `syslog`.`syslog_incoming` WHERE `host_id` = lslmysp11 AND `status` = 100100

I think the problem is the same a program name, you ask for a NAME but the query is based on an ID And You can't have the ID of the host on the 'Syslog Messages Filter' page,

arno-st commented 8 months ago

I got this error when I try to do a rules with mariadb as program name:

12/01/2024 14:00:24 - ERROR PHP ERROR: Uncaught ValueError: PDO::prepare(): Argument #1 ($query) cannot be empty in /usr/share/cacti/lib/database.php:434 Stack trace: #0 /usr/share/cacti/lib/database.php(434): PDO->prepare() #1 /usr/share/cacti/lib/database.php(727): db_execute_prepared() #2 /usr/share/cacti/plugins/syslog/database.php(167): db_fetch_assoc_prepared() #3 /usr/share/cacti/plugins/syslog/syslog_alerts.php(306): syslog_db_fetch_assoc_prepared() #4 /usr/share/cacti/plugins/syslog/syslog_alerts.php(87): api_syslog_alert_save() #5 /usr/share/cacti/plugins/syslog/syslog_alerts.php(46): form_save() #6 {main} thrown in file: /usr/share/cacti/lib/database.php on line: 434
12/01/2024 14:00:24 - CMDPHP PHP ERROR Backtrace:  (CactiShutdownHandler())

Anyone have any clue ?

TheWitness commented 8 months ago

Are you running the latest version?

TheWitness commented 8 months ago

Can you attach a screen shot of the Query Edit page?

arno-st commented 8 months ago

I just update the code from the dev repo (still 4.1), and here is the error I get:

29/01/2024 08:26:30 - CMDPHP PHP ERROR Backtrace:  (CactiShutdownHandler())
--
29/01/2024 08:26:30 - ERROR PHP ERROR: Uncaught ValueError:  PDO::prepare(): Argument #1 ($query) cannot be empty in  /usr/share/cacti/lib/database.php:434 Stack trace: #0  /usr/share/cacti/lib/database.php(434): PDO->prepare() #1  /usr/share/cacti/lib/database.php(727): db_execute_prepared() #2  /usr/share/cacti/plugins/syslog/database.php(167):  db_fetch_assoc_prepared() #3  /usr/share/cacti/plugins/syslog/syslog_alerts.php(306):  syslog_db_fetch_assoc_prepared() #4  /usr/share/cacti/plugins/syslog/syslog_alerts.php(87):  api_syslog_alert_save() #5  /usr/share/cacti/plugins/syslog/syslog_alerts.php(46): form_save() #6  {main} thrown in file: /usr/share/cacti/lib/database.php on line: 434

Edit syslog alert

TheWitness commented 8 months ago

That screen shot helps.

TheWitness commented 6 months ago

@arno-st , this is fixed now.