mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-12 16:44:12 -08:00
Added docker container monitor
This commit is contained in:
parent
2bf9764cec
commit
b0259b5592
10
db/patch-add-docker-columns.sql
Normal file
10
db/patch-add-docker-columns.sql
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD docker_daemon VARCHAR(255);
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD docker_container VARCHAR(255);
|
||||||
|
|
||||||
|
COMMIT;
|
|
@ -53,6 +53,7 @@ class Database {
|
||||||
"patch-2fa-invalidate-used-token.sql": true,
|
"patch-2fa-invalidate-used-token.sql": true,
|
||||||
"patch-notification_sent_history.sql": true,
|
"patch-notification_sent_history.sql": true,
|
||||||
"patch-monitor-basic-auth.sql": true,
|
"patch-monitor-basic-auth.sql": true,
|
||||||
|
"patch-add-docker-columns.sql": true
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -77,6 +77,8 @@ class Monitor extends BeanModel {
|
||||||
dns_resolve_server: this.dns_resolve_server,
|
dns_resolve_server: this.dns_resolve_server,
|
||||||
dns_last_result: this.dns_last_result,
|
dns_last_result: this.dns_last_result,
|
||||||
pushToken: this.pushToken,
|
pushToken: this.pushToken,
|
||||||
|
docker_container: this.docker_container,
|
||||||
|
docker_daemon: this.docker_daemon,
|
||||||
notificationIDList,
|
notificationIDList,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
};
|
};
|
||||||
|
@ -347,6 +349,27 @@ class Monitor extends BeanModel {
|
||||||
throw new Error("Server not found on Steam");
|
throw new Error("Server not found on Steam");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (this.type === "docker") {
|
||||||
|
debug(`[${this.name}] Prepare Options for axios`);
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
url: `/containers/${this.docker_container}/json`,
|
||||||
|
headers: {
|
||||||
|
"Accept": "*/*",
|
||||||
|
"User-Agent": "Uptime-Kuma/" + version,
|
||||||
|
},
|
||||||
|
socketPath: this.docker_daemon,
|
||||||
|
httpsAgent: new https.Agent({
|
||||||
|
maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940)
|
||||||
|
rejectUnauthorized: ! this.getIgnoreTls(),
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
debug(`[${this.name}] Axios Request`);
|
||||||
|
let res = await axios.request(options);
|
||||||
|
if (res.data.State.Running) {
|
||||||
|
bean.status = UP;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
bean.msg = "Unknown Monitor Type";
|
bean.msg = "Unknown Monitor Type";
|
||||||
bean.status = PENDING;
|
bean.status = PENDING;
|
||||||
|
|
|
@ -32,6 +32,9 @@
|
||||||
<option value="steam">
|
<option value="steam">
|
||||||
Steam Game Server
|
Steam Game Server
|
||||||
</option>
|
</option>
|
||||||
|
<option value="docker">
|
||||||
|
Docker Container
|
||||||
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -115,6 +118,20 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<!-- Docker Container Name / ID -->
|
||||||
|
<!-- For Docker Type -->
|
||||||
|
<div v-if="monitor.type === 'docker'" class="my-3">
|
||||||
|
<label for="docker_container" class="form-label">{{ $t("Container Name / ID") }}</label>
|
||||||
|
<input id="docker_container" v-model="monitor.docker_container" type="text" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Docker Daemon -->
|
||||||
|
<!-- For Docker Type -->
|
||||||
|
<div v-if="monitor.type === 'docker'" class="my-3">
|
||||||
|
<label for="docker_daemon" class="form-label">{{ $t("Docker Daemon") }}</label>
|
||||||
|
<input id="docker_daemon" v-model="monitor.docker_daemon" type="text" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Interval -->
|
<!-- Interval -->
|
||||||
<div class="my-3">
|
<div class="my-3">
|
||||||
<label for="interval" class="form-label">{{ $t("Heartbeat Interval") }} ({{ $t("checkEverySecond", [ monitor.interval ]) }})</label>
|
<label for="interval" class="form-label">{{ $t("Heartbeat Interval") }} ({{ $t("checkEverySecond", [ monitor.interval ]) }})</label>
|
||||||
|
@ -439,6 +456,8 @@ export default {
|
||||||
accepted_statuscodes: ["200-299"],
|
accepted_statuscodes: ["200-299"],
|
||||||
dns_resolve_type: "A",
|
dns_resolve_type: "A",
|
||||||
dns_resolve_server: "1.1.1.1",
|
dns_resolve_server: "1.1.1.1",
|
||||||
|
docker_container: "",
|
||||||
|
docker_daemon: "/var/run/docker.sock"
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let i = 0; i < this.$root.notificationList.length; i++) {
|
for (let i = 0; i < this.$root.notificationList.length; i++) {
|
||||||
|
|
Loading…
Reference in a new issue