Browse Source

fix(monitor-checks): don't throw on 4xx errors

bertyhell/feature/monitor-checks
Bert Verhelst 3 years ago
parent
commit
b0d2084fda
  1. 22
      server/model/monitor.js

22
server/model/monitor.js

@ -144,6 +144,7 @@ class Monitor extends BeanModel {
rejectUnauthorized: ! this.getIgnoreTls(),
}),
maxRedirects: this.maxredirects,
validateStatus: undefined,
});
bean.msg = `${res.status} - ${res.statusText}`;
bean.ping = dayjs().valueOf() - startTime;
@ -162,28 +163,7 @@ class Monitor extends BeanModel {
debug("Cert Info Query Time: " + (dayjs().valueOf() - certInfoStartTime) + "ms");
validateMonitorChecks(res, await this.getMonitorChecks(), bean);
if (this.type === "http") {
bean.status = UP;
} else {
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 = UP;
} else {
throw new Error(bean.msg + ", but keyword is not found");
}
}
} else if (this.type === "port") {
bean.ping = await tcping(this.hostname, this.port);
bean.msg = "";

Loading…
Cancel
Save