Get command field if it is not defined in alert or action

This commit is contained in:
Calvo 2021-07-22 11:34:07 +02:00
parent 62be3f5830
commit 51ca2de1e5
1 changed files with 14 additions and 3 deletions

View File

@ -1051,6 +1051,15 @@ sub pandora_execute_action ($$$$$$$$$;$) {
my ($field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8, $field9, $field10); my ($field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8, $field9, $field10);
my ($field11, $field12, $field13, $field14, $field15, $field16, $field17, $field18, $field19, $field20); my ($field11, $field12, $field13, $field14, $field15, $field16, $field17, $field18, $field19, $field20);
# Check for empty alert fields and assign command field.
my $index = 1;
my @command_fields = split(/,|\[|\]/, $action->{'fields_values'});
foreach my $field (@command_fields) {
unless (defined($action->{'field'.$index}) && $action->{'field'.$index} ne "") {
$action->{'field'.$index} = defined($field) ? $field : "" ;
}
}
if (!defined($alert->{'snmp_alert'})) { if (!defined($alert->{'snmp_alert'})) {
# Regular alerts # Regular alerts
$field1 = defined($action->{'field1'}) && $action->{'field1'} ne "" ? $action->{'field1'} : $alert->{'field1'}; $field1 = defined($action->{'field1'}) && $action->{'field1'} ne "" ? $action->{'field1'} : $alert->{'field1'};
@ -1097,6 +1106,8 @@ sub pandora_execute_action ($$$$$$$$$;$) {
$field20 = defined($alert->{'field20'}) && $alert->{'field20'} ne "" ? $alert->{'field20'} : $action->{'field20'}; $field20 = defined($alert->{'field20'}) && $alert->{'field20'} ne "" ? $alert->{'field20'} : $action->{'field20'};
} }
print Dumper($field1);
# Recovery fields, thanks to Kato Atsushi # Recovery fields, thanks to Kato Atsushi
if ($alert_mode == RECOVERED_ALERT) { if ($alert_mode == RECOVERED_ALERT) {
# Field 1 is a special case where [RECOVER] prefix is not added even when it is defined # Field 1 is a special case where [RECOVER] prefix is not added even when it is defined
@ -4145,9 +4156,9 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
# Execute alert # Execute alert
my $action = get_db_single_row ($dbh, 'SELECT * my $action = get_db_single_row ($dbh, 'SELECT *
FROM talert_actions, talert_commands FROM talert_actions taa JOIN talert_commands tac
WHERE talert_actions.id_alert_command = talert_commands.id ON taa.id_alert_command = tac.id
AND talert_actions.id = ?', $alert->{'id_alert'}); WHERE tac.id = ?', $alert->{'id_alert'});
my $trap_rcv_full = $trap_oid . " " . $trap_value. " ". $trap_type. " " . $trap_custom_oid; my $trap_rcv_full = $trap_oid . " " . $trap_value. " ". $trap_type. " " . $trap_custom_oid;