diff --git a/db/patch-add-timeout-monitor.sql b/db/patch-add-timeout-monitor.sql new file mode 100644 index 000000000..32d49d1e2 --- /dev/null +++ b/db/patch-add-timeout-monitor.sql @@ -0,0 +1,6 @@ +-- 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 DOUBLE default 0 not null; +COMMIT; \ No newline at end of file diff --git a/server/database.js b/server/database.js index ba20663fb..ed4e4d1b1 100644 --- a/server/database.js +++ b/server/database.js @@ -79,6 +79,7 @@ class Database { "patch-added-kafka-producer.sql": true, "patch-add-certificate-expiry-status-page.sql": true, "patch-monitor-oauth-cc.sql": true, + "patch-add-timeout-monitor.sql": true, }; /** diff --git a/server/model/monitor.js b/server/model/monitor.js index a8f3d898a..152a2c72a 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -102,6 +102,7 @@ class Monitor extends BeanModel { active: await this.isActive(), forceInactive: !await Monitor.isParentActive(this.id), type: this.type, + timeout: this.timeout, interval: this.interval, retryInterval: this.retryInterval, resendInterval: this.resendInterval, @@ -428,7 +429,7 @@ class Monitor extends BeanModel { const options = { url: this.url, method: (this.method || "get").toLowerCase(), - timeout: this.interval * 1000 * 0.8, + timeout: this.timeout, 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, @@ -648,7 +649,7 @@ class Monitor extends BeanModel { } let res = await axios.get(steamApiUrl, { - timeout: this.interval * 1000 * 0.8, + timeout: this.timeout, headers: { "Accept": "*/*", "User-Agent": "Uptime-Kuma/" + version, diff --git a/server/server.js b/server/server.js index ad01eab2f..b5f15f67d 100644 --- a/server/server.js +++ b/server/server.js @@ -716,6 +716,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.timeout = monitor.timeout; bean.oauth_client_id = monitor.oauth_client_id, bean.oauth_client_secret = monitor.oauth_client_secret, bean.oauth_auth_method = this.oauth_auth_method, @@ -1372,6 +1373,7 @@ let needSetup = false; // Define default values let retryInterval = 0; + let timeout = monitorListData[i].timeout || (monitorListData[i].interval * 0.8); // fallback to old value /* Only replace the default value with the backup file data for the specific version, where it appears the first time @@ -1397,6 +1399,7 @@ let needSetup = false; basic_auth_pass: monitorListData[i].basic_auth_pass, authWorkstation: monitorListData[i].authWorkstation, authDomain: monitorListData[i].authDomain, + timeout, interval: monitorListData[i].interval, retryInterval: retryInterval, resendInterval: monitorListData[i].resendInterval || 0, diff --git a/src/lang/en.json b/src/lang/en.json index 8a894e5c7..003e7596b 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -59,6 +59,8 @@ "Hostname": "Hostname", "Port": "Port", "Heartbeat Interval": "Heartbeat Interval", + "Request Timeout": "Request Timeout", + "timeoutAfter": "Timeout after {0} seconds", "Retries": "Retries", "Heartbeat Retry Interval": "Heartbeat Retry Interval", "Resend Notification if Down X times consecutively": "Resend Notification if Down X times consecutively", diff --git a/src/lang/ko-KR.json b/src/lang/ko-KR.json index 052e08092..f3fff8d0a 100644 --- a/src/lang/ko-KR.json +++ b/src/lang/ko-KR.json @@ -589,6 +589,8 @@ "RadiusCalledStationIdDescription": "접속 스테이션의 식별자", "RadiusCallingStationId": "접속 요청 스테이션의 Id", "RadiusCallingStationIdDescription": "접속 요청 스테이션의 식별자", + "timeoutAfter": "{0}초 후 타임아웃", + "Request Timeout": "요청 타임아웃", "Query": "쿼리", "settingsCertificateExpiry": "TLS 인증서 만료", "certificationExpiryDescription": "HTTPS 모니터링 TLS 인증서가 만료되면 알림을 활성화해요:", diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 515f84d90..c13ecc7a6 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -393,7 +393,7 @@
- +
@@ -412,6 +412,12 @@
+ +
+ + +
+