mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-10-01 01:25:45 -04:00
Merge pull request #2169 from louislam/fix-docker-monitor
Fix Docker container monitor not working in 1.18.1
This commit is contained in:
commit
c538983b87
@ -75,7 +75,7 @@ class DockerHost {
|
|||||||
if (dockerHost.dockerType === "socket") {
|
if (dockerHost.dockerType === "socket") {
|
||||||
options.socketPath = dockerHost.dockerDaemon;
|
options.socketPath = dockerHost.dockerDaemon;
|
||||||
} else if (dockerHost.dockerType === "tcp") {
|
} else if (dockerHost.dockerType === "tcp") {
|
||||||
options.baseURL = dockerHost.dockerDaemon;
|
options.baseURL = DockerHost.patchDockerURL(dockerHost.dockerDaemon);
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = await axios.request(options);
|
let res = await axios.request(options);
|
||||||
@ -99,6 +99,18 @@ class DockerHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Since axios 0.27.X, it does not accept `tcp://` protocol.
|
||||||
|
* Change it to `http://` on the fly in order to fix it. (https://github.com/louislam/uptime-kuma/issues/2165)
|
||||||
|
*/
|
||||||
|
static patchDockerURL(url) {
|
||||||
|
if (typeof url === "string") {
|
||||||
|
// Replace the first occurrence only with g
|
||||||
|
return url.replace(/tcp:\/\//g, "http://");
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -17,6 +17,7 @@ const version = require("../../package.json").version;
|
|||||||
const apicache = require("../modules/apicache");
|
const apicache = require("../modules/apicache");
|
||||||
const { UptimeKumaServer } = require("../uptime-kuma-server");
|
const { UptimeKumaServer } = require("../uptime-kuma-server");
|
||||||
const { CacheableDnsHttpAgent } = require("../cacheable-dns-http-agent");
|
const { CacheableDnsHttpAgent } = require("../cacheable-dns-http-agent");
|
||||||
|
const { DockerHost } = require("../docker");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* status:
|
* status:
|
||||||
@ -498,7 +499,7 @@ class Monitor extends BeanModel {
|
|||||||
if (dockerHost._dockerType === "socket") {
|
if (dockerHost._dockerType === "socket") {
|
||||||
options.socketPath = dockerHost._dockerDaemon;
|
options.socketPath = dockerHost._dockerDaemon;
|
||||||
} else if (dockerHost._dockerType === "tcp") {
|
} else if (dockerHost._dockerType === "tcp") {
|
||||||
options.baseURL = dockerHost._dockerDaemon;
|
options.baseURL = DockerHost.patchDockerURL(dockerHost._dockerDaemon);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug(`[${this.name}] Axios Request`);
|
log.debug(`[${this.name}] Axios Request`);
|
||||||
|
@ -56,7 +56,7 @@ module.exports.dockerSocketHandler = (socket) => {
|
|||||||
let amount = await DockerHost.testDockerHost(dockerHost);
|
let amount = await DockerHost.testDockerHost(dockerHost);
|
||||||
let msg;
|
let msg;
|
||||||
|
|
||||||
if (amount > 1) {
|
if (amount >= 1) {
|
||||||
msg = "Connected Successfully. Amount of containers: " + amount;
|
msg = "Connected Successfully. Amount of containers: " + amount;
|
||||||
} else {
|
} else {
|
||||||
msg = "Connected Successfully, but there are no containers?";
|
msg = "Connected Successfully, but there are no containers?";
|
||||||
|
@ -30,7 +30,8 @@
|
|||||||
{{ $t("Examples") }}:
|
{{ $t("Examples") }}:
|
||||||
<ul>
|
<ul>
|
||||||
<li>/var/run/docker.sock</li>
|
<li>/var/run/docker.sock</li>
|
||||||
<li>tcp://localhost:2375</li>
|
<li>http://localhost:2375</li>
|
||||||
|
<li>https://localhost:2376 (TLS)</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user