mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-10 04:58:13 +08:00
Introduce resend interval if down
This commit is contained in:
@@ -68,6 +68,7 @@ class Monitor extends BeanModel {
|
||||
type: this.type,
|
||||
interval: this.interval,
|
||||
retryInterval: this.retryInterval,
|
||||
resendInterval: this.resendInterval,
|
||||
keyword: this.keyword,
|
||||
ignoreTls: this.getIgnoreTls(),
|
||||
upsideDown: this.isUpsideDown(),
|
||||
@@ -135,6 +136,7 @@ class Monitor extends BeanModel {
|
||||
bean.monitor_id = this.id;
|
||||
bean.time = R.isoDateTime(dayjs.utc());
|
||||
bean.status = DOWN;
|
||||
bean.lastNotifiedTime = previousBeat?.lastNotifiedTime || null; // after first update lastNotifiedTime will be undefined
|
||||
|
||||
if (this.isUpsideDown()) {
|
||||
bean.status = flipStatus(bean.status);
|
||||
@@ -390,12 +392,27 @@ class Monitor extends BeanModel {
|
||||
debug(`[${this.name}] sendNotification`);
|
||||
await Monitor.sendNotification(isFirstBeat, this, bean);
|
||||
|
||||
// Set last notified time to now
|
||||
bean.lastNotifiedTime = dayjs().valueOf();
|
||||
|
||||
// Clear Status Page Cache
|
||||
debug(`[${this.name}] apicache clear`);
|
||||
apicache.clear();
|
||||
|
||||
} else {
|
||||
bean.important = false;
|
||||
|
||||
if (bean.status === DOWN && this.resendInterval > 0) {
|
||||
timeSinceLastNotified = dayjs().valueOf() - (bean.lastNotifiedTime || 0);
|
||||
if (timeSinceLastNotified >= this.resendInterval) {
|
||||
// Send notification again, because we are still DOWN
|
||||
debug(`[${this.name}] sendNotification`);
|
||||
await Monitor.sendNotification(isFirstBeat, this, bean);
|
||||
|
||||
// Set last notified time to now
|
||||
bean.lastNotifiedTime = dayjs().valueOf();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bean.status === UP) {
|
||||
|
@@ -588,6 +588,7 @@ exports.entryPage = "dashboard";
|
||||
bean.basic_auth_pass = monitor.basic_auth_pass;
|
||||
bean.interval = monitor.interval;
|
||||
bean.retryInterval = monitor.retryInterval;
|
||||
bean.resendInterval = monitor.resendInterval;
|
||||
bean.hostname = monitor.hostname;
|
||||
bean.maxretries = monitor.maxretries;
|
||||
bean.port = monitor.port;
|
||||
@@ -1082,6 +1083,7 @@ exports.entryPage = "dashboard";
|
||||
let monitorListData = backupData.monitorList;
|
||||
|
||||
let version17x = compareVersions.compare(backupData.version, "1.7.0", ">=");
|
||||
let version1114 = compareVersions.compare(backupData.version, "1.11.4", ">=");
|
||||
|
||||
// If the import option is "overwrite" it'll clear most of the tables, except "settings" and "user"
|
||||
if (importHandle == "overwrite") {
|
||||
@@ -1131,6 +1133,7 @@ exports.entryPage = "dashboard";
|
||||
|
||||
// Define default values
|
||||
let retryInterval = 0;
|
||||
let resendInterval = 0;
|
||||
|
||||
/*
|
||||
Only replace the default value with the backup file data for the specific version, where it appears the first time
|
||||
@@ -1139,6 +1142,9 @@ exports.entryPage = "dashboard";
|
||||
if (version17x) {
|
||||
retryInterval = monitorListData[i].retryInterval;
|
||||
}
|
||||
if (version1114) {
|
||||
resendInterval = monitorListData[i].resendInterval;
|
||||
}
|
||||
|
||||
// --- End ---
|
||||
|
||||
@@ -1154,6 +1160,7 @@ exports.entryPage = "dashboard";
|
||||
basic_auth_pass: monitorListData[i].basic_auth_pass,
|
||||
interval: monitorListData[i].interval,
|
||||
retryInterval: retryInterval,
|
||||
resendInterval: resendInterval,
|
||||
hostname: monitorListData[i].hostname,
|
||||
maxretries: monitorListData[i].maxretries,
|
||||
port: monitorListData[i].port,
|
||||
|
Reference in New Issue
Block a user