note 32229 added to function.snmpwalk
| From: | tony at uwood dot net | Date: | Wed, 21 May 2003 00:47:55 +0000 |
| Subject: | note 32229 added to function.snmpwalk | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-48705@lists.php.net to get a copy of this message | ||
I upgraded to net-snmp-5.0.6 and php 4.3.1 and had major league problems with my snmp.
1. snmpgets and walks started returning as "INTEGER: 1" or "STRING: POS2/0" and
such in stead of just the value.
snmp_set_quick_print(1) cured this problem.
2.snmpwalk no longer supported the "interfaces.ifTable.ifEntry.ifDescr" string format for
the string object_id.
I used snmpbulkwalk from the commandline to see what the new way was.
"snmpbulkwalk -v2c -c public 1.2.3.4"
IF-MIB::ifDescr.1 = STRING: POS2/0
IF-MIB::ifDescr.2 = STRING: FastEthernet0/0
IF-MIB::ifDescr.3 = STRING: GigabitEthernet1/0
IF-MIB::ifDescr.4 = STRING: Ethernet4/0
...
/********old code for snmpwalk of ifDescr**********/
<?php
$ifDesc = snmpwalk("1.2.3.4", "public",
"interfaces.ifTable.ifEntry.ifDescr");
for ($i = 0; $i < count($ifDesc); ++$i)
{
print "$ifDesc[$i]\n";
}
?>
/*end old*/
/********new code for snmpwalk of ifDescr**********/
<?php
snmp_set_quick_print(1); //prevent "STRING: " output
$host = "1.2.3.4";
$community = "public";
$ifDesc = snmpwalk($host, $community, "IF-MIB::ifDescr");
for ($i = 0; $i < count($ifDesc); ++$i)
{
print "$ifDesc[$i]\n";
}
?>
/*end new*/
----
Manual Page -- http://www.php.net/manual/en/function.snmpwalk.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32229
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32229&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32229&report=yes