Merge branch 'ent-13196-netflow-server-deja-de-funcionar-con-multiprocess-a-1' into 'develop'

Fix master detection for multiprocess mode.

See merge request artica/pandorafms!7245
This commit is contained in:
Daniel Rodriguez 2024-04-26 07:26:37 +00:00
commit 5dcc628b14
8 changed files with 22 additions and 9 deletions

View File

@ -7010,8 +7010,21 @@ Returns 1 if this server is the current master, 0 otherwise.
=cut
##########################################################################
sub pandora_is_master ($) {
my ($pa_config) = @_;
sub pandora_is_master ($;$) {
my ($pa_config, $dbh) = @_;
# When multiprocess is enabled the variable $Master is not shared between
# servers.
if (defined($dbh) && $pa_config->{'multiprocess'} == 1) {
my $current_master = get_db_value_limit ($dbh, 'SELECT name FROM tserver
WHERE master <> 0 AND status = 1
ORDER BY master DESC', 1);
if (defined($current_master) && $current_master eq $pa_config->{'servername'}) {
return 1;
}
return 0;
}
if ($Master eq $pa_config->{'servername'}) {
return 1;

View File

@ -143,7 +143,7 @@ sub data_producer ($) {
# By default, after create a tasks it takes the utimestamp to 0
# Status -1 means "done".
my @rows;
if (pandora_is_master($pa_config) == 0) {
if (pandora_is_master($pa_config, $dbh) == 0) {
@rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task
WHERE id_recon_server = ?
AND disabled = 0

View File

@ -83,7 +83,7 @@ sub data_producer ($) {
my @tasks;
my @rows;
if (pandora_is_master($pa_config) == 0) {
if (pandora_is_master($pa_config, $dbh) == 0) {
if ($pa_config->{'dbengine'} ne 'oracle') {
@rows = get_db_rows ($dbh,
'SELECT tagent_module_inventory.id_agent_module_inventory, tagent_module_inventory.flag, tagent_module_inventory.timestamp

View File

@ -96,7 +96,7 @@ sub data_producer ($) {
my @rows;
my $network_filter = enterprise_hook ('get_network_filter', [$pa_config]);
if (pandora_is_master($pa_config) == 0) {
if (pandora_is_master($pa_config, $dbh) == 0) {
@rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try
FROM tagente, tagente_modulo, tagente_estado
WHERE server_name = ?

View File

@ -96,7 +96,7 @@ sub data_producer ($) {
my @tasks;
my @rows;
if (pandora_is_master($pa_config) == 0) {
if (pandora_is_master($pa_config, $dbh) == 0) {
@rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try
FROM tagente, tagente_modulo, tagente_estado
WHERE server_name = ?

View File

@ -93,7 +93,7 @@ sub data_producer ($) {
my @tasks;
my @rows;
if (pandora_is_master($pa_config) == 0) {
if (pandora_is_master($pa_config, $dbh) == 0) {
@rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo,
tagente_modulo.flag, last_execution_try
FROM tagente, tagente_modulo, tagente_estado

View File

@ -94,7 +94,7 @@ sub data_producer ($) {
my @tasks;
my @rows;
if (pandora_is_master($pa_config) == 0) {
if (pandora_is_master($pa_config, $dbh) == 0) {
@rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try
FROM tagente, tagente_modulo, tagente_estado
WHERE server_name = ?

View File

@ -124,7 +124,7 @@ sub data_producer ($) {
my @tasks;
my @rows;
if (pandora_is_master($pa_config) == 0) {
if (pandora_is_master($pa_config, $dbh) == 0) {
@rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try
FROM tagente, tagente_modulo, tagente_estado
WHERE server_name = ?