Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit 532db8b

Browse files
author
Brice Figureau
committed
Improved GETNEXT support
Apparently things have changed in newer version of net-snmp (like 5.4.3). And when used with GETBULK, we weren't correctly returning the next OID.
1 parent 1d363a3 commit 532db8b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

mysql-snmp

+7-3
Original file line numberDiff line numberDiff line change
@@ -978,10 +978,10 @@ sub my_snmp_handler {
978978
}
979979

980980
if ($mode == MODE_GETNEXT) {
981-
if ($oid < $lowestOid) {
981+
if (NetSNMP::OID::compare($oid, $lowestOid) < 0) {
982982
set_value($request, $lowestOid, $request_info);
983983
}
984-
elsif ($oid < $highestOid) #request is somewhere in our range, so return first one after it
984+
elsif (NetSNMP::OID::compare($oid, $highestOid) <= 0) #request is somewhere in our range, so return first one after it
985985
{
986986
my $lasti = 0;
987987
my $i = 0;
@@ -991,10 +991,14 @@ sub my_snmp_handler {
991991
do {
992992
$oidToUse = $ks[$i];
993993
$i++;
994-
} while (NetSNMP::OID::compare($oid, $oidToUse) > -1 and $i <= scalar @ks);
994+
} while (NetSNMP::OID::compare($oid, $oidToUse) > -1 and $i < scalar @ks);
995995

996996
#got one to return
997997
if (defined $oidToUse) {
998+
if (NetSNMP::OID::compare($oid, $oidToUse) == 0) {
999+
dolog(LOG_DEBUG, "GETNEXT $oid == $oidToUse, no next, returning nothing"); if ($opt{verbose})
1000+
next;
1001+
}
9981002
dolog(LOG_DEBUG, "Next oid to $oid is $oidToUse") if ($opt{verbose});
9991003
while (!set_value($request, $oidToUse, $request_info)) {
10001004
# got not value, we need to get the next oid

0 commit comments

Comments
 (0)