Improved module execution for master servers.

Previously, master servers executed modules from any agent whose
assigned server had crashed. Now they execute modules from any agent
whose assigned server cannot execute them (e.g., the server is running
but the required component is disabled).
This commit is contained in:
Ramon Novoa 2023-04-25 12:28:38 +02:00
parent ca7e1777e5
commit 925d3fa6a2
7 changed files with 9 additions and 9 deletions

View File

@ -150,7 +150,7 @@ sub data_producer ($) {
OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))', $server_id);
} else {
@rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task
WHERE (id_recon_server = ? OR id_recon_server = ANY(SELECT id_server FROM tserver WHERE status <> 1 AND server_type = ?))
WHERE (id_recon_server = ? OR id_recon_server NOT IN (SELECT id_server FROM tserver WHERE status = 1 AND server_type = ?))
AND disabled = 0
AND ((utimestamp = 0 AND interval_sweep != 0 OR status = 1)
OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))', $server_id, DISCOVERYSERVER);

View File

@ -122,7 +122,7 @@ sub data_producer ($) {
@rows = get_db_rows ($dbh,
'SELECT tagent_module_inventory.id_agent_module_inventory, tagent_module_inventory.flag, tagent_module_inventory.timestamp
FROM tagente, tagent_module_inventory, tmodule_inventory
WHERE (server_name = ? OR server_name = ANY(SELECT name FROM tserver WHERE status <> 1 AND server_type = ?))
WHERE (server_name = ? OR server_name NOT IN (SELECT name FROM tserver WHERE status = 1 AND server_type = ?))
AND tmodule_inventory.id_module_inventory = tagent_module_inventory.id_module_inventory
AND tmodule_inventory.id_os IS NOT NULL
AND tagente.id_agente = tagent_module_inventory.id_agente
@ -138,7 +138,7 @@ sub data_producer ($) {
@rows = get_db_rows ($dbh,
'SELECT tagent_module_inventory.id_agent_module_inventory, tagent_module_inventory.flag, tagent_module_inventory.timestamp
FROM tagente, tagent_module_inventory, tmodule_inventory
WHERE (server_name = ? OR server_name = ANY(SELECT name FROM tserver WHERE status <> 1 AND server_type = ?))
WHERE (server_name = ? OR server_name NOT IN (SELECT name FROM tserver WHERE status = 1 AND server_type = ?))
AND tmodule_inventory.id_module_inventory = tagent_module_inventory.id_module_inventory
AND tmodule_inventory.id_os IS NOT NULL
AND tagente.id_agente = tagent_module_inventory.id_agente

View File

@ -112,7 +112,7 @@ sub data_producer ($) {
} else {
@rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.last_execution_try, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try
FROM tagente, tagente_modulo, tagente_estado
WHERE ((server_name = ?) OR (server_name = ANY(SELECT name FROM tserver WHERE status <> 1 AND server_type = ?)))
WHERE ((server_name = ?) OR (server_name NOT IN (SELECT name FROM tserver WHERE status = 1 AND server_type = ?)))
AND tagente_modulo.id_agente = tagente.id_agente
AND tagente.disabled = 0
AND tagente_modulo.disabled = 0

View File

@ -110,7 +110,7 @@ sub data_producer ($) {
} else {
@rows = get_db_rows ($dbh, 'SELECT DISTINCT(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 = ?) OR (server_name = ANY(SELECT name FROM tserver WHERE status <> 1 AND server_type = ?)))
WHERE ((server_name = ?) OR (server_name NOT IN (SELECT name FROM tserver WHERE status = 1 AND server_type = ?)))
AND tagente_modulo.id_agente = tagente.id_agente
AND tagente.disabled = 0
AND tagente_modulo.disabled = 0

View File

@ -114,9 +114,9 @@ sub data_producer ($) {
tagente_modulo.flag, last_execution_try
FROM tagente, tagente_modulo, tagente_estado
WHERE ((server_name = ?)
OR (server_name = ANY(SELECT name
OR (server_name NOT IN (SELECT name
FROM tserver
WHERE status <> 1 AND server_type = ?))
WHERE status = 1 AND server_type = ?))
OR ((server_name = 0 OR server_name IS NULL) AND 1=?)
)
AND tagente_modulo.id_agente = tagente.id_agente

View File

@ -109,7 +109,7 @@ sub data_producer ($) {
} else {
@rows = get_db_rows ($dbh, 'SELECT DISTINCT(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, tserver
WHERE ((server_name = ?) OR (server_name = ANY(SELECT name FROM tserver WHERE status <> 1 AND server_type = ?)))
WHERE ((server_name = ?) OR (server_name NOT IN (SELECT name FROM tserver WHERE status = 1 AND server_type = ?)))
AND tagente_modulo.id_agente = tagente.id_agente
AND tagente.disabled = 0
AND tagente_modulo.disabled = 0

View File

@ -137,7 +137,7 @@ sub data_producer ($) {
} else {
@rows = get_db_rows ($dbh, 'SELECT DISTINCT(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, tserver
WHERE ((server_name = ?) OR (server_name = ANY(SELECT server_name FROM tserver WHERE status <> 1 AND server_type = ?)))
WHERE ((server_name = ?) OR (server_name NOT IN (SELECT server_name FROM tserver WHERE status = 1 AND server_type = ?)))
AND tagente_modulo.id_agente = tagente.id_agente
AND tagente.disabled = 0
AND tagente_modulo.disabled = 0