2009-01-21 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/DB.pm: Take into account the alert option 'matches_value'. * bin/pandora_server: Added support for forced alert execution. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1373 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
f154b7d0d8
commit
7ee00ca354
|
@ -1,3 +1,10 @@
|
|||
2009-01-21 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* lib/PandoraFMS/DB.pm: Take into account the alert option
|
||||
'matches_value'.
|
||||
|
||||
* bin/pandora_server: Added support for forced alert execution.
|
||||
|
||||
2009-01-20 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* Config.pm: Now works without breaking the server :-). Show verbose info
|
||||
|
|
|
@ -95,6 +95,8 @@ while (1) {
|
|||
pandora_serverkeepaliver (\%pa_config, 0, $dbh);
|
||||
# Disabled until we can finish code from editor and update server code
|
||||
pandora_planned_downtime (\%pa_config, $dbh);
|
||||
# Ececute forced alerts
|
||||
pandora_exec_forced_alerts (\%pa_config, $dbh);
|
||||
keep_alive_check (\%pa_config, $dbh);
|
||||
threads->yield;
|
||||
sleep ($pa_config{"server_threshold"});
|
||||
|
@ -451,3 +453,29 @@ sub process_module_data {
|
|||
logger($pa_config, "ERROR: Received data from an unknown module ($tipo_modulo)", 2);
|
||||
}
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
## SUB pandora_exec_forced_alerts ($pa_config, $dbh)
|
||||
## Execute forced alerts.
|
||||
##########################################################################
|
||||
|
||||
sub pandora_exec_forced_alerts {
|
||||
my $pa_config = $_[0];
|
||||
my $dbh = $_[1];
|
||||
|
||||
# Get alerts marked for forced execution (even disabled alerts)
|
||||
my @alerts = get_db_all_rows ("SELECT talert_template_modules.id as id_template_module, talert_template_modules.*, talert_templates.*, tagente.*
|
||||
FROM talert_template_modules, talert_templates, tagente, tagente_modulo
|
||||
WHERE talert_template_modules.id_alert_template = talert_templates.id
|
||||
AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo
|
||||
AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND force_execution = 1", $dbh);
|
||||
|
||||
foreach my $alert (@alerts) {
|
||||
execute_alert ($pa_config, $alert, $alert->{'id_agente'}, $alert->{'id_grupo'}, $alert->{'nombre'},
|
||||
'', 1, $dbh);
|
||||
|
||||
# Reset the force_execution flag, even if the alert could not be executed
|
||||
db_do ("UPDATE talert_template_modules SET force_execution = 0 WHERE id = " . $alert->{'id_template_module'}, $dbh);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -223,10 +223,17 @@ sub pandora_evaluate_alert (%$%$$$) {
|
|||
elsif ($alert_data->{'type'} eq "max" && $module_data <= $alert_data->{'max_value'}) {
|
||||
return $status;
|
||||
}
|
||||
elsif ($alert_data->{'type'} eq "max_min"
|
||||
&& $module_data >= $alert_data->{'min_value'}
|
||||
&& $module_data <= $alert_data->{'max_value'}) {
|
||||
return $status;
|
||||
elsif ($alert_data->{'type'} eq "max_min") {
|
||||
if ($alert_data->{'matches_value'} == 1 &&
|
||||
$module_data <= $alert_data->{'min_value'} &&
|
||||
$module_data >= $alert_data->{'max_value'}) {
|
||||
return $status;
|
||||
}
|
||||
|
||||
if ($module_data >= $alert_data->{'min_value'} &&
|
||||
$module_data <= $alert_data->{'max_value'}) {
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
elsif ($alert_data->{'type'} eq "equal" && $module_data == $alert_data->{'value'}) {
|
||||
return $status;
|
||||
|
@ -234,8 +241,14 @@ sub pandora_evaluate_alert (%$%$$$) {
|
|||
elsif ($alert_data->{'type'} eq "not_equal" && $module_data != $alert_data->{'value'}) {
|
||||
return $status;
|
||||
}
|
||||
elsif ($alert_data->{'type'} eq "regex" && $module_data !~ m/$alert_data->{'alert_text'}/i) {
|
||||
return $status;
|
||||
elsif ($alert_data->{'type'} eq "regex") {
|
||||
if ($alert_data->{'matches_value'} == 1 && $module_data =~ m/$alert_data->{'alert_text'}/i) {
|
||||
return $status;
|
||||
}
|
||||
|
||||
if ($module_data !~ m/$alert_data->{'alert_text'}/i) {
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
#if ($id_module_type == -1) {
|
||||
|
|
Loading…
Reference in New Issue