Closed jozefrebjak closed 2 years ago
Still learning this library myself, but I notice that you do not have the loop right after the walk to get all the returns..
I think you still need this from the example:
# Keep the walk going until there are no more OIDs left
while($walk->hasOids()) {
try {
# Get the next OID in the walk
$oid = $walk->next();
echo sprintf("%s = %s", $oid->getOid(), $oid->getValue()).PHP_EOL;
} catch (\Exception $e) {
# If we had an issue, display it here (network timeout, etc)
echo "Unable to retrieve OID. ".$e->getMessage().PHP_EOL;
}
}
php ./test2.php
1.3.6.1.2.1.2.2.1.1.1 = 1
1.3.6.1.2.1.2.2.1.1.2 = 2
1.3.6.1.2.1.2.2.1.1.3 = 3
Still learning this library myself, but I notice that you do not have the loop right after the walk to get all the returns..
I think you still need this from the example:
# Keep the walk going until there are no more OIDs left while($walk->hasOids()) { try { # Get the next OID in the walk $oid = $walk->next(); echo sprintf("%s = %s", $oid->getOid(), $oid->getValue()).PHP_EOL; } catch (\Exception $e) { # If we had an issue, display it here (network timeout, etc) echo "Unable to retrieve OID. ".$e->getMessage().PHP_EOL; } }
php ./test2.php 1.3.6.1.2.1.2.2.1.1.1 = 1 1.3.6.1.2.1.2.2.1.1.2 = 2 1.3.6.1.2.1.2.2.1.1.3 = 3
Yes, this is the intended way of performing a walk for his case. It's interactive, so just instantiating it is not enough. You must iteratively call hasOids()
and next()
.
Closing this out since it was answered. Please re-open if you're still having issues. Thanks!
Hello @ChadSikorra,
I am taking look at this libary and I would like to use it in my project. But, how to use SnmpWalk ?
For example I wan to read values of oid
1.3.6.1.2.1.2.2.1.1
. With classic snmpwalk I can get values with:but when I am trying to get values with SnmpWalk function from this libaray I can't get values for example:
I expect that count can't be 0
@ChadSikorra can you help me what I am doing wrong ?
Thank you.