Skip to content

Commit 4f3a022

Browse files
committed
Resolving Issue #99
Re-Alert Cycle (Alert Rules) is wrong in case of 1 minute poller interval
1 parent 175f661 commit 4f3a022

2 files changed

Lines changed: 54 additions & 34 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ The sylog plugin has been in development for well over a decade with increasing
8282
* issue#102: Syslog statistics filter problem - select program
8383
* issue#101: Alert rule SQL Expression not working as expected
8484
* issue#100: Fix odd/even classes generation in report
85+
* issue#99: Re-Alert Cycle (Alert Rules) is wrong in case of 1 minute poller interval
8586
* issue#96: Syslog filtering does not work with some international characters
8687
* issue#87: Program data is not sync with syslog_incoming under PHP 7.2
8788

syslog_alerts.php

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,58 @@ function syslog_get_alert_records(&$sql_where, $rows) {
348348
return syslog_db_fetch_assoc($query_string);
349349
}
350350

351+
function get_repeat_array() {
352+
$poller_interval = read_config_option('poller_interval');
353+
354+
$multiplier = 300 / $poller_interval;
355+
356+
$repeatarray = array(
357+
$multiplier * 0 => __('Not Set', 'syslog'),
358+
);
359+
360+
if ($multiplier > 1) {
361+
$repeatarray += array(
362+
round($multiplier / 5,0) => __('1 Minute', 'syslog'),
363+
);
364+
}
365+
366+
$repeatarray += array(
367+
$multiplier * 1 => __('%d Minutes', 5, 'syslog'),
368+
$multiplier * 2 => __('%d Minutes', 10, 'syslog'),
369+
$multiplier * 3 => __('%d Minutes', 15, 'syslog'),
370+
$multiplier * 4 => __('%d Minutes', 20, 'syslog'),
371+
$multiplier * 6 => __('%d Minutes', 30, 'syslog'),
372+
$multiplier * 8 => __('%d Minutes', 45, 'syslog'),
373+
$multiplier * 12 => __('%d Hour', 1, 'syslog'),
374+
$multiplier * 24 => __('%d Hours', 2, 'syslog'),
375+
$multiplier * 36 => __('%d Hours', 3, 'syslog'),
376+
$multiplier * 48 => __('%d Hours', 4, 'syslog'),
377+
$multiplier * 72 => __('%d Hours', 6, 'syslog'),
378+
$multiplier * 96 => __('%d Hours', 8, 'syslog'),
379+
$multiplier * 144 => __('%d Hours', 12, 'syslog'),
380+
$multiplier * 288 => __('%d Day', 1, 'syslog'),
381+
$multiplier * 576 => __('%d Days', 2, 'syslog'),
382+
$multiplier * 2016 => __('%d Week', 1, 'syslog'),
383+
$multiplier * 4032 => __('%d Weeks', 2, 'syslog'),
384+
$multiplier * 8640 => __('1 Month', 'syslog')
385+
);
386+
387+
$alert_retention = read_config_option('syslog_alert_retention');
388+
if ($alert_retention != '' && $alert_retention > 0 && $alert_retention < 365) {
389+
$repeat_end = ($alert_retention * 24 * 60 * $multiplier) / 5;
390+
}
391+
392+
if ($repeat_end) {
393+
foreach ($repeatarray as $i => $value) {
394+
if ($i > $repeat_end) {
395+
unset($repeatarray[$i]);
396+
}
397+
}
398+
}
399+
400+
return $repeatarray;
401+
}
402+
351403
function syslog_action_edit() {
352404
global $message_types, $severities;
353405

@@ -384,40 +436,7 @@ function syslog_action_edit() {
384436
$alert['name'] = __('New Alert Rule', 'syslog');
385437
}
386438

387-
$alert_retention = read_config_option('syslog_alert_retention');
388-
if ($alert_retention != '' && $alert_retention > 0 && $alert_retention < 365) {
389-
$repeat_end = ($alert_retention * 24 * 60) / 5;
390-
}
391-
392-
$repeatarray = array(
393-
0 => __('Not Set', 'syslog'),
394-
1 => __('%d Minutes', 5, 'syslog'),
395-
2 => __('%d Minutes', 10, 'syslog'),
396-
3 => __('%d Minutes', 15, 'syslog'),
397-
4 => __('%d Minutes', 20, 'syslog'),
398-
6 => __('%d Minutes', 30, 'syslog'),
399-
8 => __('%d Minutes', 45, 'syslog'),
400-
12 => __('%d Hour', 1, 'syslog'),
401-
24 => __('%d Hours', 2, 'syslog'),
402-
36 => __('%d Hours', 3, 'syslog'),
403-
48 => __('%d Hours', 4, 'syslog'),
404-
72 => __('%d Hours', 6, 'syslog'),
405-
96 => __('%d Hours', 8, 'syslog'),
406-
144 => __('%d Hours', 12, 'syslog'),
407-
288 => __('%d Day', 1, 'syslog'),
408-
576 => __('%d Days', 2, 'syslog'),
409-
2016 => __('%d Week', 1, 'syslog'),
410-
4032 => __('%d Weeks', 2, 'syslog'),
411-
8640 => __('Month', 'syslog')
412-
);
413-
414-
if ($repeat_end) {
415-
foreach ($repeatarray as $i => $value) {
416-
if ($i > $repeat_end) {
417-
unset($repeatarray[$i]);
418-
}
419-
}
420-
}
439+
$repeatarray = get_repeat_array();
421440

422441
$fields_syslog_alert_edit = array(
423442
'spacer0' => array(

0 commit comments

Comments
 (0)