2009-02-04 Ramon Novoa <rnovoa@artica.es>

* 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
This commit is contained in:
Ramon Novoa 2009-02-04 20:09:23 +00:00
parent 6965af931f
commit 5a630b38d9
3 changed files with 29 additions and 13 deletions

View File

@ -1,3 +1,10 @@
2009-02-04 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/DB.pm: Read template default action on alert
execution.
* bin/pandora_snmpconsole: Fixed SNMP alerts.
2009-02-04 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/DB.pm: Use db_do instead of db_update.

View File

@ -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);

View File

@ -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'},
);