@@ -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+
351403function 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