From f84f7aca7515516964b6757ac993ad35f6c23e77 Mon Sep 17 00:00:00 2001 From: TheGuyDanish <5776313+TheGuyDanish@users.noreply.github.com> Date: Sun, 11 Jul 2021 21:01:34 +0100 Subject: [PATCH 01/11] Introduce custom user agent. Fixes #5 Quick and easy fix. Could be improved by adding a version number as well. Like `Uptime-Kuma/0.0.1`, for example. --- server/model/monitor.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 2735c378f..b8e8eb30c 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -71,7 +71,9 @@ class Monitor extends BeanModel { try { if (this.type === "http" || this.type === "keyword") { let startTime = dayjs().valueOf(); - let res = await axios.get(this.url) + let res = await axios.get(this.url, { + headers: { 'User-Agent':'Uptime-Kuma' } + }) bean.msg = `${res.status} - ${res.statusText}` bean.ping = dayjs().valueOf() - startTime; From a9d19ae06ad5bec0b2a90ebf4ba729987cec7118 Mon Sep 17 00:00:00 2001 From: LouisLam Date: Mon, 12 Jul 2021 10:52:41 +0800 Subject: [PATCH 02/11] support json for keyword type --- server/model/monitor.js | 9 ++++++++- src/pages/EditMonitor.vue | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index b8e8eb30c..162772875 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -81,7 +81,14 @@ class Monitor extends BeanModel { bean.status = 1; } else { - if (res.data.includes(this.keyword)) { + let data = res.data; + + // Convert to string for object/array + if (typeof data !== "string") { + data = JSON.stringify(data) + } + + if (data.includes(this.keyword)) { bean.msg += ", keyword is found" bean.status = 1; } else { diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 7054d73ac..01af50610 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -30,7 +30,7 @@
-
Search keyword in plain html response and it is case-sensitive
+
Search keyword in plain html or JSON response and it is case-sensitive
From 56fcfc9369a4f57b4c593d440ce30bbaefb8992c Mon Sep 17 00:00:00 2001 From: LouisLam Date: Mon, 12 Jul 2021 11:20:18 +0800 Subject: [PATCH 03/11] fix show N/A if the ping is 0ms --- src/pages/Details.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/Details.vue b/src/pages/Details.vue index 0b031bfe6..f925c2849 100644 --- a/src/pages/Details.vue +++ b/src/pages/Details.vue @@ -137,7 +137,7 @@ export default { }, ping() { - if (this.lastHeartBeat.ping) { + if (this.lastHeartBeat.ping || this.lastHeartBeat.ping === 0) { return this.lastHeartBeat.ping; } else { return "N/A" @@ -145,7 +145,7 @@ export default { }, avgPing() { - if (this.$root.avgPingList[this.monitor.id]) { + if (this.$root.avgPingList[this.monitor.id] || this.$root.avgPingList[this.monitor.id] === 0) { return this.$root.avgPingList[this.monitor.id]; } else { return "N/A" From c436ef4e054c5647c89a602dbb8a7afebf62ee9d Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Mon, 12 Jul 2021 11:42:36 +0800 Subject: [PATCH 04/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b09048d74..31589e99f 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ npm run setup # Option 1. Try it npm run start-server -# (Recommanded) +# (Recommended) # Option 2. Run in background using PM2 # Install PM2 if you don't have: npm install pm2 -g pm2 start npm --name uptime-kuma -- run start-server From 0176857a2cf9f8fd3db118807fbaa5b76ca7772c Mon Sep 17 00:00:00 2001 From: LouisLam Date: Mon, 12 Jul 2021 18:33:25 +0800 Subject: [PATCH 05/11] add ability to change the listening port and hostname --- package-lock.json | 8 ++++++-- package.json | 2 +- server/server.js | 11 +++++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index d77efd9e1..3f7b3843b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,8 +1,7 @@ { "name": "uptime-kuma", - "version": "1.0.0", - "lockfileVersion": 1, "requires": true, + "lockfileVersion": 1, "dependencies": { "@babel/helper-validator-identifier": { "version": "7.14.5", @@ -243,6 +242,11 @@ "readable-stream": "^2.0.6" } }, + "args-parser": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/args-parser/-/args-parser-1.3.0.tgz", + "integrity": "sha512-If3Zi4BSjlQIJ9fgAhSiKi0oJtgMzSqh0H4wvl7XSeO16FKx7QqaHld8lZeEajPX7y1C5qKKeNgyrfyvmjmjUQ==" + }, "arr-diff": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", diff --git a/package.json b/package.json index b8ee4ed36..76c1538b8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,5 @@ { "name": "uptime-kuma", - "version": "1.0.0", "scripts": { "dev": "vite --host", "start-server": "node server/server.js", @@ -12,6 +11,7 @@ }, "dependencies": { "@popperjs/core": "^2.9.2", + "args-parser": "^1.3.0", "axios": "^0.21.1", "bootstrap": "^5.0.0", "dayjs": "^1.10.4", diff --git a/server/server.js b/server/server.js index 7b340372e..a03e5acbb 100644 --- a/server/server.js +++ b/server/server.js @@ -12,6 +12,13 @@ const Monitor = require("./model/monitor"); const fs = require("fs"); const {getSettings} = require("./util-server"); const {Notification} = require("./notification") +const args = require('args-parser')(process.argv); + +console.log("args:") +console.log(args) + +const hostname = args.host || "0.0.0.0" +const port = args.port || 3001 app.use(express.json()) @@ -435,8 +442,8 @@ let needSetup = false; }); }); - server.listen(3001, () => { - console.log('Listening on 3001'); + server.listen(port, hostname, () => { + console.log(`Listening on ${hostname}:${port}`); startMonitors(); }); From cb94ab3bb573d447c95afa511eca51462b50de74 Mon Sep 17 00:00:00 2001 From: LouisLam Date: Mon, 12 Jul 2021 18:59:48 +0800 Subject: [PATCH 06/11] add update guide --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 31589e99f..5f2508310 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,9 @@ npm run start-server # Install PM2 if you don't have: npm install pm2 -g pm2 start npm --name uptime-kuma -- run start-server +# Listen to different port or hostname +pm2 start npm --name uptime-kuma -- run start-server -- --port=80 --hostname=0.0.0.0 + ``` Browse to http://localhost:3001 after started. @@ -56,6 +59,22 @@ Browse to http://localhost:3001 after started. [![Deploy to DO](https://www.deploytodo.com/do-btn-blue.svg)](https://cloud.digitalocean.com/apps/new?repo=https://github.com/louislam/uptime-kuma/tree/master&refcode=e2c7eb658434) +# How to Update + +### Docker + +Re-pull the latest docker image and create another container with the same volume. + +### Without Docker + +```bash +git fetch --all +git checkout 1.0.1 --force +npm install +npm run build +pm2 restart uptime-kuma +``` + # More Screenshots Settings Page: From 459dde2761de3fdf3235ebecbe3cd39e330cb09d Mon Sep 17 00:00:00 2001 From: LouisLam Date: Mon, 12 Jul 2021 19:03:25 +0800 Subject: [PATCH 07/11] update the setup script to 1.0.1 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 76c1538b8..bc4757890 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "update": "", "build": "vite build", "vite-preview-dist": "vite preview --host", - "build-docker": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma -t louislam/uptime-kuma:1 . --push", - "setup": "git checkout 1.0.0 && npm install && npm run build" + "build-docker": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma -t louislam/uptime-kuma:1 -t louislam/uptime-kuma:1.0.1 . --push", + "setup": "git checkout 1.0.1 && npm install && npm run build" }, "dependencies": { "@popperjs/core": "^2.9.2", From c7dfb36349ec611ec8e1641f50b874a28e82a24f Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Mon, 12 Jul 2021 20:00:12 +0800 Subject: [PATCH 08/11] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5f2508310..0c932f4a9 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ Browse to http://localhost:3001 after started. [![Deploy to DO](https://www.deploytodo.com/do-btn-blue.svg)](https://cloud.digitalocean.com/apps/new?repo=https://github.com/louislam/uptime-kuma/tree/master&refcode=e2c7eb658434) +Choose Cheapest Plan is enough. (US$ 5) # How to Update From a6e16116f2d12c5d169d13c98bf374cff79b51ca Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Mon, 12 Jul 2021 20:08:51 +0800 Subject: [PATCH 09/11] improve the docker script --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0c932f4a9..08f5eb470 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,11 @@ It is a self-hosted monitoring tool like "Uptime Robot". ### Docker ```bash -docker run -d --restart=always -p 3001:3001 louislam/uptime-kuma +# Create a volume +docker volume create uptime-kuma + +# Start the container +docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma ``` Browse to http://localhost:3001 after started. @@ -27,7 +31,7 @@ Browse to http://localhost:3001 after started. Change Port and Volume ```bash -docker run -d --restart=always -p :3001 -v :/app/data louislam/uptime-kuma +docker run -d --restart=always -p :3001 -v :/app/data --name uptime-kuma louislam/uptime-kuma ``` ### Without Docker From ad615d1a90eafde55be4962e951c378cc6c16958 Mon Sep 17 00:00:00 2001 From: LouisLam Date: Mon, 12 Jul 2021 23:28:56 +0800 Subject: [PATCH 10/11] remove some timezones which may cause error --- src/util-frontend.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/util-frontend.js b/src/util-frontend.js index f4cd11634..35c8ed63c 100644 --- a/src/util-frontend.js +++ b/src/util-frontend.js @@ -24,7 +24,6 @@ const aryIannaTimeZones = [ 'Asia/Yerevan', 'Antarctica/Casey', 'Antarctica/Davis', - 'Antarctica/DumontDUrville', // https://bugs.chromium.org/p/chromium/issues/detail?id=928068 'Antarctica/Mawson', 'Antarctica/Palmer', 'Antarctica/Rothera', @@ -195,7 +194,6 @@ const aryIannaTimeZones = [ 'Asia/Seoul', 'Asia/Almaty', 'Asia/Qyzylorda', - 'Asia/Qostanay', // https://bugs.chromium.org/p/chromium/issues/detail?id=928068 'Asia/Aqtobe', 'Asia/Aqtau', 'Asia/Atyrau', From 1259ff536856d6dd3cb51f74a839d74a26fe136a Mon Sep 17 00:00:00 2001 From: LouisLam Date: Tue, 13 Jul 2021 01:02:50 +0800 Subject: [PATCH 11/11] smtp username/password is not required --- src/components/NotificationDialog.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index c86551616..2c524e897 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -105,12 +105,12 @@
- +
- +