mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-02-25 21:15:55 +00:00
also handle the first beat problem in uptime
This commit is contained in:
parent
4f07c2ea9a
commit
8ee34c7904
1 changed files with 13 additions and 3 deletions
|
@ -448,13 +448,23 @@ class Monitor extends BeanModel {
|
||||||
|
|
||||||
let totalDuration = result.total_duration;
|
let totalDuration = result.total_duration;
|
||||||
let uptimeDuration = result.uptime_duration;
|
let uptimeDuration = result.uptime_duration;
|
||||||
|
let uptime = 0;
|
||||||
|
|
||||||
let uptime = uptimeDuration / totalDuration;
|
if (totalDuration > 0) {
|
||||||
|
uptime = uptimeDuration / totalDuration;
|
||||||
if (uptime < 0) {
|
if (uptime < 0) {
|
||||||
uptime = 0;
|
uptime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Handle new monitor with only one beat, because the beat's duration = 0
|
||||||
|
let status = parseInt(await R.getCell("SELECT `status` FROM heartbeat WHERE monitor_id = ?", [ monitorID ]));
|
||||||
|
console.log("here???" + status);
|
||||||
|
if (status === UP) {
|
||||||
|
uptime = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
io.to(userID).emit("uptime", monitorID, duration, uptime);
|
io.to(userID).emit("uptime", monitorID, duration, uptime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue