Skip to content

Commit

Permalink
Fixing #220 - Program Queries fail
Browse files Browse the repository at this point in the history
* Error when creating an Alert Rules based on program name
* Preparing for release 4.2
  • Loading branch information
TheWitness committed Mar 17, 2024
1 parent 35fee95 commit 55dd42b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

* issue#218: SQL errors when deleting messages

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

* issue#222: PHP Deprecation Errors in PHP 8.2

--- 4.1 ---
Expand Down
2 changes: 1 addition & 1 deletion INFO
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; +-------------------------------------------------------------------------+
; | Copyright (C) 2004-2023 The Cacti Group |
; | Copyright (C) 2004-2024 The Cacti Group |
; | |
; | This program is free software; you can redistribute it and/or |
; | modify it under the terms of the GNU General Public License |
Expand Down
7 changes: 4 additions & 3 deletions config.php.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2023 The Cacti Group |
| Copyright (C) 2004-2024 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
Expand Down Expand Up @@ -64,10 +64,11 @@ if (!$use_cacti_db) {
//$syslog_install_options['id'] = 'syslog';

/* field in the incomming table */
$syslog_incoming_config['timeField'] = 'logtime';
$syslog_incoming_config['priorityField'] = 'priority_id';
$syslog_incoming_config['facilityField'] = 'facility_id';
$syslog_incoming_config['hostField'] = 'host_id';
$syslog_incoming_config['programField'] = 'program';
$syslog_incoming_config['timeField'] = 'logtime';
$syslog_incoming_config['hostField'] = 'host';
$syslog_incoming_config['textField'] = 'message';
$syslog_incoming_config['id'] = 'seq';

12 changes: 12 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,10 @@ function syslog_process_alert($alert, $sql, $params, $count, $hostname = '') {
function syslog_get_alert_sql(&$alert, $uniqueID) {
global $syslogdb_default, $syslog_incoming_config;

if (!isset($syslog_incoming_config['programField'])) {
$syslog_incoming_config['programField'] = 'program';
}

$params = array();
$sql = '';

Expand Down Expand Up @@ -1653,6 +1657,14 @@ function syslog_get_alert_sql(&$alert, $uniqueID) {
WHERE `' . $syslog_incoming_config['hostField'] . '` = ?
AND `status` = ?' . $uniqueID;

$params[] = $alert['message'];
$params[] = $uniqueID;
} elseif ($alert['type'] == 'program') {
$sql = 'SELECT *
FROM `' . $syslogdb_default . '`.`syslog_incoming`
WHERE `' . $syslog_incoming_config['programField'] . '` = ?
AND `status` = ?' . $uniqueID;

$params[] = $alert['message'];
$params[] = $uniqueID;
} elseif ($alert['type'] == 'sql') {
Expand Down

0 comments on commit 55dd42b

Please sign in to comment.