mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 07:44:35 +02:00
Merge branch 'ent-10485-fix-inconsistency-between-lag-calculation-on-server-and-cosole' into 'develop'
Ent 10485 fix inconsistency between lag calculation on server and cosole See merge request artica/pandorafms!5577
This commit is contained in:
commit
6545c72d85
@ -1017,40 +1017,58 @@ function servers_get_info($id_server=-1)
|
|||||||
// Remote servers LAG Calculation (server_type != 0).
|
// Remote servers LAG Calculation (server_type != 0).
|
||||||
if ($server['server_type'] != 0) {
|
if ($server['server_type'] != 0) {
|
||||||
// MySQL 8.0 has function lag(). So, lag must be enclosed in quotations.
|
// MySQL 8.0 has function lag(). So, lag must be enclosed in quotations.
|
||||||
$result = db_get_row_sql(
|
$sql = sprintf(
|
||||||
'SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag,
|
'SELECT COUNT(tam.id_agente_modulo) AS module_lag,
|
||||||
AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS "lag"
|
AVG(UNIX_TIMESTAMP() - tae.last_execution_try - tae.current_interval) AS "lag"
|
||||||
FROM tagente_estado, tagente_modulo, tagente
|
FROM (
|
||||||
WHERE utimestamp > 0
|
SELECT tagente_estado.last_execution_try, tagente_estado.current_interval, tagente_estado.id_agente_modulo
|
||||||
AND tagente.disabled = 0
|
FROM tagente_estado
|
||||||
AND tagente.id_agente = tagente_estado.id_agente
|
WHERE tagente_estado.current_interval > 0
|
||||||
|
AND tagente_estado.last_execution_try > 0
|
||||||
|
AND tagente_estado.running_by = %d
|
||||||
|
) tae
|
||||||
|
JOIN (
|
||||||
|
SELECT tagente_modulo.id_agente_modulo
|
||||||
|
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.disabled = 0
|
||||||
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
) tam
|
||||||
AND current_interval > 0
|
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||||
AND running_by = '.$server['id_server'].'
|
WHERE (UNIX_TIMESTAMP() - tae.last_execution_try) > (tae.current_interval)
|
||||||
AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10)
|
AND (UNIX_TIMESTAMP() - tae.last_execution_try) < ( tae.current_interval * 10)',
|
||||||
AND (UNIX_TIMESTAMP() - utimestamp) > current_interval'
|
$server['id_server']
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Local/Dataserver server LAG calculation.
|
// Local/Dataserver server LAG calculation.
|
||||||
// MySQL 8.0 has function lag(). So, lag must be enclosed in quotations.
|
// MySQL 8.0 has function lag(). So, lag must be enclosed in quotations.
|
||||||
$result = db_get_row_sql(
|
$sql = sprintf(
|
||||||
'SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag,
|
'SELECT COUNT(tam.id_agente_modulo) AS module_lag,
|
||||||
AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS "lag"
|
AVG(UNIX_TIMESTAMP() - tae.last_execution_try - tae.current_interval) AS "lag"
|
||||||
FROM tagente_estado, tagente_modulo, tagente
|
FROM (
|
||||||
WHERE utimestamp > 0
|
SELECT tagente_estado.last_execution_try, tagente_estado.current_interval, tagente_estado.id_agente_modulo
|
||||||
AND tagente.disabled = 0
|
FROM tagente_estado
|
||||||
AND tagente.id_agente = tagente_estado.id_agente
|
WHERE tagente_estado.current_interval > 0
|
||||||
|
AND tagente_estado.last_execution_try > 0
|
||||||
|
AND tagente_estado.running_by = %d
|
||||||
|
) tae
|
||||||
|
JOIN (
|
||||||
|
SELECT tagente_modulo.id_agente_modulo
|
||||||
|
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.disabled = 0
|
||||||
AND tagente_modulo.id_tipo_modulo < 5
|
AND tagente_modulo.id_tipo_modulo < 5
|
||||||
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
) tam
|
||||||
AND current_interval > 0
|
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||||
AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10)
|
WHERE (UNIX_TIMESTAMP() - tae.last_execution_try) > (tae.current_interval * 1.1)
|
||||||
AND running_by = '.$server['id_server'].'
|
AND (UNIX_TIMESTAMP() - tae.last_execution_try) < ( tae.current_interval * 10)',
|
||||||
AND (UNIX_TIMESTAMP() - utimestamp) > (current_interval * 1.1)'
|
$server['id_server']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$result = db_get_row_sql($sql);
|
||||||
|
|
||||||
// Lag over current_interval * 2 is not lag,
|
// Lag over current_interval * 2 is not lag,
|
||||||
// it's a timed out module.
|
// it's a timed out module.
|
||||||
if (!empty($result['lag'])) {
|
if (!empty($result['lag'])) {
|
||||||
|
@ -5627,9 +5627,10 @@ 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 (
|
||||||
$lag_row = get_db_single_row ($dbh,
|
$dbh,
|
||||||
"SELECT COUNT(tam.id_agente_modulo) AS module_lag, AVG(UNIX_TIMESTAMP() - tae.last_execution_try - tae.current_interval) AS lag
|
"SELECT COUNT(tam.id_agente_modulo) AS module_lag,
|
||||||
|
AVG(UNIX_TIMESTAMP() - tae.last_execution_try - tae.current_interval) AS lag
|
||||||
FROM (
|
FROM (
|
||||||
SELECT tagente_estado.last_execution_try, tagente_estado.current_interval, tagente_estado.id_agente_modulo
|
SELECT tagente_estado.last_execution_try, tagente_estado.current_interval, tagente_estado.id_agente_modulo
|
||||||
FROM tagente_estado
|
FROM tagente_estado
|
||||||
@ -5638,7 +5639,33 @@ sub pandora_server_statistics ($$) {
|
|||||||
AND tagente_estado.running_by = ?
|
AND tagente_estado.running_by = ?
|
||||||
) tae
|
) tae
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag
|
SELECT tagente_modulo.id_agente_modulo
|
||||||
|
FROM tagente_modulo LEFT JOIN tagente
|
||||||
|
ON tagente_modulo.id_agente = tagente.id_agente
|
||||||
|
WHERE tagente.disabled = 0
|
||||||
|
AND tagente_modulo.disabled = 0
|
||||||
|
) tam
|
||||||
|
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||||
|
WHERE (UNIX_TIMESTAMP() - tae.last_execution_try) > (tae.current_interval)
|
||||||
|
AND (UNIX_TIMESTAMP() - tae.last_execution_try) < ( tae.current_interval * 10)",
|
||||||
|
$server->{"id_server"}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
# Dataserver LAG calculation:
|
||||||
|
else {
|
||||||
|
$lag_row = get_db_single_row (
|
||||||
|
$dbh,
|
||||||
|
"SELECT COUNT(tam.id_agente_modulo) AS module_lag,
|
||||||
|
AVG(UNIX_TIMESTAMP() - tae.last_execution_try - tae.current_interval) AS lag
|
||||||
|
FROM (
|
||||||
|
SELECT tagente_estado.last_execution_try, tagente_estado.current_interval, tagente_estado.id_agente_modulo
|
||||||
|
FROM tagente_estado
|
||||||
|
WHERE tagente_estado.current_interval > 0
|
||||||
|
AND tagente_estado.last_execution_try > 0
|
||||||
|
AND tagente_estado.running_by = ?
|
||||||
|
) tae
|
||||||
|
JOIN (
|
||||||
|
SELECT tagente_modulo.id_agente_modulo
|
||||||
FROM tagente_modulo LEFT JOIN tagente
|
FROM tagente_modulo LEFT JOIN tagente
|
||||||
ON tagente_modulo.id_agente = tagente.id_agente
|
ON tagente_modulo.id_agente = tagente.id_agente
|
||||||
WHERE tagente.disabled = 0
|
WHERE tagente.disabled = 0
|
||||||
@ -5646,20 +5673,10 @@ sub pandora_server_statistics ($$) {
|
|||||||
AND tagente_modulo.id_tipo_modulo < 5
|
AND tagente_modulo.id_tipo_modulo < 5
|
||||||
) tam
|
) tam
|
||||||
ON tae.id_agente_modulo = tam.id_agente_modulo
|
ON tae.id_agente_modulo = tam.id_agente_modulo
|
||||||
WHERE (UNIX_TIMESTAMP() - tae.last_execution_try) < ( tae.current_interval * 10)
|
WHERE (UNIX_TIMESTAMP() - tae.last_execution_try) > (tae.current_interval * 1.1)
|
||||||
AND (tam.flag = 1 OR (UNIX_TIMESTAMP() - tae.last_execution_try) > tae.current_interval)", $server->{"id_server"});
|
AND (UNIX_TIMESTAMP() - tae.last_execution_try) < ( tae.current_interval * 10)",
|
||||||
}
|
$server->{"id_server"}
|
||||||
# Dataserver LAG calculation:
|
);
|
||||||
else {
|
|
||||||
$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
|
|
||||||
FROM tagente_estado, tagente_modulo
|
|
||||||
WHERE utimestamp > 0
|
|
||||||
AND tagente_modulo.disabled = 0
|
|
||||||
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
|
||||||
AND current_interval > 0
|
|
||||||
AND running_by = ?
|
|
||||||
AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10)
|
|
||||||
AND (UNIX_TIMESTAMP() - utimestamp) > current_interval", $server->{"id_server"});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$server->{"module_lag"} = $lag_row->{'module_lag'};
|
$server->{"module_lag"} = $lag_row->{'module_lag'};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user