Merge branch 'ent-9701-incorrect-non-dataserver-lag-calculation' into 'develop'

Fix non dataserver lag calculation

See merge request artica/pandorafms!5540
This commit is contained in:
Daniel Rodriguez 2023-02-15 14:37:43 +00:00
commit 83860a9e5c

View File

@ -5628,16 +5628,26 @@ sub pandora_server_statistics ($$) {
# Non-dataserver LAG calculation: # Non-dataserver LAG calculation:
if ($server->{"server_type"} != DATASERVER){ if ($server->{"server_type"} != DATASERVER){
$lag_row = get_db_single_row ($dbh, "SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag, AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS lag $lag_row = get_db_single_row ($dbh,
FROM tagente_estado, tagente_modulo "SELECT COUNT(tam.id_agente_modulo) AS module_lag, AVG(UNIX_TIMESTAMP() - tae.last_execution_try - tae.current_interval) AS lag
WHERE utimestamp > 0 FROM (
AND tagente_modulo.disabled = 0 SELECT tagente_estado.last_execution_try, tagente_estado.current_interval, tagente_estado.id_agente_modulo
AND tagente_modulo.id_tipo_modulo < 5 FROM tagente_estado
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo WHERE tagente_estado.current_interval > 0
AND current_interval > 0 AND tagente_estado.last_execution_try > 0
AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10) AND tagente_estado.running_by = ?
AND running_by = ? ) tae
AND (UNIX_TIMESTAMP() - utimestamp) > (current_interval * 1.1)", $server->{"id_server"}); JOIN (
SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag
FROM tagente_modulo LEFT JOIN tagente
ON tagente_modulo.id_agente = tagente.id_agente
WHERE tagente.disabled = 0
AND tagente_modulo.disabled = 0
AND tagente_modulo.id_tipo_modulo < 5
) tam
ON tae.id_agente_modulo = tam.id_agente_modulo
WHERE (UNIX_TIMESTAMP() - tae.last_execution_try) < ( tae.current_interval * 10)
AND (tam.flag = 1 OR (UNIX_TIMESTAMP() - tae.last_execution_try) > tae.current_interval)", $server->{"id_server"});
} }
# Dataserver LAG calculation: # Dataserver LAG calculation:
else { else {