Merge branch 'ent-8555-Field_1_en_templates_de_alertas' into 'develop'
Fix issue with fields in alerts See merge request artica/pandorafms!4765
This commit is contained in:
commit
2f8c506fe8
|
@ -3,7 +3,7 @@ package PandoraFMS::Core;
|
|||
# Core Pandora FMS functions.
|
||||
# Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org
|
||||
##########################################################################
|
||||
# Copyright (c) 2005-2021 Artica Soluciones Tecnologicas S.L
|
||||
# Copyright (c) 2005-2022 Artica Soluciones Tecnologicas S.L
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public License
|
||||
|
@ -17,7 +17,7 @@ package PandoraFMS::Core;
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##########################################################################
|
||||
|
||||
=head1 NAME
|
||||
=head1 NAME
|
||||
|
||||
PandoraFMS::Core - Core functions of Pandora FMS
|
||||
|
||||
|
@ -1130,15 +1130,6 @@ sub pandora_execute_action ($$$$$$$$$;$$) {
|
|||
my ($field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8, $field9, $field10);
|
||||
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'})) {
|
||||
# Regular alerts
|
||||
$field1 = defined($action->{'field1'}) && $action->{'field1'} ne "" ? $action->{'field1'} : $alert->{'field1'};
|
||||
|
@ -1163,6 +1154,15 @@ sub pandora_execute_action ($$$$$$$$$;$$) {
|
|||
$field20 = defined($action->{'field20'}) && $action->{'field20'} ne "" ? $action->{'field20'} : $alert->{'field20'};
|
||||
}
|
||||
else {
|
||||
# Check for empty alert fields and assign command field.
|
||||
my $index = 1;
|
||||
my @command_fields = split(/,|\[|\]/, $action->{'fields_values'});
|
||||
foreach my $field (@command_fields) {
|
||||
if (!defined($action->{'field'.$index}) || $action->{'field'.$index} eq "") {
|
||||
$action->{'field'.$index} = defined($field) ? $field : "" ;
|
||||
}
|
||||
}
|
||||
|
||||
$field1 = defined($alert->{'field1'}) && $alert->{'field1'} ne "" ? $alert->{'field1'} : $action->{'field1'};
|
||||
$field2 = defined($alert->{'field2'}) && $alert->{'field2'} ne "" ? $alert->{'field2'} : $action->{'field2'};
|
||||
$field3 = defined($alert->{'field3'}) && $alert->{'field3'} ne "" ? $alert->{'field3'} : $action->{'field3'};
|
||||
|
@ -1185,7 +1185,6 @@ sub pandora_execute_action ($$$$$$$$$;$$) {
|
|||
$field20 = defined($alert->{'field20'}) && $alert->{'field20'} ne "" ? $alert->{'field20'} : $action->{'field20'};
|
||||
}
|
||||
|
||||
|
||||
# Recovery fields, thanks to Kato Atsushi
|
||||
if ($alert_mode == RECOVERED_ALERT) {
|
||||
# Field 1 is a special case where [RECOVER] prefix is not added even when it is defined
|
||||
|
|
Loading…
Reference in New Issue