From 302630143a4c3e22203faed76f62029925bbe037 Mon Sep 17 00:00:00 2001 From: Jordi Sanfeliu Date: Fri, 19 Apr 2013 13:19:42 +0200 Subject: [PATCH] fixed the 'delvd' alert in the 'mail' graph --- lib/mail.pm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/mail.pm b/lib/mail.pm index 209d94e..6591126 100644 --- a/lib/mail.pm +++ b/lib/mail.pm @@ -110,6 +110,7 @@ sub mail_init { $config->{mail_hist} = 0; $config->{mail_hist_alert1} = 0; + $config->{mail_hist_alert2} = 0; push(@{$config->{func_update}}, $package); logger("$myself: Ok") if $debug; } @@ -447,16 +448,17 @@ sub mail_update { # MAIL alert if(lc($mail->{alerts}->{delvd_enabled}) eq "y") { - if(!$mail->{alerts}->{delvd_threshold} || $delvd < $mail->{alerts}->{delvd_threshold}) { + my $val = int($mta[3] * 60 + 0.5); + if(!$mail->{alerts}->{delvd_threshold} || $val < $mail->{alerts}->{delvd_threshold}) { $config->{mail_hist_alert1} = 0; } else { if(!$config->{mail_hist_alert1}) { $config->{mail_hist_alert1} = time; } - if($config->{mail_hist_alert1} > 0 && (time - $config->{mail_hist_alert1}) > $mail->{alerts}->{delvd_timeintvl}) { + if($config->{mail_hist_alert1} > 0 && (time - $config->{mail_hist_alert1}) >= $mail->{alerts}->{delvd_timeintvl}) { if(-x $mail->{alerts}->{delvd_script}) { logger("$myself: ALERT: executing script '$mail->{alerts}->{delvd_script}'."); - system($mail->{alerts}->{delvd_script} . " " .$mail->{alerts}->{delvd_timeintvl} . " " . $mail->{alerts}->{delvd_threshold} . " " . $delvd); + system($mail->{alerts}->{delvd_script} . " " .$mail->{alerts}->{delvd_timeintvl} . " " . $mail->{alerts}->{delvd_threshold} . " " . $val); } else { logger("$myself: ERROR: script '$mail->{alerts}->{delvd_script}' doesn't exist or don't has execution permissions."); } @@ -466,19 +468,19 @@ sub mail_update { } if(lc($mail->{alerts}->{mqueued_enabled}) eq "y") { if(!$mail->{alerts}->{mqueued_threshold} || $queued < $mail->{alerts}->{mqueued_threshold}) { - $config->{mail_hist_alert1} = 0; + $config->{mail_hist_alert2} = 0; } else { - if(!$config->{mail_hist_alert1}) { - $config->{mail_hist_alert1} = time; + if(!$config->{mail_hist_alert2}) { + $config->{mail_hist_alert2} = time; } - if($config->{mail_hist_alert1} > 0 && (time - $config->{mail_hist_alert1}) > $mail->{alerts}->{mqueued_timeintvl}) { + if($config->{mail_hist_alert2} > 0 && (time - $config->{mail_hist_alert2}) > $mail->{alerts}->{mqueued_timeintvl}) { if(-x $mail->{alerts}->{mqueued_script}) { logger("$myself: ALERT: executing script '$mail->{alerts}->{mqueued_script}'."); system($mail->{alerts}->{mqueued_script} . " " .$mail->{alerts}->{mqueued_timeintvl} . " " . $mail->{alerts}->{mqueued_threshold} . " " . $queued); } else { logger("$myself: ERROR: script '$mail->{alerts}->{mqueued_script}' doesn't exist or don't has execution permissions."); } - $config->{mail_hist_alert1} = time; + $config->{mail_hist_alert2} = time; } } }