updated alert configuration

This commit is contained in:
Jordi Sanfeliu 2013-01-23 12:06:19 +01:00
parent 8e177c6d3f
commit a248a733d9
4 changed files with 22 additions and 11 deletions

View File

@ -16,9 +16,9 @@ current_value=$3
(
cat << EOF
Message from hostname '$HOSTNAME'
Message from hostname '$HOSTNAME'.
This system is reaching/exceeding the defined '$ALERT_THRESHOLD' threshold value during the last '$ALERT_TIMEINTVL' seconds.
This system is reaching/exceeding the defined threshold value ($ALERT_THRESHOLD') during the last '$ALERT_TIMEINTVL' seconds.
The current value is: $current_value

View File

@ -253,7 +253,7 @@ sub fs_init {
}
# check dependencies
if(lc($fs->{alerts}->{enabled}) eq "y") {
if(lc($fs->{alerts}->{rootfs_enabled}) eq "y") {
if(! -x $fs->{alerts}->{rootfs_script}) {
logger("$myself: ERROR: script '$fs->{alerts}->{rootfs_script}' doesn't exist or don't has execution permissions.");
}
@ -369,7 +369,7 @@ sub fs_update {
$use = ($used * 100) / ($used + $free);
# FS alert
if($f eq "/" && lc($fs->{alerts}->{enabled}) eq "y") {
if($f eq "/" && lc($fs->{alerts}->{rootfs_enabled}) eq "y") {
if(!$fs->{alerts}->{rootfs_threshold} || $use < $fs->{alerts}->{rootfs_threshold}) {
$config->{fs_hist_alert1} = 0;
} else {
@ -378,6 +378,7 @@ sub fs_update {
}
if($config->{fs_hist_alert1} > 0 && (time - $config->{fs_hist_alert1}) > $fs->{alerts}->{rootfs_timeintvl}) {
if(-x $fs->{alerts}->{rootfs_script}) {
logger("$myself: ALERT: executing script '$fs->{alerts}->{rootfs_script}'.");
system($fs->{alerts}->{rootfs_script} . " " . $fs->{alerts}->{rootfs_timeintvl} . " " . $fs->{alerts}->{rootfs_threshold} . " " . $use);
} else {
logger("$myself: ERROR: script '$fs->{alerts}->{rootfs_script}' doesn't exist or don't has execution permissions.");

View File

@ -98,11 +98,16 @@ sub mail_init {
}
# check dependencies
if(lc($mail->{alerts}->{enabled}) eq "y") {
if(lc($mail->{alerts}->{delvd_enabled}) eq "y") {
if(! -x $mail->{alerts}->{delvd_script}) {
logger("$myself: ERROR: script '$mail->{alerts}->{delvd_script}' doesn't exist or don't has execution permissions.");
}
}
if(lc($mail->{alerts}->{mqueued_enabled}) eq "y") {
if(! -x $mail->{alerts}->{mqueued_script}) {
logger("$myself: ERROR: script '$mail->{alerts}->{mqueued_script}' doesn't exist or don't has execution permissions.");
}
}
$config->{mail_hist} = 0;
$config->{mail_hist_alert1} = 0;
@ -442,7 +447,7 @@ sub mail_update {
}
# MAIL alert
if(lc($mail->{alerts}->{enabled}) eq "y") {
if(lc($mail->{alerts}->{delvd_enabled}) eq "y") {
if(!$mail->{alerts}->{delvd_threshold} || $delvd < $mail->{alerts}->{delvd_threshold}) {
$config->{mail_hist_alert1} = 0;
} else {
@ -451,13 +456,16 @@ sub mail_update {
}
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);
} else {
logger("$myself: ERROR: script '$config->{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.");
}
$config->{mail_hist_alert1} = time;
}
}
}
if(lc($mail->{alerts}->{mqueued_enabled}) eq "y") {
if(!$mail->{alerts}->{mqueued_threshold} || $queued < $mail->{alerts}->{mqueued_threshold}) {
$config->{mail_hist_alert1} = 0;
} else {
@ -466,9 +474,10 @@ sub mail_update {
}
if($config->{mail_hist_alert1} > 0 && (time - $config->{mail_hist_alert1}) > $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 '$config->{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;
}

View File

@ -91,7 +91,7 @@ sub system_init {
}
# check dependencies
if(lc($system->{alerts}->{enabled}) eq "y") {
if(lc($system->{alerts}->{loadavg_enabled}) eq "y") {
if(! -x $system->{alerts}->{loadavg_script}) {
logger("$myself: ERROR: script '$system->{alerts}->{loadavg_script}' doesn't exist or don't has execution permissions.");
}
@ -278,7 +278,7 @@ sub system_update {
);
# SYSTEM alert
if(lc($system->{alerts}->{enabled}) eq "y") {
if(lc($system->{alerts}->{loadavg_enabled}) eq "y") {
if(!$system->{alerts}->{loadavg_threshold} || $load15 < $system->{alerts}->{loadavg_threshold}) {
$config->{system_hist_alert1} = 0;
} else {
@ -287,9 +287,10 @@ sub system_update {
}
if($config->{system_hist_alert1} > 0 && (time - $config->{system_hist_alert1}) > $system->{alerts}->{loadavg_timeintvl}) {
if(-x $system->{alerts}->{loadavg_script}) {
logger("$myself: ALERT: executing script '$system->{alerts}->{loadavg_script}'.");
system($system->{alerts}->{loadavg_script} . " " .$system->{alerts}->{loadavg_timeintvl} . " " . $system->{alerts}->{loadavg_threshold} . " " . $load15);
} else {
logger("$myself: ERROR: script '$config->{alerts}->{loadavg_script}' doesn't exist or don't has execution permissions.");
logger("$myself: ERROR: script '$system->{alerts}->{loadavg_script}' doesn't exist or don't has execution permissions.");
}
$config->{system_hist_alert1} = time;
}