mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 14:54:05 +00:00
feat: show child status on group error
This commit is contained in:
parent
dda40610c7
commit
50d6ea36a4
1 changed files with 32 additions and 4 deletions
|
@ -382,7 +382,8 @@ class Monitor extends BeanModel {
|
|||
|
||||
if (children.length > 0) {
|
||||
bean.status = UP;
|
||||
bean.msg = "All children up and running";
|
||||
bean.msg = "";
|
||||
let errorChildNames = [];
|
||||
for (const child of children) {
|
||||
if (!child.active) {
|
||||
// Ignore inactive childs
|
||||
|
@ -399,10 +400,23 @@ class Monitor extends BeanModel {
|
|||
} else if (bean.status === PENDING && lastBeat.status === DOWN) {
|
||||
bean.status = lastBeat.status;
|
||||
}
|
||||
|
||||
if(lastBeat && (lastBeat.status === PENDING || lastBeat.status === DOWN)) {
|
||||
console.log(lastBeat.monitor_id);
|
||||
const childMonitor = await Monitor.getMonitor(lastBeat.monitor_id);
|
||||
console.log(childMonitor)
|
||||
if(errorChildNames.length > 0)
|
||||
bean.msg += "\r\n";
|
||||
|
||||
bean.msg += "- " + childMonitor.name + ":\r\n" + lastBeat.msg.trim().replace(/^/gm, " ");
|
||||
errorChildNames.push(childMonitor.name);
|
||||
}
|
||||
}
|
||||
|
||||
if (bean.status !== UP) {
|
||||
bean.msg = "Child inaccessible";
|
||||
if (bean.status === UP) {
|
||||
bean.msg = "All children up and running";
|
||||
} else if(bean.status === PENDING || bean.status === DOWN) {
|
||||
bean.msg = "Some Children are having problems (" + errorChildNames.join(', ') + ")\r\n" + bean.msg;
|
||||
}
|
||||
} else {
|
||||
// Set status pending if group is empty
|
||||
|
@ -1604,6 +1618,20 @@ class Monitor extends BeanModel {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Monitor with specific ID
|
||||
* @param {number} monitorID ID of monitor to get
|
||||
* @returns {Promise<LooseObject<any>>} Children
|
||||
*/
|
||||
static async getMonitor(monitorID) {
|
||||
return await R.getRow(`
|
||||
SELECT * FROM monitor
|
||||
WHERE id = ?
|
||||
`, [
|
||||
monitorID,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Parent of the monitor
|
||||
* @param {number} monitorID ID of monitor to get
|
||||
|
|
Loading…
Reference in a new issue