mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-19 23:44:04 +02:00
fix merge issue
This commit is contained in:
parent
6e0f1c46b8
commit
771845c62f
1 changed files with 32 additions and 25 deletions
|
@ -11,34 +11,41 @@ class GroupMonitorType extends MonitorType {
|
||||||
async check(monitor, heartbeat, _server) {
|
async check(monitor, heartbeat, _server) {
|
||||||
const children = await Monitor.getChildren(monitor.id);
|
const children = await Monitor.getChildren(monitor.id);
|
||||||
|
|
||||||
if (children.length > 0) {
|
if (children.length == 0) {
|
||||||
heartbeat.status = UP;
|
|
||||||
heartbeat.msg = "All children up and running";
|
|
||||||
for (const child of children) {
|
|
||||||
if (!child.active) {
|
|
||||||
// Ignore inactive childs
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const lastBeat = await Monitor.getPreviousHeartbeat(child.id);
|
|
||||||
|
|
||||||
// Only change state if the monitor is in worse conditions then the ones before
|
|
||||||
// lastBeat.status could be null
|
|
||||||
if (!lastBeat) {
|
|
||||||
heartbeat.status = PENDING;
|
|
||||||
} else if (heartbeat.status === UP && (lastBeat.status === PENDING || lastBeat.status === DOWN)) {
|
|
||||||
heartbeat.status = lastBeat.status;
|
|
||||||
} else if (heartbeat.status === PENDING && lastBeat.status === DOWN) {
|
|
||||||
heartbeat.status = lastBeat.status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (heartbeat.status !== UP) {
|
|
||||||
heartbeat.msg = "Child inaccessible";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Set status pending if group is empty
|
// Set status pending if group is empty
|
||||||
heartbeat.status = PENDING;
|
heartbeat.status = PENDING;
|
||||||
heartbeat.msg = "Group empty";
|
heartbeat.msg = "Group empty";
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (children.filter(child => child.active).length === 0) {
|
||||||
|
// Set status pending if all children are paused
|
||||||
|
bean.status = PENDING;
|
||||||
|
bean.msg = "All Children are paused.";
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
heartbeat.status = UP;
|
||||||
|
heartbeat.msg = "All children up and running";
|
||||||
|
for (const child of children) {
|
||||||
|
if (!child.active) {
|
||||||
|
// Ignore inactive childs
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const lastBeat = await Monitor.getPreviousHeartbeat(child.id);
|
||||||
|
|
||||||
|
// Only change state if the monitor is in worse conditions then the ones before
|
||||||
|
// lastBeat.status could be null
|
||||||
|
if (!lastBeat) {
|
||||||
|
heartbeat.status = PENDING;
|
||||||
|
} else if (heartbeat.status === UP && (lastBeat.status === PENDING || lastBeat.status === DOWN)) {
|
||||||
|
heartbeat.status = lastBeat.status;
|
||||||
|
} else if (heartbeat.status === PENDING && lastBeat.status === DOWN) {
|
||||||
|
heartbeat.status = lastBeat.status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (heartbeat.status !== UP) {
|
||||||
|
heartbeat.msg = "Child inaccessible";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue