Added a first version to multi origin macros feature.

This commit is contained in:
Arturo Gonzalez 2017-06-05 17:48:37 +02:00
parent 291ae3a192
commit 0c57d35f53
1 changed files with 24 additions and 1 deletions

View File

@ -1020,6 +1020,7 @@ sub pandora_execute_action ($$$$$$$$$;$) {
_name_tag_ => undef, _name_tag_ => undef,
_all_address_ => undef, _all_address_ => undef,
'_address_\d+_' => undef, '_address_\d+_' => undef,
'_data_module_\S+_ ' => undef,
); );
if ((defined ($extra_macros)) && (ref($extra_macros) eq "HASH")) { if ((defined ($extra_macros)) && (ref($extra_macros) eq "HASH")) {
@ -3637,6 +3638,28 @@ sub on_demand_macro($$$$$$) {
$field_value = 'Ip not defined'; $field_value = 'Ip not defined';
} }
return(defined($field_value)) ? $field_value : '';
} elsif ($macro =~ /_data_module_(\S+)_/) {
my $field_number = $1;
my @rows = get_db_rows ($dbh, 'SELECT alias FROM tagente WHERE id_agente = (SELECT id_agente FROM tagente_modulo WHERE nombre = ?)', $field_number);
use Data::Dumper;
$Data::Dumper::Sortkeys = 1;
my $field_value = '';
foreach my $row (@rows) {
my $agent_name = $row->{'alias'};
if ($agent_name ne "") {
$field_value .= "Agent " . $agent_name . " - Module " . $field_number;
}
}
if($field_value eq ''){
$field_value = 'Module ' . $field_number . " not found";
}
return(defined($field_value)) ? $field_value : ''; return(defined($field_value)) ? $field_value : '';
} }
} }