Matt Visnovsky 2024-05-05 15:47:43 -06:00
parent 9053b48030
commit 4386d0afad
2 changed files with 6 additions and 6 deletions

View file

@ -25,9 +25,7 @@ class SNMPMonitorType extends MonitorType {
// Handle errors during session creation // Handle errors during session creation
session.on("error", (error) => { session.on("error", (error) => {
heartbeat.status = DOWN; throw new Error(`Error creating SNMP session: ${error.message}`);
heartbeat.msg = `SNMP: Error creating SNMP session: ${error.message}`;
log.debug("monitor", heartbeat.msg);
}); });
const varbinds = await new Promise((resolve, reject) => { const varbinds = await new Promise((resolve, reject) => {
@ -35,11 +33,11 @@ class SNMPMonitorType extends MonitorType {
if (error) { if (error) {
reject(error); reject(error);
} else { } else {
log.debug("monitor", `SNMP: Received varbinds (Type=${getKey(snmp.ObjectType, varbinds[0].type)}): ${varbinds[0].value}`);
resolve(varbinds); resolve(varbinds);
} }
}); });
}); });
log.debug("monitor", `SNMP: Received varbinds (Type=${getKey(snmp.ObjectType, varbinds[0].type)}): ${varbinds[0].value}`);
// Verify if any varbinds were returned from the SNMP session or if the varbind type indicates a non-existent instance. // Verify if any varbinds were returned from the SNMP session or if the varbind type indicates a non-existent instance.
// The `getKey` method retrieves the key associated with the varbind type from the snmp.ObjectType object. // The `getKey` method retrieves the key associated with the varbind type from the snmp.ObjectType object.

View file

@ -1320,11 +1320,13 @@ message HealthCheckResponse {
} }
} }
// Set default timeout // Set a default timeout of 1 second for SNMP monitors when querying a single OID.
// Since we're only querying a single OID, a shorter timeout is sufficient to ensure timely responses
// without unnecessary delays. This helps keep the monitoring process lightweight and efficient.
if (this.monitor.type === "snmp") { if (this.monitor.type === "snmp") {
this.monitor.timeout = 1; this.monitor.timeout = 1;
} else { } else {
this.monitor.timeout = 48; this.monitor.timeout = 48; // Default timeout for other monitor types
} }
// Set default SNMP version // Set default SNMP version