stauts
This commit is contained in:
1 parent
f56f91c31d
commit
7a01a8a8a3
7 files changed
+56
-36
No files matched your search
@@ -362,28 +362,6 @@ class MonitorService implements IMonitorService {
|
||||
},
|
||||
},
|
||||
},
|
||||
runningContainersSnapshot: {
|
||||
$last: {
|
||||
$map: {
|
||||
input: {
|
||||
$filter: {
|
||||
input: { $ifNull: ["$dockerContainers", []] },
|
||||
as: "c",
|
||||
cond: { $eq: ["$$c.running", true] },
|
||||
},
|
||||
},
|
||||
as: "c",
|
||||
in: {
|
||||
container_id: "$$c.container_id",
|
||||
container_name: "$$c.container_name",
|
||||
base_image: "$$c.base_image",
|
||||
exposed_ports: "$$c.exposed_ports",
|
||||
status: "$$c.status",
|
||||
health: "$$c.health",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
ICheck,
|
||||
} from "@/db/models/index.js";
|
||||
import { StatusResponse } from "./NetworkService.js";
|
||||
import { LatestCheck } from "@/db/models/monitors/Monitor.js";
|
||||
|
||||
const emptyMetrics = (): ThresholdEvaluationResult["metrics"] => ({
|
||||
cpu: { breached: false },
|
||||
@@ -74,11 +75,21 @@ class StatusService implements IStatusService {
|
||||
|
||||
// Store latest checks for display
|
||||
monitor.latestChecks = monitor.latestChecks || [];
|
||||
monitor.latestChecks.push({
|
||||
const nextCheck: LatestCheck = {
|
||||
status: newStatus,
|
||||
responseTime: statusResponse.responseTime,
|
||||
checkedAt: monitor.lastCheckedAt,
|
||||
});
|
||||
};
|
||||
// If this is a docker type, add the snapshot
|
||||
if (monitor.type === "docker") {
|
||||
const payload: any = statusResponse.payload;
|
||||
nextCheck.containerSnapshot = payload.data;
|
||||
}
|
||||
monitor.latestChecks.push(nextCheck);
|
||||
|
||||
if (monitor.type === "docker") {
|
||||
}
|
||||
|
||||
while (monitor.latestChecks.length > MAX_LATEST_CHECKS) {
|
||||
monitor.latestChecks.shift();
|
||||
}
|
||||
@@ -102,6 +113,7 @@ class StatusService implements IStatusService {
|
||||
if (allDifferent && monitor.status !== newStatus) {
|
||||
monitor.status = newStatus;
|
||||
}
|
||||
|
||||
return [await monitor.save(), allDifferent];
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user