mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-22 22:13:20 +02:00
feat: Add timeoutMs field
This commit is contained in:
parent
c3eef28443
commit
76ef46740a
7
db/patch-add-timeout-ms-monitor.sql
Normal file
7
db/patch-add-timeout-ms-monitor.sql
Normal file
@ -0,0 +1,7 @@
|
||||
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
ALTER TABLE monitor
|
||||
ADD timeout_ms INTEGER default 0 not null;
|
||||
|
||||
COMMIT;
|
@ -64,6 +64,7 @@ class Database {
|
||||
"patch-add-other-auth.sql": { parents: [ "patch-monitor-basic-auth.sql" ] },
|
||||
"patch-add-radius-monitor.sql": true,
|
||||
"patch-monitor-add-resend-interval.sql": true,
|
||||
"patch-add-timeout-ms-monitor.sql": true,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -77,6 +77,7 @@ class Monitor extends BeanModel {
|
||||
weight: this.weight,
|
||||
active: this.active,
|
||||
type: this.type,
|
||||
timeoutMs: this.timeoutMs,
|
||||
interval: this.interval,
|
||||
retryInterval: this.retryInterval,
|
||||
resendInterval: this.resendInterval,
|
||||
@ -252,7 +253,7 @@ class Monitor extends BeanModel {
|
||||
url: this.url,
|
||||
method: (this.method || "get").toLowerCase(),
|
||||
...(this.body ? { data: JSON.parse(this.body) } : {}),
|
||||
timeout: this.interval * 1000 * 0.8,
|
||||
timeout: this.timeoutMs,
|
||||
headers: {
|
||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
||||
"User-Agent": "Uptime-Kuma/" + version,
|
||||
@ -446,7 +447,7 @@ class Monitor extends BeanModel {
|
||||
}
|
||||
|
||||
let res = await axios.get(steamApiUrl, {
|
||||
timeout: this.interval * 1000 * 0.8,
|
||||
timeout: this.timeoutMs,
|
||||
headers: {
|
||||
"Accept": "*/*",
|
||||
"User-Agent": "Uptime-Kuma/" + version,
|
||||
|
@ -668,6 +668,7 @@ let needSetup = false;
|
||||
bean.headers = monitor.headers;
|
||||
bean.basic_auth_user = monitor.basic_auth_user;
|
||||
bean.basic_auth_pass = monitor.basic_auth_pass;
|
||||
bean.timeoutMs = monitor.timeoutMs;
|
||||
bean.interval = monitor.interval;
|
||||
bean.retryInterval = monitor.retryInterval;
|
||||
bean.resendInterval = monitor.resendInterval;
|
||||
@ -1254,6 +1255,7 @@ let needSetup = false;
|
||||
|
||||
// Define default values
|
||||
let retryInterval = 0;
|
||||
let timeoutMs = monitorListData[i].interval * 1000 * 0.8; // previously hardcoded in monitor.js
|
||||
|
||||
/*
|
||||
Only replace the default value with the backup file data for the specific version, where it appears the first time
|
||||
@ -1278,6 +1280,7 @@ let needSetup = false;
|
||||
basic_auth_pass: monitorListData[i].basic_auth_pass,
|
||||
authWorkstation: monitorListData[i].authWorkstation,
|
||||
authDomain: monitorListData[i].authDomain,
|
||||
timeoutMs: timeoutMs,
|
||||
interval: monitorListData[i].interval,
|
||||
retryInterval: retryInterval,
|
||||
resendInterval: monitorListData[i].resendInterval || 0,
|
||||
|
@ -254,6 +254,11 @@
|
||||
</template>
|
||||
|
||||
<!-- Interval -->
|
||||
<div class="my-3">
|
||||
<label for="timeoutMs" class="form-label">{{ $t("Heartbeat Timeout") }} ({{ $t("timeoutAfterMs", [ monitor.timeoutMs ]) }})</label>
|
||||
<input id="timeoutMs" v-model="monitor.timeoutMs" type="number" class="form-control" required min="50" step="50">
|
||||
</div>
|
||||
|
||||
<div class="my-3">
|
||||
<label for="interval" class="form-label">{{ $t("Heartbeat Interval") }} ({{ $t("checkEverySecond", [ monitor.interval ]) }})</label>
|
||||
<input id="interval" v-model="monitor.interval" type="number" class="form-control" required min="20" step="1">
|
||||
@ -606,6 +611,10 @@ export default {
|
||||
if (this.monitor.retryInterval === oldValue) {
|
||||
this.monitor.retryInterval = value;
|
||||
}
|
||||
// keep timeoutMs below interval, minding the unit conversion
|
||||
if (!this.monitor.timeoutMs || this.monitor.timeoutMs >= value * 1000) {
|
||||
this.monitor.timeoutMs = value * 1000 * 0.8;
|
||||
}
|
||||
},
|
||||
|
||||
"monitor.type"() {
|
||||
@ -668,6 +677,7 @@ export default {
|
||||
url: "https://",
|
||||
method: "GET",
|
||||
interval: 60,
|
||||
timeoutMs: this.interval * 1000 * 0.8, // previous default value
|
||||
retryInterval: this.interval,
|
||||
resendInterval: 0,
|
||||
maxretries: 0,
|
||||
@ -711,6 +721,10 @@ export default {
|
||||
if (this.monitor.retryInterval === 0) {
|
||||
this.monitor.retryInterval = this.monitor.interval;
|
||||
}
|
||||
// Handling for monitors that are missing timeoutMs
|
||||
if (!this.monitor.timeoutMs) {
|
||||
this.monitor.timeoutMs = this.monitor.interval * 1000 * 0.8;
|
||||
}
|
||||
} else {
|
||||
toast.error(res.msg);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user