Update script LUA + conf x aggiornamento statistiche da RIOC

This commit is contained in:
Samuele Locatelli
2026-05-11 10:11:58 +02:00
parent 8ca120716c
commit 7c2d470551
7 changed files with 43 additions and 7 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.RIOC</RootNamespace>
<Version>8.16.2605.1109</Version>
<Version>8.16.2605.1110</Version>
</PropertyGroup>
<ItemGroup>
+4 -2
View File
@@ -4,11 +4,13 @@ local countInc = tonumber(ARGV[1]) or 0
local totalMsInc = tonumber(ARGV[2]) or 0
local newMax = tonumber(ARGV[3])
local newMin = tonumber(ARGV[4])
local sentinel = tonumber(ARGV[5])
local noReply = tonumber(ARGV[5])
local sentinel = tonumber(ARGV[6])
-- Incrementi base
-- Incrementi
redis.call('HINCRBY', key, 'count', countInc)
redis.call('HINCRBYFLOAT', key, 'totalMs', totalMsInc)
redis.call('HINCRBY', key, 'noReply', noReply)
-- MAX
local currentMaxStr = redis.call('HGET', key, 'maxMs')
+3 -1
View File
@@ -4,11 +4,13 @@ local countInc = tonumber(ARGV[1]) or 0
local totalMsInc = tonumber(ARGV[2]) or 0
local newMax = tonumber(ARGV[3])
local newMin = tonumber(ARGV[4])
local sentinel = tonumber(ARGV[5])
local noReply = tonumber(ARGV[5])
local sentinel = tonumber(ARGV[6])
-- Incrementi
redis.call('HINCRBY', key, 'count', countInc)
redis.call('HINCRBYFLOAT', key, 'totalMs', totalMsInc)
redis.call('HINCRBY', key, 'noReply', noReply)
-- MAX
local currentMaxStr = redis.call('HGET', key, 'maxMs')
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MP-RIOC </i>
<h4>Versione: 8.16.2605.1109</h4>
<h4>Versione: 8.16.2605.1110</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2605.1109
8.16.2605.1110
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2605.1109</version>
<version>8.16.2605.1110</version>
<url>https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/MP.RIOC.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+32
View File
@@ -48,6 +48,7 @@ namespace MP.RIOC.Services
private class AggregatedStats
{
public long Count;
public long NoReply;
public double TotalMs;
public double MaxMs;
public double MinMs = double.MaxValue;
@@ -111,6 +112,10 @@ namespace MP.RIOC.Services
var hoursIndex = HoursIndexKey(dest, method);
var hourScore = ToEpochSeconds(hourStart);
// Calcolo NoReply: Somma di tutti i codici >= 400 o errori espliciti
long noReplyCount = stat.ErrorMessages.Sum(x => x.Value);
// 1. INVIO BUCKET PRINCIPALE (con NoReply)
// Usiamo lo script Lua per l'aggiornamento atomico dell'ora
tasks.Add(batch.ScriptEvaluateAsync(_updateScript,
new RedisKey[] { hourKey },
@@ -119,9 +124,34 @@ namespace MP.RIOC.Services
totalMs.ToString(CultureInfo.InvariantCulture),
maxMs.ToString(CultureInfo.InvariantCulture),
minMs.ToString(CultureInfo.InvariantCulture),
noReplyCount.ToString(CultureInfo.InvariantCulture),
SentinelValue
}));
// 2. INVIO DISTRIBUZIONE STATUS CODES
if (stat.StatusCodes.Any())
{
var statusKey = hourKey + ":status";
foreach (var status in stat.StatusCodes)
{
tasks.Add(batch.HashIncrementAsync(statusKey, status.Key.ToString(), status.Value));
}
// Aggiungiamo anche questa chiave all'indice per la pulizia automatica
tasks.Add(batch.SortedSetAddAsync(hoursIndex, statusKey, hourScore));
}
// 3. INVIO DETTAGLIO ERRORI
if (stat.ErrorMessages.Any())
{
var errorKey = hourKey + ":errors";
foreach (var error in stat.ErrorMessages)
{
// Usiamo HashIncrement per aggregare messaggi uguali
tasks.Add(batch.HashIncrementAsync(errorKey, error.Key, error.Value));
}
tasks.Add(batch.SortedSetAddAsync(hoursIndex, errorKey, hourScore));
}
tasks.Add(batch.SortedSetAddAsync(hoursIndex, hourKey, hourScore));
// --- LOGICA DAILY (Aggregazione locale per evitare sovrascritture nel loop) ---
@@ -136,6 +166,7 @@ namespace MP.RIOC.Services
}
agg.Count += count;
agg.NoReply += noReplyCount;
agg.TotalMs += totalMs;
agg.MaxMs = Math.Max(agg.MaxMs, maxMs);
if (minMs != double.MaxValue)
@@ -162,6 +193,7 @@ namespace MP.RIOC.Services
agg.TotalMs.ToString(CultureInfo.InvariantCulture),
agg.MaxMs.ToString(CultureInfo.InvariantCulture),
finalMin.ToString(CultureInfo.InvariantCulture),
agg.NoReply.ToString(CultureInfo.InvariantCulture),
SentinelValue
}));
}