diff --git a/README.md b/README.md index 99c6e6b..dc83c1c 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,7 @@ that. --- develop --- * issue#122: Apply Cacti#3191 for XSS exposure (CVE-2020-7106) +* issue#128:The syslog alert email is not sent if the Reporting Method is set to threshold. --- 2.9 --- diff --git a/syslog_process.php b/syslog_process.php index a2a6af1..0eb1ddb 100644 --- a/syslog_process.php +++ b/syslog_process.php @@ -451,6 +451,33 @@ $alertm .= "-----------------------------------------------\n\n"; if ($alert['method'] == 1) { + //The syslog_sendemail should be called prior to syslog_log_alert, otherwise, the $found always larger than 0 + if ($alertm != '') { + $resend = true; + if ($alert['repeat_alert'] > 0) { + $found = syslog_db_fetch_cell('SELECT count(*) + FROM syslog_logs + WHERE alert_id=' . $alert['id'] . " + AND logtime>'$date'"); + + if ($found) $resend = false; + } + + if ($resend) { + syslog_sendemail(trim($alert['email']), $from, __esc('Event Alert - %s', $alert['name'], 'syslog'), ($html ? $htmlm:$alertm), $smsalert); + + if ($alert['open_ticket'] == 'on' && strlen(read_config_option('syslog_ticket_command'))) { + if (is_executable(read_config_option('syslog_ticket_command'))) { + exec(read_config_option('syslog_ticket_command') . + " --alert-name='" . clean_up_name($alert['name']) . "'" . + " --severity='" . $alert['severity'] . "'" . + " --hostlist='" . implode(',',$hostlist) . "'" . + " --message='" . $alert['message'] . "'"); + } + } + } + } + $sequence = syslog_log_alert($alert['id'], $alert['name'], $alert['severity'], $at[0], sizeof($at), $htmlm, $hostlist); $smsalert = __('Sev:', 'syslog') . $severities[$alert['severity']] . __(', Count:', 'syslog') . sizeof($at) . __(', URL:', 'syslog') . read_config_option('base_url', true) . '/plugins/syslog/syslog.php?tab=current&id=' . $sequence; } @@ -459,32 +486,6 @@ } } } - - if ($alertm != '' && $alert['method'] == 1) { - $resend = true; - if ($alert['repeat_alert'] > 0) { - $found = syslog_db_fetch_cell('SELECT count(*) - FROM syslog_logs - WHERE alert_id=' . $alert['id'] . " - AND logtime>'$date'"); - - if ($found) $resend = false; - } - - if ($resend) { - syslog_sendemail(trim($alert['email']), $from, __esc('Event Alert - %s', $alert['name'], 'syslog'), ($html ? $htmlm:$alertm), $smsalert); - - if ($alert['open_ticket'] == 'on' && strlen(read_config_option('syslog_ticket_command'))) { - if (is_executable(read_config_option('syslog_ticket_command'))) { - exec(read_config_option('syslog_ticket_command') . - " --alert-name='" . clean_up_name($alert['name']) . "'" . - " --severity='" . $alert['severity'] . "'" . - " --hostlist='" . implode(',',$hostlist) . "'" . - " --message='" . $alert['message'] . "'"); - } - } - } - } } }