diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 66371ab9a7..28f69ef82a 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2010-11-19 Ramon Novoa + + * lib/PandoraFMS/Core.pm: Fixed regexp alerts. The patch to detect + malformed regular expressions made them malfunction. + 2010-11-18 Ramon Novoa * lib/PandoraFMS/Core.pm, diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 66edc0bc65..81b9d3769e 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -298,16 +298,21 @@ sub pandora_evaluate_alert ($$$$$$$) { return $status if ($alert->{'type'} eq "equal" && $data != $alert->{'value'}); return $status if ($alert->{'type'} eq "not_equal" && $data == $alert->{'value'}); if ($alert->{'type'} eq "regex") { + + # Make sure the regexp is valid eval { local $SIG{'__DIE__'}; - if ($alert->{'matches_value'} == 1) { - return $status if ($data !~ m/$alert->{'value'}/i); - } else { - return $status if ($data =~ m/$alert->{'value'}/i); - } + $data =~ m/$alert->{'value'}/i; }; if ($@) { logger ($pa_config, "Error evaluating alert '" . $alert->{'name'} . "' for agent '" . $agent->{'nombre'} . "': '" . $alert->{'value'} . "' is not a valid regular expression.", 10); + return $status; + } + + if ($alert->{'matches_value'} == 1) { + return $status if ($data !~ m/$alert->{'value'}/i); + } else { + return $status if ($data =~ m/$alert->{'value'}/i); } }