From 2db5823746cd8b2bec6945adcaba9ea4855a17dc Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 27 Oct 2016 18:33:27 +0200 Subject: [PATCH] Feature: Transactional agent flag When a module Transactional subsystem status is received, the agent turns into transactional_agent --- pandora_server/lib/PandoraFMS/Core.pm | 20 ++++++++++++++++++++ pandora_server/lib/PandoraFMS/DataServer.pm | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 80e8f6241b..0dedc1323b 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -223,6 +223,7 @@ our @EXPORT = qw( pandora_update_server pandora_update_table_from_hash pandora_update_template_module + pandora_mark_transactional_agent pandora_group_statistics pandora_server_statistics pandora_self_monitoring @@ -2287,6 +2288,25 @@ sub pandora_update_agent ($$$$$$$;$$) { db_do ($dbh, "UPDATE tagente SET $set WHERE id_agente = ?", @{$values}, $agent_id); } + +########################################################################## +=head2 C<< pandora_mark_transactional_agent (I<$id_agente>) >> + +Set an agent as transactional agent + +=cut +########################################################################## +sub pandora_mark_transactional_agent($$) { + my ($dbh, $id_agente) = @_; + + if ( (!(defined($id_agente))) || (!(defined($dbh))) ) { + return; + } + + db_do ($dbh, "UPDATE tagente SET transactional_agent=1 WHERE id_agente = ?", $id_agente); +} + + ########################################################################## =head2 C<< pandora_update_gis_data (I<$pa_config>, I<$dbh>, I<$agent_id>, I<$longitude>, I<$latitude>, I<$altitude>) >> diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 8d1cfe4eda..a2eb9ca19e 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -584,6 +584,12 @@ sub process_module_data ($$$$$$$$$$) { # Name XML tag and column name don't match $module_conf->{'nombre'} = safe_input($module_name); + + # Check if module is 'Transactional subsystem status' + if ($module_conf->{'name'} eq "Transactional subsystem status") { + # Defines current agent as transactional agent + pandora_mark_transactional_agent($dbh, $agent->{'id_agente'}); + } delete $module_conf->{'name'}; # Calculate the module interval in seconds