2013-01-10 Hirofumi Kosaka <kosaka@rworks.jp>
* lib/PandoraFMS/SNMPServer.pm: Rewrite my commit at rev7388 in more general way. logger() call was deleted here, because the corresponding error message is recorded by pandora_crash(). Merged from 4.0.x. * lib/PandoraFMS/Core.pm: Fixed that invalid regex in critical_str or warning_str could make server down at worst. Not used logger() here, because the corresponding error message is recorded by pandora_crash(). Merged from 4.0.x. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7410 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
48825d25e5
commit
b2698a1655
|
@ -1,3 +1,14 @@
|
||||||
|
2013-01-10 Hirofumi Kosaka <kosaka@rworks.jp>
|
||||||
|
|
||||||
|
* lib/PandoraFMS/SNMPServer.pm: Rewrite my commit at rev7388 in more
|
||||||
|
general way. logger() call was deleted here, because the corresponding
|
||||||
|
error message is recorded by pandora_crash(). Merged from 4.0.x.
|
||||||
|
|
||||||
|
* lib/PandoraFMS/Core.pm: Fixed that invalid regex in
|
||||||
|
critical_str or warning_str could make server down at worst.
|
||||||
|
Not used logger() here, because the corresponding error
|
||||||
|
message is recorded by pandora_crash(). Merged from 4.0.x.
|
||||||
|
|
||||||
2013-01-09 Dario Rodriguez <dario.rodriguez@artica.es>
|
2013-01-09 Dario Rodriguez <dario.rodriguez@artica.es>
|
||||||
|
|
||||||
* lib/PandoraFMS/NetworkServer.pm: Added log traces to inform
|
* lib/PandoraFMS/NetworkServer.pm: Added log traces to inform
|
||||||
|
|
|
@ -2931,6 +2931,7 @@ sub get_module_status ($$$) {
|
||||||
my ($critical_min, $critical_max, $warning_min, $warning_max) =
|
my ($critical_min, $critical_max, $warning_min, $warning_max) =
|
||||||
($module->{'min_critical'}, $module->{'max_critical'}, $module->{'min_warning'}, $module->{'max_warning'});
|
($module->{'min_critical'}, $module->{'max_critical'}, $module->{'min_warning'}, $module->{'max_warning'});
|
||||||
my ($critical_str, $warning_str) = ($module->{'str_critical'}, $module->{'str_warning'});
|
my ($critical_str, $warning_str) = ($module->{'str_critical'}, $module->{'str_warning'});
|
||||||
|
my $eval_result;
|
||||||
|
|
||||||
# Was the module status set in the XML data file?
|
# Was the module status set in the XML data file?
|
||||||
if (defined ($module->{'status'})) {
|
if (defined ($module->{'status'})) {
|
||||||
|
@ -2991,18 +2992,24 @@ sub get_module_status ($$$) {
|
||||||
else {
|
else {
|
||||||
|
|
||||||
# Critical
|
# Critical
|
||||||
if ($module->{'critical_inverse'} == 0) {
|
$eval_result = eval {
|
||||||
return 1 if ($critical_str ne '' && $data =~ /$critical_str/);
|
if ($module->{'critical_inverse'} == 0) {
|
||||||
} else {
|
$critical_str ne '' && $data =~ /$critical_str/ ;
|
||||||
return 1 if ($critical_str ne '' && $data !~ /$critical_str/);
|
} else {
|
||||||
}
|
$critical_str ne '' && $data !~ /$critical_str/ ;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return 1 if ($eval_result);
|
||||||
|
|
||||||
# Warning
|
# Warning
|
||||||
if ($module->{'warning_inverse'} == 0) {
|
$eval_result = eval {
|
||||||
return 2 if ($warning_str ne '' && $data =~ /$warning_str/);
|
if ($module->{'warning_inverse'} == 0) {
|
||||||
} else {
|
$warning_str ne '' && $data =~ /$warning_str/ ;
|
||||||
return 2 if ($warning_str ne '' && $data !~ /$warning_str/);
|
} else {
|
||||||
}
|
$warning_str ne '' && $data !~ /$warning_str/ ;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return 2 if ($eval_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Normal
|
# Normal
|
||||||
|
|
|
@ -239,17 +239,18 @@ sub matches_filter ($$$) {
|
||||||
my @filters = get_db_rows ($dbh, 'SELECT filter FROM tsnmp_filter');
|
my @filters = get_db_rows ($dbh, 'SELECT filter FROM tsnmp_filter');
|
||||||
foreach my $filter (@filters) {
|
foreach my $filter (@filters) {
|
||||||
my $regexp = safe_output($filter->{'filter'}) ;
|
my $regexp = safe_output($filter->{'filter'}) ;
|
||||||
|
my $eval_result;
|
||||||
|
|
||||||
# Check if $regexp begins with quantifier
|
# eval protects against server down (by invalid regular expressions)
|
||||||
if ($regexp =~ m/^[+*?]/ ) {
|
$eval_result = eval {
|
||||||
logger($pa_config, "Invalid SNMP filter. Quantifier follows nothing in regex '$regexp'.", 3);
|
$string =~ m/$regexp/i ;
|
||||||
next;
|
};
|
||||||
}
|
|
||||||
|
if ($eval_result) {
|
||||||
|
logger($pa_config, "Trap '$string' matches filter '$regexp'. Discarding...", 10);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if ($string =~ m/$regexp/i) {
|
|
||||||
logger($pa_config, "Trap '$string' matches filter '$regexp'. Discarding...", 10);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue