Use frontend timeout

Addresses https://github.com/louislam/uptime-kuma/pull/4717#discussion_r1585616669
This commit is contained in:
Matt Visnovsky
2024-05-02 15:07:22 -06:00
parent d83c2b90c9
commit f059d54349
3 changed files with 18 additions and 6 deletions

View File

@@ -13,7 +13,7 @@ class SNMPMonitorType extends MonitorType {
const options = {
port: monitor.port || "161",
retries: monitor.maxretries,
timeout: 1000,
timeout: monitor.timeout * 1000,
version: getKey(snmp.Version, monitor.snmpVersion) || snmp.Version2c,
};
@@ -91,8 +91,13 @@ class SNMPMonitorType extends MonitorType {
session.close();
} catch (err) {
heartbeat.status = DOWN;
heartbeat.msg = `SNMP Error: ${err.message}`;
if (err instanceof snmp.RequestTimedOutError) {
heartbeat.status = DOWN;
heartbeat.msg = `SNMP Error: Timed out after ${monitor.timeout} seconds`;
} else {
heartbeat.status = DOWN;
heartbeat.msg = `SNMP Error: ${err.message}`;
}
}
}