This commit is contained in:
Marco van Dijk 2023-10-31 14:46:20 +01:00
parent 3c31f88449
commit 3ff15d78bd

View File

@ -120,7 +120,7 @@ masterRouter.post("/collectStats", async (req, res) => {
} }
const latitude = null; const latitude = null;
const longitude = null; const longitude = null;
if (lookupResults.ll){ if (lookupResults && lookupResults.ll){
latitude = lookupResults.ll[0]; latitude = lookupResults.ll[0];
longitude = lookupResults.ll[1]; longitude = lookupResults.ll[1];
} }
@ -131,11 +131,11 @@ masterRouter.post("/collectStats", async (req, res) => {
if (thisEns.address != thisId) { continue; } if (thisEns.address != thisId) { continue; }
thisId = thisEns.domain; thisId = thisEns.domain;
} }
promLatestLatency.set({ region: tag, orchestrator: thisId, latitude: longitude, longitude: longitude }, responseTime); promLatestLatency.set({ region: tag, orchestrator: thisId, latitude: latitude, longitude: longitude }, responseTime);
promLatency.observe({ region: tag }, responseTime); promLatency.observe({ region: tag }, responseTime);
} }
if (discoveryResults && discoveryResults.price_info){ if (discoveryResults && discoveryResults.price_info){
promLatestPPP.set({ region: tag, orchestrator: thisId, latitude: longitude, longitude: longitude }, discoveryResults.price_info.pricePerUnit / discoveryResults.price_info.pixelsPerUnit); promLatestPPP.set({ region: tag, orchestrator: thisId, latitude: latitude, longitude: longitude }, discoveryResults.price_info.pricePerUnit / discoveryResults.price_info.pixelsPerUnit);
} }
console.log('received data for ' + thisId + ' from ' + tag + ' (' + responseTime + " ms latency)"); console.log('received data for ' + thisId + ' from ' + tag + ' (' + responseTime + " ms latency)");
// Save data point // Save data point
@ -197,13 +197,13 @@ masterRouter.post("/collectStats", async (req, res) => {
prevtime = thisData.timestamp; prevtime = thisData.timestamp;
} }
if (pingpoints) { if (pingpoints) {
promAverageLatency.set({ region: tag, orchestrator: thisId, latitude: longitude, longitude: longitude }, pingsum / pingpoints); promAverageLatency.set({ region: tag, orchestrator: thisId, latitude: latitude, longitude: longitude }, pingsum / pingpoints);
} }
if (uptime || downtime) { if (uptime || downtime) {
let score; let score;
if (!uptime) { score = 0; } if (!uptime) { score = 0; }
else { score = uptime / (uptime + downtime); } else { score = uptime / (uptime + downtime); }
promAUptimeScore.set({ region: tag, orchestrator: thisId, latitude: longitude, longitude: longitude }, score); promAUptimeScore.set({ region: tag, orchestrator: thisId, latitude: latitude, longitude: longitude }, score);
} }
res.send(true); res.send(true);
} catch (err) { } catch (err) {