Compare commits

...

10 Commits
1.0.0 ... 1.0.1

Author SHA1 Message Date
LouisLam
0176857a2c add ability to change the listening port and hostname 2021-07-12 18:33:25 +08:00
Louis Lam
c436ef4e05 Update README.md 2021-07-12 11:42:36 +08:00
LouisLam
56fcfc9369 fix show N/A if the ping is 0ms 2021-07-12 11:20:18 +08:00
LouisLam
a9d19ae06a support json for keyword type 2021-07-12 10:52:41 +08:00
Louis Lam
35ce54f30c Merge pull request #6 from TheGuyDanish/patch-1
Introduce custom user agent. Fixes #5
2021-07-12 09:39:15 +08:00
TheGuyDanish
f84f7aca75 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.
2021-07-11 21:01:34 +01:00
LouisLam
b198b3dde4 Merge remote-tracking branch 'origin/master' 2021-07-12 01:18:18 +08:00
LouisLam
0b294815c7 add back arm/v7 for build-docker 2021-07-12 01:18:02 +08:00
Louis Lam
83935a2cf4 Update README.md 2021-07-11 23:41:21 +08:00
Louis Lam
838913f0a1 Update README.md 2021-07-11 23:41:04 +08:00
7 changed files with 38 additions and 12 deletions

View File

@@ -24,6 +24,12 @@ docker run -d --restart=always -p 3001:3001 louislam/uptime-kuma
Browse to http://localhost:3001 after started.
Change Port and Volume
```bash
docker run -d --restart=always -p <YOUR_PORT>:3001 -v <YOUR_DIR OR VOLUME>:/app/data louislam/uptime-kuma
```
### Without Docker
Required Tools: Node.js >= 14, git and pm2.
@@ -36,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

8
package-lock.json generated
View File

@@ -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",

View File

@@ -1,17 +1,17 @@
{
"name": "uptime-kuma",
"version": "1.0.0",
"scripts": {
"dev": "vite --host",
"start-server": "node server/server.js",
"update": "",
"build": "vite build",
"vite-preview-dist": "vite preview --host",
"build-docker": "docker buildx build --platform linux/amd64,linux/arm64 -t louislam/uptime-kuma -t louislam/uptime-kuma:1 . --push",
"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"
},
"dependencies": {
"@popperjs/core": "^2.9.2",
"args-parser": "^1.3.0",
"axios": "^0.21.1",
"bootstrap": "^5.0.0",
"dayjs": "^1.10.4",

View File

@@ -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;
@@ -79,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 {

View File

@@ -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();
});

View File

@@ -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"

View File

@@ -30,7 +30,7 @@
<div class="mb-3" v-if="monitor.type === 'keyword' ">
<label for="keyword" class="form-label">Keyword</label>
<input type="text" class="form-control" id="keyword" v-model="monitor.keyword" required>
<div class="form-text">Search keyword in plain html response and it is case-sensitive</div>
<div class="form-text">Search keyword in plain html or JSON response and it is case-sensitive</div>
</div>
<div class="mb-3" v-if="monitor.type === 'port' || monitor.type === 'ping' ">