Merge remote-tracking branch 'upstream/master'

# Conflicts:
#	package.json
This commit is contained in:
Philipp Dormann 2021-07-12 21:40:35 +02:00
commit dae92d0ae4
No known key found for this signature in database
GPG Key ID: 3BB9ADD52DCA4314
9 changed files with 61 additions and 19 deletions

View File

@ -19,7 +19,11 @@ It is a self-hosted monitoring tool like "Uptime Robot".
### Docker ### Docker
```bash ```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. Browse to http://localhost:3001 after started.
@ -27,7 +31,7 @@ Browse to http://localhost:3001 after started.
Change Port and Volume Change Port and Volume
```bash ```bash
docker run -d --restart=always -p <YOUR_PORT>:3001 -v <YOUR_DIR OR VOLUME>:/app/data louislam/uptime-kuma docker run -d --restart=always -p <YOUR_PORT>:3001 -v <YOUR_DIR OR VOLUME>:/app/data --name uptime-kuma louislam/uptime-kuma
``` ```
### Without Docker ### Without Docker
@ -42,11 +46,14 @@ npm run setup
# Option 1. Try it # Option 1. Try it
npm run start-server npm run start-server
# (Recommanded) # (Recommended)
# Option 2. Run in background using PM2 # Option 2. Run in background using PM2
# Install PM2 if you don't have: npm install pm2 -g # Install PM2 if you don't have: npm install pm2 -g
pm2 start npm --name uptime-kuma -- run start-server 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. Browse to http://localhost:3001 after started.
@ -55,6 +62,23 @@ 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) [![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
### 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 # More Screenshots

8
package-lock.json generated
View File

@ -1,8 +1,7 @@
{ {
"name": "uptime-kuma", "name": "uptime-kuma",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true, "requires": true,
"lockfileVersion": 1,
"dependencies": { "dependencies": {
"@babel/helper-validator-identifier": { "@babel/helper-validator-identifier": {
"version": "7.14.5", "version": "7.14.5",
@ -243,6 +242,11 @@
"readable-stream": "^2.0.6" "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": { "arr-diff": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz",

View File

@ -1,17 +1,17 @@
{ {
"name": "uptime-kuma", "name": "uptime-kuma",
"version": "1.0.0",
"scripts": { "scripts": {
"dev": "vite --host", "dev": "vite --host",
"start-server": "node server/server.js", "start-server": "node server/server.js",
"update": "", "update": "",
"build": "vite build", "build": "vite build",
"vite-preview-dist": "vite preview --host", "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", "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.0 && npm install && npm run build" "setup": "git checkout 1.0.1 && npm install && npm run build"
}, },
"dependencies": { "dependencies": {
"@popperjs/core": "2.9.2", "@popperjs/core": "2.9.2",
"args-parser": "1.3.0",
"axios": "0.21.1", "axios": "0.21.1",
"bootstrap": "5.0.2", "bootstrap": "5.0.2",
"dayjs": "1.10.6", "dayjs": "1.10.6",

View File

@ -71,7 +71,9 @@ class Monitor extends BeanModel {
try { try {
if (this.type === "http" || this.type === "keyword") { if (this.type === "http" || this.type === "keyword") {
let startTime = dayjs().valueOf(); 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.msg = `${res.status} - ${res.statusText}`
bean.ping = dayjs().valueOf() - startTime; bean.ping = dayjs().valueOf() - startTime;
@ -79,7 +81,14 @@ class Monitor extends BeanModel {
bean.status = 1; bean.status = 1;
} else { } 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.msg += ", keyword is found"
bean.status = 1; bean.status = 1;
} else { } else {

View File

@ -12,6 +12,13 @@ const Monitor = require("./model/monitor");
const fs = require("fs"); const fs = require("fs");
const {getSettings} = require("./util-server"); const {getSettings} = require("./util-server");
const {Notification} = require("./notification") 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()) app.use(express.json())
@ -435,8 +442,8 @@ let needSetup = false;
}); });
}); });
server.listen(3001, () => { server.listen(port, hostname, () => {
console.log('Listening on 3001'); console.log(`Listening on ${hostname}:${port}`);
startMonitors(); startMonitors();
}); });

View File

@ -105,12 +105,12 @@
<div class="mb-3"> <div class="mb-3">
<label for="username" class="form-label">Username</label> <label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" required v-model="notification.smtpUsername" autocomplete="false"> <input type="text" class="form-control" id="username" v-model="notification.smtpUsername" autocomplete="false">
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="password" class="form-label">Password</label> <label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" required v-model="notification.smtpPassword" autocomplete="false"> <input type="password" class="form-control" id="password" v-model="notification.smtpPassword" autocomplete="false">
</div> </div>
<div class="mb-3"> <div class="mb-3">

View File

@ -137,7 +137,7 @@ export default {
}, },
ping() { ping() {
if (this.lastHeartBeat.ping) { if (this.lastHeartBeat.ping || this.lastHeartBeat.ping === 0) {
return this.lastHeartBeat.ping; return this.lastHeartBeat.ping;
} else { } else {
return "N/A" return "N/A"
@ -145,7 +145,7 @@ export default {
}, },
avgPing() { 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]; return this.$root.avgPingList[this.monitor.id];
} else { } else {
return "N/A" return "N/A"

View File

@ -30,7 +30,7 @@
<div class="mb-3" v-if="monitor.type === 'keyword' "> <div class="mb-3" v-if="monitor.type === 'keyword' ">
<label for="keyword" class="form-label">Keyword</label> <label for="keyword" class="form-label">Keyword</label>
<input type="text" class="form-control" id="keyword" v-model="monitor.keyword" required> <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>
<div class="mb-3" v-if="monitor.type === 'port' || monitor.type === 'ping' "> <div class="mb-3" v-if="monitor.type === 'port' || monitor.type === 'ping' ">

View File

@ -24,7 +24,6 @@ const aryIannaTimeZones = [
'Asia/Yerevan', 'Asia/Yerevan',
'Antarctica/Casey', 'Antarctica/Casey',
'Antarctica/Davis', 'Antarctica/Davis',
'Antarctica/DumontDUrville', // https://bugs.chromium.org/p/chromium/issues/detail?id=928068
'Antarctica/Mawson', 'Antarctica/Mawson',
'Antarctica/Palmer', 'Antarctica/Palmer',
'Antarctica/Rothera', 'Antarctica/Rothera',
@ -195,7 +194,6 @@ const aryIannaTimeZones = [
'Asia/Seoul', 'Asia/Seoul',
'Asia/Almaty', 'Asia/Almaty',
'Asia/Qyzylorda', 'Asia/Qyzylorda',
'Asia/Qostanay', // https://bugs.chromium.org/p/chromium/issues/detail?id=928068
'Asia/Aqtobe', 'Asia/Aqtobe',
'Asia/Aqtau', 'Asia/Aqtau',
'Asia/Atyrau', 'Asia/Atyrau',