fix undefined bug, updated server validation
This commit is contained in:
1 parent
9bd2e336a6
commit
27415aeca6
2 files changed
+18
-3
No files matched your search
@@ -117,13 +117,18 @@ class StatusService {
|
||||
// Update running stats
|
||||
this.updateRunningStats({ monitor, networkResponse });
|
||||
|
||||
// If the status window size has changed, empty
|
||||
while (monitor.statusWindow.length > monitor.statusWindowSize) {
|
||||
monitor.statusWindow.shift();
|
||||
}
|
||||
|
||||
// Update status sliding window
|
||||
monitor.statusWindow.push(status);
|
||||
if (monitor.statusWindow.length > monitor.statusWindowSize) {
|
||||
monitor.statusWindow.shift();
|
||||
}
|
||||
|
||||
if (!monitor.status) {
|
||||
if (monitor.status === undefined || monitor.status === null) {
|
||||
monitor.status = status;
|
||||
}
|
||||
|
||||
@@ -145,10 +150,16 @@ class StatusService {
|
||||
|
||||
// Check if threshold has been met
|
||||
const failures = monitor.statusWindow.filter((s) => s === false).length;
|
||||
const failureRate = failures / monitor.statusWindow.length;
|
||||
const failureRate = (failures / monitor.statusWindow.length) * 100;
|
||||
|
||||
console.log({
|
||||
failureRate,
|
||||
status: monitor.status,
|
||||
statusWindow: monitor.statusWindow,
|
||||
});
|
||||
|
||||
// If threshold has been met and the monitor is not already down, mark down:
|
||||
if (failureRate > monitor.statusWindowThreshold && monitor.status !== false) {
|
||||
if (failureRate >= monitor.statusWindowThreshold && monitor.status !== false) {
|
||||
newStatus = false;
|
||||
statusChanged = true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user