mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-27 16:54:04 +00:00
Rename feature to: Resend Notification if Down X times consequently
Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
This commit is contained in:
parent
869a040011
commit
ac27e6e2af
5 changed files with 16 additions and 18 deletions
|
@ -5,6 +5,6 @@ ALTER TABLE monitor
|
|||
ADD resend_interval INTEGER default 0 not null;
|
||||
|
||||
ALTER TABLE heartbeat
|
||||
ADD last_notified_time DATETIME default null;
|
||||
ADD down_count INTEGER default 0 not null;
|
||||
|
||||
COMMIT;
|
||||
|
|
|
@ -206,7 +206,7 @@ class Monitor extends BeanModel {
|
|||
bean.monitor_id = this.id;
|
||||
bean.time = R.isoDateTimeMillis(dayjs.utc());
|
||||
bean.status = DOWN;
|
||||
bean.lastNotifiedTime = previousBeat?.lastNotifiedTime;
|
||||
bean.downCount = previousBeat?.downCount || 0;
|
||||
|
||||
if (this.isUpsideDown()) {
|
||||
bean.status = flipStatus(bean.status);
|
||||
|
@ -523,8 +523,8 @@ class Monitor extends BeanModel {
|
|||
log.debug("monitor", `[${this.name}] sendNotification`);
|
||||
await Monitor.sendNotification(isFirstBeat, this, bean);
|
||||
|
||||
// Set last notified time to now
|
||||
bean.lastNotifiedTime = R.isoDateTime(dayjs.utc());
|
||||
// Reset down count
|
||||
bean.downCount = 0;
|
||||
|
||||
// Clear Status Page Cache
|
||||
log.debug("monitor", `[${this.name}] apicache clear`);
|
||||
|
@ -534,16 +534,14 @@ class Monitor extends BeanModel {
|
|||
bean.important = false;
|
||||
|
||||
if (bean.status === DOWN && this.resendInterval > 0) {
|
||||
// divide by 1000 to convert from milliseconds to seconds and divide by 60 to convert from seconds to minutes
|
||||
let timeSinceLastNotified = (dayjs.utc().valueOf() - (bean.lastNotifiedTime == null ? 0 : dayjs.utc(bean.lastNotifiedTime).valueOf())) / 1000 / 60;
|
||||
if (timeSinceLastNotified >= this.resendInterval) {
|
||||
++bean.downCount;
|
||||
if (bean.downCount >= this.resendInterval) {
|
||||
// Send notification again, because we are still DOWN
|
||||
const currentTime = R.isoDateTime(dayjs.utc());
|
||||
log.debug("monitor", `[${this.name}] sendNotification again: lastNotifiedTime: ${bean.lastNotifiedTime} | current time: ${currentTime}`);
|
||||
log.debug("monitor", `[${this.name}] sendNotification again: Down Count: ${bean.downCount} | Resend Interval: ${this.resendInterval}`);
|
||||
await Monitor.sendNotification(isFirstBeat, this, bean);
|
||||
|
||||
// Set last notified time to now
|
||||
bean.lastNotifiedTime = currentTime;
|
||||
// Reset down count
|
||||
bean.downCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -556,7 +554,7 @@ class Monitor extends BeanModel {
|
|||
}
|
||||
log.warn("monitor", `Monitor #${this.id} '${this.name}': Pending: ${bean.msg} | Max retries: ${this.maxretries} | Retry: ${retries} | Retry Interval: ${beatInterval} seconds | Type: ${this.type}`);
|
||||
} else {
|
||||
log.warn("monitor", `Monitor #${this.id} '${this.name}': Failing: ${bean.msg} | Interval: ${beatInterval} seconds | Type: ${this.type}`);
|
||||
log.warn("monitor", `Monitor #${this.id} '${this.name}': Failing: ${bean.msg} | Interval: ${beatInterval} seconds | Type: ${this.type} | Down Count: ${bean.downCount} | Resend Interval: ${this.resendInterval}`);
|
||||
}
|
||||
|
||||
log.debug("monitor", `[${this.name}] Send to socket`);
|
||||
|
|
|
@ -162,9 +162,9 @@ export default {
|
|||
Pink: "Pink",
|
||||
"Search...": "Suchen...",
|
||||
"Heartbeat Retry Interval": "Überprüfungsintervall",
|
||||
"Notification resend interval if down": "Benachrichtigung erneut versenden wenn Inaktiv",
|
||||
"Resend Notification if Down X times consequently": "Benachrichtigung erneut senden, wenn Inaktiv X mal hintereinander",
|
||||
retryCheckEverySecond: "Alle {0} Sekunden neu versuchen",
|
||||
resendEveryMinute: "Erneut versenden alle {0} Minuten",
|
||||
resendEveryXTimes: "Erneut versenden alle {0} mal",
|
||||
resendDisabled: "Erneut versenden deaktiviert",
|
||||
"Import Backup": "Backup importieren",
|
||||
"Export Backup": "Backup exportieren",
|
||||
|
|
|
@ -2,7 +2,7 @@ export default {
|
|||
languageName: "English",
|
||||
checkEverySecond: "Check every {0} seconds",
|
||||
retryCheckEverySecond: "Retry every {0} seconds",
|
||||
resendEveryMinute: "Resend every {0} minutes",
|
||||
resendEveryXTimes: "Resend every {0} times",
|
||||
resendDisabled: "Resend disabled",
|
||||
retriesDescription: "Maximum retries before the service is marked as down and a notification is sent",
|
||||
ignoreTLSError: "Ignore TLS/SSL error for HTTPS websites",
|
||||
|
@ -74,7 +74,7 @@ export default {
|
|||
"Heartbeat Interval": "Heartbeat Interval",
|
||||
Retries: "Retries",
|
||||
"Heartbeat Retry Interval": "Heartbeat Retry Interval",
|
||||
"Notification resend interval if down": "Notification resend interval if down",
|
||||
"Resend Notification if Down X times consequently": "Resend Notification if Down X times consequently",
|
||||
Advanced: "Advanced",
|
||||
"Upside Down Mode": "Upside Down Mode",
|
||||
"Max. Redirects": "Max. Redirects",
|
||||
|
|
|
@ -204,8 +204,8 @@
|
|||
|
||||
<div class="my-3">
|
||||
<label for="resend-interval" class="form-label">
|
||||
{{ $t("Notification resend interval if down") }}
|
||||
<span v-if="monitor.resendInterval > 0">({{ $t("resendEveryMinute", [ monitor.resendInterval ]) }})</span>
|
||||
{{ $t("Resend Notification if Down X times consequently") }}
|
||||
<span v-if="monitor.resendInterval > 0">({{ $t("resendEveryXTimes", [ monitor.resendInterval ]) }})</span>
|
||||
<span v-else>({{ $t("resendDisabled") }})</span>
|
||||
</label>
|
||||
<input id="resend-interval" v-model="monitor.resendInterval" type="number" class="form-control" required min="0" step="1">
|
||||
|
|
Loading…
Reference in a new issue