From d209bd2f4537bd2cbb89c2854a72d945e31c9259 Mon Sep 17 00:00:00 2001 From: Hirofumi Kosaka Date: Mon, 22 May 2017 15:50:49 +0900 Subject: [PATCH] Bug Fix: SNMP Alert could not refer agents. #150 --- pandora_server/lib/PandoraFMS/Core.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 543ae4e264..855610d82f 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -976,7 +976,9 @@ sub pandora_execute_action ($$$$$$$$$;$) { _field13_ => $field13, _field14_ => $field14, _field15_ => $field15, - _agent_ => (defined ($agent)) ? $agent->{'alias'} : '', + _agentname_ => (defined ($agent)) ? $agent->{'nombre'} : '', + _agentalias_ => (defined ($agent)) ? $agent->{'alias'} : '', + _agent_ => (defined ($agent)) ? ($agent->{'alias'} ? $agent->{'alias'} : $agent->{'nombre'}) : '', _agentcustomid_ => (defined ($agent)) ? $agent->{'custom_id'} : '', '_agentcustomfield_\d+_' => undef, _agentdescription_ => (defined ($agent)) ? $agent->{'comentarios'} : '', @@ -1213,6 +1215,9 @@ sub pandora_execute_action ($$$$$$$$$;$) { } $agent_name = subst_alert_macros ($agent_name, \%macros, $pa_config, $dbh, $agent, $module); my $fullagent = get_agent_from_name ($dbh, $agent_name); + if( ! $fullagent && $macros{'_agentname_'} ) { + $fullagent = get_agent_from_name ($dbh, $macros{'_agentname_'} ); + } # Field 5 (priority) my $priority = $field5; @@ -3423,6 +3428,7 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) { if (defined($this_agent)){ %agent = ( 'nombre' => $this_agent->{'nombre'}, + 'alias' => $this_agent->{'alias'}, 'id_agente' => $this_agent->{'id_agente'}, 'direccion' => $trap_agent, 'id_grupo' => $this_agent->{'id_grupo'},