mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 14:54:05 +00:00
Separate error cases for SNMP varbind returns
This commit is contained in:
parent
c68b1c6274
commit
e9b52eb0e7
1 changed files with 6 additions and 2 deletions
|
@ -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…
Reference in a new issue