From 5a630b38d915450eee49c6ac0de89da6d00b60ff Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Wed, 4 Feb 2009 20:09:23 +0000 Subject: [PATCH] 2009-02-04 Ramon Novoa * lib/PandoraFMS/DB.pm: Read template default action on alert execution. * bin/pandora_snmpconsole: Fixed SNMP alerts. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1425 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 7 +++++++ pandora_server/bin/pandora_snmpconsole | 25 ++++++++++++++----------- pandora_server/lib/PandoraFMS/DB.pm | 10 ++++++++-- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index fe708101cd..cb350404c2 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,10 @@ +2009-02-04 Ramon Novoa + + * lib/PandoraFMS/DB.pm: Read template default action on alert + execution. + + * bin/pandora_snmpconsole: Fixed SNMP alerts. + 2009-02-04 Ramon Novoa * lib/PandoraFMS/DB.pm: Use db_do instead of db_update. diff --git a/pandora_server/bin/pandora_snmpconsole b/pandora_server/bin/pandora_snmpconsole index 02a9182489..6d7be87c90 100755 --- a/pandora_server/bin/pandora_snmpconsole +++ b/pandora_server/bin/pandora_snmpconsole @@ -197,8 +197,7 @@ sub calcula_alerta_snmp { my $dbh = $_[6]; my $alert_fired = 0; - my $query_idag = "select * from talert_snmp"; - my $s_idag = $dbh->prepare($query_idag); + my $s_idag = $dbh->prepare("SELECT * FROM talert_snmp"); $s_idag ->execute; my @data; # Read all alerts and apply to this incoming trap @@ -273,15 +272,19 @@ sub calcula_alerta_snmp { logger($pa_config,"Executing SNMP Trap alert for $agent - $alert_data",2); # Create a hash for passing to execute_alert - my %data_alert; - $data_alert{'id_aam'} = 0; - $data_alert{'id_agente_modulo'} = 0; - $data_alert{'id_alerta'} = $id_alert; - $data_alert{'al_campo1'} = $field1; - $data_alert{'al_campo2'} = $field2; - $data_alert{'al_campo3'} = $field3; - $data_alert{'descripcion'} = $description; - $data_alert{'priority'} = $alert_priority; + my %data_alert = ( + 'name' => '', + 'id_agent_module' => 0, + 'id_template_module' => 0, + 'field1' => $field1, + 'field2' => $field2, + 'field3' => $field3, + 'description' => $description, + 'times_fired' => $times_fired, + 'time_threshold' => 0, + 'id_alert_action' => $id_alert, + 'priority' => $alert_priority, + ); # Execute alert execute_alert ($pa_config, \%data_alert, 0, 0, $agent, $trap_agente, 1, $dbh); diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index 3c9890ecda..10e31a20be 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -540,7 +540,13 @@ sub execute_alert (%$$$$$$$$$$$$$$$) { OR (" . $alert->{'times_fired'} . " >= fires_min AND " . $alert->{'times_fired'} . " <= fires_max))", $dbh); if ($#actions < 0) { - return; + # Get default action + @actions = get_db_all_rows ("SELECT * FROM talert_actions, talert_commands + WHERE talert_actions.id = " . $alert->{'id_alert_action'} . + " AND talert_actions.id_alert_command = talert_commands.id", $dbh); + if ($#actions < 0) { + return; + } } # Get agent address @@ -566,7 +572,7 @@ sub execute_alert (%$$$$$$$$$$$$$$$) { _address_ => $address, _timestamp_ => &UnixDate ("today", "%Y-%m-%d %H:%M:%S"), _data_ => $data, - _alert_description_ => $alert->{'descripcion'}, + _alert_description_ => $alert->{'description'}, _alert_threshold_ => $alert->{'time_threshold'}, _alert_times_fired_ => $alert->{'times_fired'}, );