mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 07:44:35 +02:00
Fix master detection for multiprocess mode.
This commit is contained in:
parent
228570a53e
commit
0e97e8dc2b
@ -7010,8 +7010,21 @@ Returns 1 if this server is the current master, 0 otherwise.
|
|||||||
|
|
||||||
=cut
|
=cut
|
||||||
##########################################################################
|
##########################################################################
|
||||||
sub pandora_is_master ($) {
|
sub pandora_is_master ($;$) {
|
||||||
my ($pa_config) = @_;
|
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'}) {
|
if ($Master eq $pa_config->{'servername'}) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -143,7 +143,7 @@ sub data_producer ($) {
|
|||||||
# By default, after create a tasks it takes the utimestamp to 0
|
# By default, after create a tasks it takes the utimestamp to 0
|
||||||
# Status -1 means "done".
|
# Status -1 means "done".
|
||||||
my @rows;
|
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
|
@rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task
|
||||||
WHERE id_recon_server = ?
|
WHERE id_recon_server = ?
|
||||||
AND disabled = 0
|
AND disabled = 0
|
||||||
|
@ -83,7 +83,7 @@ sub data_producer ($) {
|
|||||||
my @tasks;
|
my @tasks;
|
||||||
my @rows;
|
my @rows;
|
||||||
|
|
||||||
if (pandora_is_master($pa_config) == 0) {
|
if (pandora_is_master($pa_config, $dbh) == 0) {
|
||||||
if ($pa_config->{'dbengine'} ne 'oracle') {
|
if ($pa_config->{'dbengine'} ne 'oracle') {
|
||||||
@rows = get_db_rows ($dbh,
|
@rows = get_db_rows ($dbh,
|
||||||
'SELECT tagent_module_inventory.id_agent_module_inventory, tagent_module_inventory.flag, tagent_module_inventory.timestamp
|
'SELECT tagent_module_inventory.id_agent_module_inventory, tagent_module_inventory.flag, tagent_module_inventory.timestamp
|
||||||
|
@ -96,7 +96,7 @@ sub data_producer ($) {
|
|||||||
my @rows;
|
my @rows;
|
||||||
my $network_filter = enterprise_hook ('get_network_filter', [$pa_config]);
|
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
|
@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
|
FROM tagente, tagente_modulo, tagente_estado
|
||||||
WHERE server_name = ?
|
WHERE server_name = ?
|
||||||
|
@ -96,7 +96,7 @@ sub data_producer ($) {
|
|||||||
my @tasks;
|
my @tasks;
|
||||||
my @rows;
|
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
|
@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
|
FROM tagente, tagente_modulo, tagente_estado
|
||||||
WHERE server_name = ?
|
WHERE server_name = ?
|
||||||
|
@ -93,7 +93,7 @@ sub data_producer ($) {
|
|||||||
my @tasks;
|
my @tasks;
|
||||||
my @rows;
|
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,
|
@rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo,
|
||||||
tagente_modulo.flag, last_execution_try
|
tagente_modulo.flag, last_execution_try
|
||||||
FROM tagente, tagente_modulo, tagente_estado
|
FROM tagente, tagente_modulo, tagente_estado
|
||||||
|
@ -94,7 +94,7 @@ sub data_producer ($) {
|
|||||||
my @tasks;
|
my @tasks;
|
||||||
my @rows;
|
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
|
@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
|
FROM tagente, tagente_modulo, tagente_estado
|
||||||
WHERE server_name = ?
|
WHERE server_name = ?
|
||||||
|
@ -124,7 +124,7 @@ sub data_producer ($) {
|
|||||||
my @tasks;
|
my @tasks;
|
||||||
my @rows;
|
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
|
@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
|
FROM tagente, tagente_modulo, tagente_estado
|
||||||
WHERE server_name = ?
|
WHERE server_name = ?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user