fixed the 'delvd' alert in the 'mail' graph

This commit is contained in:
Jordi Sanfeliu 2013-04-19 13:19:42 +02:00
parent 536eea8f48
commit 302630143a
1 changed files with 10 additions and 8 deletions

View File

@ -110,6 +110,7 @@ sub mail_init {
$config->{mail_hist} = 0; $config->{mail_hist} = 0;
$config->{mail_hist_alert1} = 0; $config->{mail_hist_alert1} = 0;
$config->{mail_hist_alert2} = 0;
push(@{$config->{func_update}}, $package); push(@{$config->{func_update}}, $package);
logger("$myself: Ok") if $debug; logger("$myself: Ok") if $debug;
} }
@ -447,16 +448,17 @@ sub mail_update {
# MAIL alert # MAIL alert
if(lc($mail->{alerts}->{delvd_enabled}) eq "y") { 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; $config->{mail_hist_alert1} = 0;
} else { } else {
if(!$config->{mail_hist_alert1}) { if(!$config->{mail_hist_alert1}) {
$config->{mail_hist_alert1} = time; $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}) { if(-x $mail->{alerts}->{delvd_script}) {
logger("$myself: ALERT: executing script '$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 { } else {
logger("$myself: ERROR: script '$mail->{alerts}->{delvd_script}' doesn't exist or don't has execution permissions."); 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(lc($mail->{alerts}->{mqueued_enabled}) eq "y") {
if(!$mail->{alerts}->{mqueued_threshold} || $queued < $mail->{alerts}->{mqueued_threshold}) { if(!$mail->{alerts}->{mqueued_threshold} || $queued < $mail->{alerts}->{mqueued_threshold}) {
$config->{mail_hist_alert1} = 0; $config->{mail_hist_alert2} = 0;
} else { } else {
if(!$config->{mail_hist_alert1}) { if(!$config->{mail_hist_alert2}) {
$config->{mail_hist_alert1} = time; $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}) { if(-x $mail->{alerts}->{mqueued_script}) {
logger("$myself: ALERT: executing script '$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); system($mail->{alerts}->{mqueued_script} . " " .$mail->{alerts}->{mqueued_timeintvl} . " " . $mail->{alerts}->{mqueued_threshold} . " " . $queued);
} else { } else {
logger("$myself: ERROR: script '$mail->{alerts}->{mqueued_script}' doesn't exist or don't has execution permissions."); 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;
} }
} }
} }