Separate error cases for SNMP varbind returns

pull/4717/head
Matt Visnovsky 7 months ago
parent c68b1c6274
commit e9b52eb0e7

@ -36,10 +36,14 @@ class SNMPMonitorType extends MonitorType {
});
log.debug("monitor", `SNMP: Received varbinds (Type: ${snmp.ObjectType[varbinds[0].type]} Value: ${varbinds[0].value}`);
// Verify if any varbinds were returned from the SNMP session or if the varbind type indicates a non-existent instance.
if (varbinds.length === 0 || varbinds[0].type === snmp.ObjectType.NoSuchInstance) {
// Verify if any varbinds were returned from the SNMP session.
if (varbinds.length === 0) {
throw new Error(`No varbinds returned from SNMP session (OID: ${monitor.snmpOid})`);
}
// Check if the varbind type indicates a non-existent instance.
if (varbinds[0].type === snmp.ObjectType.NoSuchInstance) {
throw new Error(`The SNMP query was successful but no varbinds returned for OID: ${monitor.snmpOid}`);
}
// We restrict querying to one OID per monitor, therefore `varbinds[0]` will always contain the value we're interested in.

Loading…
Cancel
Save