feat(NetworkMapScheduler): improve logging for speed test results by including server labels
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m39s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m39s
This commit is contained in:
@@ -254,6 +254,9 @@ async function runJob(opts) {
|
|||||||
const withSpeed = connections.filter((c) => c.speedTestServerId && c.interfaceName);
|
const withSpeed = connections.filter((c) => c.speedTestServerId && c.interfaceName);
|
||||||
const speedTasks = withSpeed.map((c) => async () => {
|
const speedTasks = withSpeed.map((c) => async () => {
|
||||||
const key = speedKey(c.fromKey, c.toKey);
|
const key = speedKey(c.fromKey, c.toKey);
|
||||||
|
const server = servers.find((s) => (s.id || s.dns || s.ip) === c.speedTestServerId);
|
||||||
|
const serverLabel = server ? (server.dns || server.ip || server.id) : c.speedTestServerId;
|
||||||
|
const speedLabel = `${serverLabel} / ${c.interfaceName}`;
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${baseUrl}/api/mikrotik/speed-test`, {
|
const res = await fetch(`${baseUrl}/api/mikrotik/speed-test`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -279,16 +282,16 @@ async function runJob(opts) {
|
|||||||
};
|
};
|
||||||
const down = data.tcpDownloadBps != null ? (data.tcpDownloadBps / 1e6).toFixed(1) : '—';
|
const down = data.tcpDownloadBps != null ? (data.tcpDownloadBps / 1e6).toFixed(1) : '—';
|
||||||
const up = data.tcpUploadBps != null ? (data.tcpUploadBps / 1e6).toFixed(1) : '—';
|
const up = data.tcpUploadBps != null ? (data.tcpUploadBps / 1e6).toFixed(1) : '—';
|
||||||
log(`Скорость ${c.interfaceName}: ↓${down} ↑${up} Mbps`);
|
log(`Скорость ${speedLabel}: ↓${down} ↑${up} Mbps`);
|
||||||
return speedMap[key];
|
return speedMap[key];
|
||||||
}
|
}
|
||||||
speedMap[key] = null;
|
speedMap[key] = null;
|
||||||
const speedErr = !res.ok ? (data?.message || `HTTP ${res.status}`) : 'нет данных';
|
const speedErr = !res.ok ? (data?.message || `HTTP ${res.status}`) : 'нет данных';
|
||||||
log(`Скорость ${c.interfaceName}: ${speedErr}`);
|
log(`Скорость ${speedLabel}: ${speedErr}`);
|
||||||
return null;
|
return null;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
speedMap[key] = null;
|
speedMap[key] = null;
|
||||||
log(`Скорость ${c.interfaceName}: ошибка ${e?.message || e}`);
|
log(`Скорость ${speedLabel}: ошибка ${e?.message || e}`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user