Cacti / plugin_syslog

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

Cacti log shows syslog error when setting the "Re-Alert Cycle" in Alert Rules settings. #132

Closed simonpunk closed 3 years ago

simonpunk commented 4 years ago

Environments: OS: ubuntu server 20.04 Cacti version: 1.2.12

Issue: cacti log shows syslog error when setting the "Re-Alert Cycle" in Alert Rules settings.

2020-06-10 10:50:03 - CMDPHP PHP ERROR NOTICE Backtrace: (/plugins/syslog/syslog_alerts.php[64]:syslog_action_edit(), /plugins/syslog/syslog_alerts.php[443]:get_repeat_array(), /plugins/syslog/syslog_alerts.php[394]:CactiErrorHandler())

2020-06-10 10:50:03 - ERROR PHP NOTICE in Plugin 'syslog': Undefined variable: repeat_end in file: /opt/cacti/plugins/syslog/syslog_alerts.php on line: 394

I just look around the code:

        if ($alert_retention != '' && $alert_retention > 0 && $alert_retention < 365) {
                $repeat_end = ($alert_retention * 24 * 60 * $multiplier) / 5;
        }

        if ($repeat_end) {
                foreach ($repeatarray as $i => $value) {
                        if ($i > $repeat_end) {
                                unset($repeatarray[$i]);
                        }
                }
        }

The $repeat_end is not defined when the first if clause is false, maybe '$alert_retention < 365' should be "$alert_retention <= 365", I am not sure, but doing this can eliminate the error.

However, it didn't affect sending alert email with changing different Re-Alert Cycle even this error pops up.