mirror of
https://github.com/stronk-dev/OrchestratorTracker.git
synced 2025-07-05 10:55:09 +02:00
fixes
This commit is contained in:
parent
b9b669cf37
commit
5fa08800bf
@ -100,8 +100,7 @@ Incoming stats parsing
|
|||||||
masterRouter.post("/collectStats", async (req, res) => {
|
masterRouter.post("/collectStats", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
if (!isSynced) { console.log("waiting for sync"); res.end('busy'); return; }
|
if (!isSynced) { console.log("waiting for sync"); res.end('busy'); return; }
|
||||||
const { id, discoveryResults,
|
const { id, discoveryResults, responseTime, tag, key } = req.body;
|
||||||
responseTime, tag, key } = req.body;
|
|
||||||
if (!id || !tag || !key) {
|
if (!id || !tag || !key) {
|
||||||
console.log("Received malformed data. Aborting stats update...");
|
console.log("Received malformed data. Aborting stats update...");
|
||||||
console.log(id, discoveryResults, responseTime, tag, key);
|
console.log(id, discoveryResults, responseTime, tag, key);
|
||||||
@ -157,7 +156,7 @@ masterRouter.post("/collectStats", async (req, res) => {
|
|||||||
}
|
}
|
||||||
if (!orchFound) {
|
if (!orchFound) {
|
||||||
currentDataList = [{ latency: thisPing, timestamp: now }];
|
currentDataList = [{ latency: thisPing, timestamp: now }];
|
||||||
orchScores.push({ id: thisId, data: currentDataList });
|
orchScores.push({ id: thisId, data: [{ tag, data: currentDataList }] });
|
||||||
}
|
}
|
||||||
await storage.setItem('orchScores', orchScores);
|
await storage.setItem('orchScores', orchScores);
|
||||||
// Calc new scores
|
// Calc new scores
|
||||||
@ -188,7 +187,9 @@ masterRouter.post("/collectStats", async (req, res) => {
|
|||||||
promAverageLatency.set({ region: tag, orchestrator: thisId }, pingsum / pingpoints);
|
promAverageLatency.set({ region: tag, orchestrator: thisId }, pingsum / pingpoints);
|
||||||
}
|
}
|
||||||
if (uptime || downtime) {
|
if (uptime || downtime) {
|
||||||
const score = uptime / (uptime + downtime)
|
let score;
|
||||||
|
if (!uptime) { score = 0; }
|
||||||
|
else { score = uptime / (uptime + downtime); }
|
||||||
promAUptimeScore.set({ region: tag, orchestrator: thisId }, score);
|
promAUptimeScore.set({ region: tag, orchestrator: thisId }, score);
|
||||||
}
|
}
|
||||||
res.send(true);
|
res.send(true);
|
||||||
@ -219,7 +220,7 @@ masterRouter.get("/prometheus", async (req, res) => {
|
|||||||
masterRouter.get("/json", async (req, res) => {
|
masterRouter.get("/json", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
res.set('Content-Type', 'application/json');
|
res.set('Content-Type', 'application/json');
|
||||||
res.end(orchScores);
|
res.end(JSON.stringify(orchScores));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
res.status(400).send(err);
|
res.status(400).send(err);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user