mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-27 16:54:04 +00:00
Use frontend timeout
Addresses https://github.com/louislam/uptime-kuma/pull/4717#discussion_r1585616669
This commit is contained in:
parent
d83c2b90c9
commit
f059d54349
3 changed files with 18 additions and 6 deletions
|
@ -13,7 +13,7 @@ class SNMPMonitorType extends MonitorType {
|
||||||
const options = {
|
const options = {
|
||||||
port: monitor.port || "161",
|
port: monitor.port || "161",
|
||||||
retries: monitor.maxretries,
|
retries: monitor.maxretries,
|
||||||
timeout: 1000,
|
timeout: monitor.timeout * 1000,
|
||||||
version: getKey(snmp.Version, monitor.snmpVersion) || snmp.Version2c,
|
version: getKey(snmp.Version, monitor.snmpVersion) || snmp.Version2c,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -91,8 +91,13 @@ class SNMPMonitorType extends MonitorType {
|
||||||
session.close();
|
session.close();
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
heartbeat.status = DOWN;
|
if (err instanceof snmp.RequestTimedOutError) {
|
||||||
heartbeat.msg = `SNMP Error: ${err.message}`;
|
heartbeat.status = DOWN;
|
||||||
|
heartbeat.msg = `SNMP Error: Timed out after ${monitor.timeout} seconds`;
|
||||||
|
} else {
|
||||||
|
heartbeat.status = DOWN;
|
||||||
|
heartbeat.msg = `SNMP Error: ${err.message}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -835,6 +835,7 @@ let needSetup = false;
|
||||||
bean.snmpOid = monitor.snmpOid;
|
bean.snmpOid = monitor.snmpOid;
|
||||||
bean.snmpCondition = monitor.snmpCondition;
|
bean.snmpCondition = monitor.snmpCondition;
|
||||||
bean.snmpControlValue = monitor.snmpControlValue;
|
bean.snmpControlValue = monitor.snmpControlValue;
|
||||||
|
bean.timeout = monitor.timeout;
|
||||||
|
|
||||||
bean.validate();
|
bean.validate();
|
||||||
|
|
||||||
|
|
|
@ -506,8 +506,8 @@
|
||||||
<input id="retry-interval" v-model="monitor.retryInterval" type="number" class="form-control" required :min="minInterval" step="1">
|
<input id="retry-interval" v-model="monitor.retryInterval" type="number" class="form-control" required :min="minInterval" step="1">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Timeout: HTTP / Keyword only -->
|
<!-- Timeout: HTTP / Keyword / SNMP only -->
|
||||||
<div v-if="monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'json-query'" class="my-3">
|
<div v-if="monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'json-query' || monitor.type === 'snmp'" class="my-3">
|
||||||
<label for="timeout" class="form-label">{{ $t("Request Timeout") }} ({{ $t("timeoutAfter", [ monitor.timeout || clampTimeout(monitor.interval) ]) }})</label>
|
<label for="timeout" class="form-label">{{ $t("Request Timeout") }} ({{ $t("timeoutAfter", [ monitor.timeout || clampTimeout(monitor.interval) ]) }})</label>
|
||||||
<input id="timeout" v-model="monitor.timeout" type="number" class="form-control" required min="0" step="0.1">
|
<input id="timeout" v-model="monitor.timeout" type="number" class="form-control" required min="0" step="0.1">
|
||||||
</div>
|
</div>
|
||||||
|
@ -969,7 +969,6 @@ const monitorDefaults = {
|
||||||
retryInterval: 60,
|
retryInterval: 60,
|
||||||
resendInterval: 0,
|
resendInterval: 0,
|
||||||
maxretries: 0,
|
maxretries: 0,
|
||||||
timeout: 48,
|
|
||||||
notificationIDList: {},
|
notificationIDList: {},
|
||||||
ignoreTls: false,
|
ignoreTls: false,
|
||||||
upsideDown: false,
|
upsideDown: false,
|
||||||
|
@ -1321,6 +1320,13 @@ message HealthCheckResponse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set default timeout
|
||||||
|
if (this.monitor.type === "snmp") {
|
||||||
|
this.monitor.timeout = 1;
|
||||||
|
} else {
|
||||||
|
this.monitor.timeout = 48;
|
||||||
|
}
|
||||||
|
|
||||||
// Set default SNMP version
|
// Set default SNMP version
|
||||||
if (!this.monitor.snmpVersion) {
|
if (!this.monitor.snmpVersion) {
|
||||||
this.monitor.snmpVersion = "2c";
|
this.monitor.snmpVersion = "2c";
|
||||||
|
|
Loading…
Reference in a new issue