2010-11-19 Ramon Novoa <rnovoa@artica.es>

* lib/PandoraFMS/Core.pm: Fixed regexp alerts. The patch to detect
	  malformed regular expressions made them malfunction.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3603 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Ramon Novoa 2010-11-19 10:48:27 +00:00
parent fb18038db6
commit 5731f640f8
2 changed files with 15 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2010-11-19 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/Core.pm: Fixed regexp alerts. The patch to detect
malformed regular expressions made them malfunction.
2010-11-18 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/Core.pm,

View File

@ -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);
}
}