add new macros all_address and address_n

This commit is contained in:
daniel 2017-05-23 10:09:32 +02:00
parent 3abb9710b1
commit 37d3d895b0
3 changed files with 29 additions and 0 deletions

View File

@ -33,6 +33,8 @@ Apart from the defined module macros, the following macros are also available:
<li>_agentstatus_ : Current status of the agent.</li>
<li>_agentos_: Agent's operative system.</li>
<li>_address_ : Address of the agent that fired the alert.</li>
<li>_all_address_ : All address of the agent that fired the alert.</li>
<li>_address_n_ : The address of the agent that corresponds to the position indicated in "n" e.g: address_1_ , address_2_</li>
<li>_timestamp_ : Time when the alert was fired (yy-mm-dd hh:mm:ss).</li>
<li>_timezone_ : Timezone name that _timestamp_ represents in.</li>
<li>_data_ : Module data that caused the alert to fire.</li>

View File

@ -34,6 +34,8 @@ Además de las macros de módulo definidas, las siguientes macros están disponi
<li>_agentgroup_ : Nombre del grupo del agente.</li>
<li>_agentstatus_ : Estado actual del agente.</li>
<li>_address_: Dirección del agente que disparó la alerta.</li>
<li>_all_address_ : Todas las direcciones del agente que disparo la alerta.</li>
<li>_address_n_ : La dirección del agente que corresponde a la posicion indicada en "n" ejemplo: address_1_ , address_2_</li>
<li>_agentos_: Sistema operativo del agente.</li>
<li>_timestamp_: Hora y fecha en que se disparó la alerta.</li>
<li>_timezone_: Area Nombre _timestamp_ que representa en.</li>

View File

@ -1018,6 +1018,8 @@ sub pandora_execute_action ($$$$$$$$$;$) {
_email_tag_ => undef,
_phone_tag_ => undef,
_name_tag_ => undef,
_all_address_ => undef,
'_address_\d+_' => undef,
);
if ((defined ($extra_macros)) && (ref($extra_macros) eq "HASH")) {
@ -3613,6 +3615,29 @@ sub on_demand_macro($$$$$$) {
else{
my $field_value = get_db_value($dbh, 'SELECT datos FROM tagente_datos where id_agente_modulo = ? order by utimestamp desc limit 1 offset 1', $module->{'id_agente_modulo'});
}
}elsif ($macro eq '_all_address_') {
return '' unless defined ($module);
my @rows = get_db_rows ($dbh, 'SELECT ip FROM taddress_agent taag, taddress ta WHERE ta.id_a = taag.id_a AND id_agent = ?', $module->{'id_agente'});
my $field_value = "<pre>";
my $count=1;
foreach my $element (@rows) {
$field_value .= $count.": " . $element->{'ip'} . "\n";
$count++;
}
$field_value .= "</pre>";
return(defined($field_value)) ? $field_value : '';
} elsif ($macro =~ /_address_(\d+)_/) {
return '' unless defined ($module);
my $field_number = $1 - 1;
my @rows = get_db_rows ($dbh, 'SELECT ip FROM taddress_agent taag, taddress ta WHERE ta.id_a = taag.id_a AND id_agent = ?', $module->{'id_agente'});
my $field_value = $rows[$field_number]->{'ip'};
if($field_value == ''){
$field_value = 'Ip not defined';
}
return(defined($field_value)) ? $field_value : '';
}
}