Merge branch 'ent-3214-exact-oid-matches' into 'develop'

Add support for exact matches to SNMP alerts.

See merge request artica/pandorafms!2090

Former-commit-id: 5e4c43a5343f7fa6992c05c93c0695b1881548b9
This commit is contained in:
Daniel Rodriguez 2019-02-21 11:35:51 +01:00
commit ba87d6a9b8
2 changed files with 11 additions and 2 deletions

View File

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

View File

@ -3418,7 +3418,16 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
$alert->{'oid'} = decode_entities($alert->{'oid'});
my $oid = $alert->{'oid'};
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 ";
}