As the title suggests the getSubtree function doesn't return all oids if they are not in order. Example below:
When requesting 1.3.6.1.2.1.17.4.3.1.1 with snmpwalk I get the below output and a lot more. You will see after they are not ordered which is fine as they are returned anyway.
OID=.1.3.6.1.2.1.17.4.3.1.1.0.34.100.181.251.62, Type=OctetString, Value=
OID=.1.3.6.1.2.1.17.4.3.1.1.120.165.4.237.241.250, Type=OctetString, Value=
OID=.1.3.6.1.2.1.17.4.3.1.1.244.206.70.191.124.155, Type=OctetString, Value=
OID=.1.3.6.1.2.1.17.4.3.1.1.244.206.70.191.124.154, Type=OctetString, Value=
OID=.1.3.6.1.2.1.17.4.3.1.1.120.227.181.207.79.69, Type=OctetString, Value=
OID=.1.3.6.1.2.1.17.4.3.1.1.208.23.194.138.146.72, Type=OctetString, Value=
OID=.1.3.6.1.2.1.17.4.3.1.1.2.156.2.161.21.112, Type=OctetString, Value=
.... (there are alot more after this)
Now if I use snmp-native I get nothing as the result. But looking deeper if I add some logging in the getSubtree method I find it stops at 244.206.70.191.124.155 because the next entry is 244.206.70.191.124.154. Which is less than the original.
[ 1, 3, 6, 1, 2, 1, 17, 4, 3, 1, 1, 0, 34, 100, 181, 251, 62 ]
[ 1, 3, 6, 1, 2, 1, 17, 4, 3, 1, 1, 120, 165, 4, 237, 241, 250 ]
[ 1, 3, 6, 1, 2, 1, 17, 4, 3, 1, 1, 244, 206, 70, 191, 124, 155 ]
So this led me to believe the problem lies in the compareOids function. Specifically this piece of code which checks if each value is greater than the last.
for (i = 0; i < mlen; i++) {
if (oidA[i] > oidB[i]) {
return -1;
} else if (oidB[i] > oidA[i]) {
return 1;
}
}
Now I changed it to this which is working from what I can tell but the original oid needs to be parsed in.
if(originalOid.length < mlen) {
for(var i = 0; i < originalOid.length; i++) {
// Check the oids contain the root oid if they don't stop
if(originalOid[i] != oidA[i] || originalOid[i] != oidB[i]) {
return -1;
}
}
return 1;
} else {
return -1;
}
Is there another way to retrieve a list of oids like this that I am missing? If not would be great if getSubtree would support these.
As the title suggests the getSubtree function doesn't return all oids if they are not in order. Example below:
When requesting 1.3.6.1.2.1.17.4.3.1.1 with snmpwalk I get the below output and a lot more. You will see after they are not ordered which is fine as they are returned anyway.
Now if I use snmp-native I get nothing as the result. But looking deeper if I add some logging in the getSubtree method I find it stops at 244.206.70.191.124.155 because the next entry is 244.206.70.191.124.154. Which is less than the original.
So this led me to believe the problem lies in the compareOids function. Specifically this piece of code which checks if each value is greater than the last.
Now I changed it to this which is working from what I can tell but the original oid needs to be parsed in.
Is there another way to retrieve a list of oids like this that I am missing? If not would be great if getSubtree would support these.