added alert capabilities to the Apache graph based on the remaining slots

This commit is contained in:
Jordi Sanfeliu 2015-07-24 09:21:24 +02:00
parent 224480b7c4
commit 8332378bbd
1 changed files with 27 additions and 0 deletions

View File

@ -576,6 +576,7 @@ sub apache_init {
}
$config->{apache_hist} = ();
$config->{apache_hist_alerts} = ();
push(@{$config->{func_update}}, $package);
logger("$myself: Ok") if $debug;
}
@ -666,6 +667,32 @@ sub apache_update {
}
}
# check alerts for each Apache
my @al = split(',', $apache->{alerts}->{$url} || "");
if(scalar(@al)) {
my $timeintvl = trim($al[0]);
my $threshold = trim($al[1]);
my $script = trim($al[2]);
if(!$threshold || $slot >= $threshold) {
$config->{apache_hist_alerts}->{$url} = 0;
} else {
if(!$config->{apache_hist_alerts}->{$url}) {
$config->{apache_hist_alerts}->{$url} = time;
}
if($config->{apache_hist_alerts}->{$url} > 0 && (time - $config->{apache_hist_alerts}->{$url}) >= $timeintvl) {
if(-x $script) {
logger("$myself: alert on Apache ($url): executing script '$script'.");
system($script . " " . $timeintvl . " " . $threshold . " " . $slot);
} else {
logger("$myself: ERROR: script '$script' doesn't exist or don't has execution permissions.");
}
$config->{apache_hist_alerts}->{$url} = time;
}
}
}
if(!$acc && !$kb && !$busy && !$idle) {
logger("$myself: WARNING: collected values are zero. Check the URL defined.");
}