Add support for exact matches to SNMP alerts.

Ref pandora_enterprise#3214.


Former-commit-id: 35aa55d4d2ae236e614be7f4db50a9eb9f62aafa
This commit is contained in:
Ramon Novoa 2018-12-17 15:39:44 +01:00
parent 7f9ee21b4b
commit bc36bb0534
2 changed files with 11 additions and 2 deletions

View File

@ -634,7 +634,7 @@ if ($create_alert || $update_alert) {
// OID // OID
echo '<tr id="tr-oid">' . echo '<tr id="tr-oid">' .
'<td class="datos2">' . __('Enterprise String') . '</td>' . '<td class="datos2">' . __('Enterprise String') . ui_print_help_tip (__('Matches substrings. End the string with $ for exact matches.'), true) . '</td>' .
'<td class="datos2">'; '<td class="datos2">';
html_print_input_text ("oid", $oid, '', 50, 255); html_print_input_text ("oid", $oid, '', 50, 255);
echo '</td></tr>'; echo '</td></tr>';

View File

@ -3400,7 +3400,16 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
$alert->{'oid'} = decode_entities($alert->{'oid'}); $alert->{'oid'} = decode_entities($alert->{'oid'});
my $oid = $alert->{'oid'}; my $oid = $alert->{'oid'};
if ($oid ne '') { if ($oid ne '') {
next if (index ($trap_oid, $oid) == -1 && index ($trap_oid_text, $oid) == -1); my $term = substr($oid, -1);
# Strict match.
if ($term eq '$') {
chop($oid);
next if ($trap_oid ne $oid && $trap_oid_text ne $oid);
}
# Partial match.
else {
next if (index ($trap_oid, $oid) == -1 && index ($trap_oid_text, $oid) == -1);
}
$alert_data .= "OID: $oid "; $alert_data .= "OID: $oid ";
} }