|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-02-23 04:38 UTC] Gregg dot Nelson at Co dot Ramsey dot MN dot US
Description:
------------
Running:
PHP-5.0.3
Net-SNMP-5.2.1
Apache-(httpd-2.0.530)
PHP config Line
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-snmp
No changes to php.ini
-----------------------------------------------------------------------
Executing snmpwalk from command line (RH Linux 9) produces different
results from snmpwalk called from php.
I have a Cisco 6509 configured for Server Load Balancing.
The MIB tree for this starts at OID .1.3.6.1.4.1.9.9.161
With the following command from the Linux shell I get the folowing results:
---------------------------------------------------------------------------
snmpwalk -v2c -crmsy 192.168.108.254 .1.3.6.1.4.1.9.9.161
SNMPv2-SMI::enterprises.9.9.161.1.1.1.1.2.0 = Counter32: 49602212
SNMPv2-SMI::enterprises.9.9.161.1.1.1.1.3.0 = Counter64: 49602212
SNMPv2-SMI::enterprises.9.9.161.1.1.1.1.4.0 = Counter32: 2776480
SNMPv2-SMI::enterprises.9.9.161.1.1.1.1.5.0 = Counter64: 2776480
SNMPv2-SMI::enterprises.9.9.161.1.1.1.1.6.0 = Counter32: 26014
SNMPv2-SMI::enterprises.9.9.161.1.1.1.1.7.0 = Counter64: 26014
SNMPv2-SMI::enterprises.9.9.161.1.1.1.1.8.0 = Counter32: 26013
SNMPv2-SMI::enterprises.9.9.161.1.1.1.1.9.0 = Counter64: 26013
SNMPv2-SMI::enterprises.9.9.161.1.1.1.1.10.0 = Counter32: 26014
SNMPv2-SMI::enterprises.9.9.161.1.1.1.1.11.0 = Counter64: 26014
SNMPv2-SMI::enterprises.9.9.161.1.1.1.1.12.0 = Counter32: 6
SNMPv2-SMI::enterprises.9.9.161.1.1.1.1.13.0 = Counter64: 6
SNMPv2-SMI::enterprises.9.9.161.1.1.1.1.14.0 = Counter32: 0
SNMPv2-SMI::enterprises.9.9.161.1.1.1.1.15.0 = Counter64: 0
SNMPv2-SMI::enterprises.9.9.161.1.2.1.1.2.0.8.67.65.70.69.84.69.83.84 = INTEGER: 1
SNMPv2-SMI::enterprises.9.9.161.1.2.1.1.3.0.8.67.65.70.69.84.69.83.84 = INTEGER: 3
SNMPv2-SMI::enterprises.9.9.161.1.2.1.1.4.0.8.67.65.70.69.84.69.83.84 = Gauge32: 2
SNMPv2-SMI::enterprises.9.9.161.1.2.1.1.5.0.8.67.65.70.69.84.69.83.84 = Gauge32: 0
SNMPv2-SMI::enterprises.9.9.161.1.2.1.1.6.0.8.67.65.70.69.84.69.83.84 = INTEGER: 1
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.4.0.8.67.65.70.69.84.69.83.84.192.168.110.15.0 = INTEGER: 2
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.4.0.8.67.65.70.69.84.69.83.84.192.168.110.46.0 = INTEGER: 2
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.5.0.8.67.65.70.69.84.69.83.84.192.168.110.15.0 = Gauge32: 0
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.5.0.8.67.65.70.69.84.69.83.84.192.168.110.46.0 = Gauge32: 0
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.6.0.8.67.65.70.69.84.69.83.84.192.168.110.15.0 = Gauge32: 0
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.6.0.8.67.65.70.69.84.69.83.84.192.168.110.46.0 = Gauge32: 0
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.7.0.8.67.65.70.69.84.69.83.84.192.168.110.15.0 = Gauge32: 4294967295
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.7.0.8.67.65.70.69.84.69.83.84.192.168.110.46.0 = Gauge32: 4294967295
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.8.0.8.67.65.70.69.84.69.83.84.192.168.110.15.0 = Gauge32: 8
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.8.0.8.67.65.70.69.84.69.83.84.192.168.110.46.0 = Gauge32: 8
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.9.0.8.67.65.70.69.84.69.83.84.192.168.110.15.0 = Gauge32: 8
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.9.0.8.67.65.70.69.84.69.83.84.192.168.110.46.0 = Gauge32: 8
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.10.0.8.67.65.70.69.84.69.83.84.192.168.110.15.0 = Gauge32: 0
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.10.0.8.67.65.70.69.84.69.83.84.192.168.110.46.0 = Gauge32: 0
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.11.0.8.67.65.70.69.84.69.83.84.192.168.110.15.0 = Gauge32: 1
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.11.0.8.67.65.70.69.84.69.83.84.192.168.110.46.0 = Gauge32: 1
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.12.0.8.67.65.70.69.84.69.83.84.192.168.110.15.0 = INTEGER: 360
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.12.0.8.67.65.70.69.84.69.83.84.192.168.110.46.0 = INTEGER: 360
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.13.0.8.67.65.70.69.84.69.83.84.192.168.110.15.0 = Gauge32: 1
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.13.0.8.67.65.70.69.84.69.83.84.192.168.110.46.0 = Gauge32: 1
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.14.0.8.67.65.70.69.84.69.83.84.192.168.110.15.0 = Gauge32: 1
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.14.0.8.67.65.70.69.84.69.83.84.192.168.110.46.0 = Gauge32: 1
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.15.0.8.67.65.70.69.84.69.83.84.192.168.110.15.0 = Gauge32: 0
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.15.0.8.67.65.70.69.84.69.83.84.192.168.110.46.0 = Gauge32: 0
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.16.0.8.67.65.70.69.84.69.83.84.192.168.110.15.0 = Counter32: 5
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.16.0.8.67.65.70.69.84.69.83.84.192.168.110.46.0 = Counter32: 2
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.17.0.8.67.65.70.69.84.69.83.84.192.168.110.15.0 = INTEGER: 1
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.17.0.8.67.65.70.69.84.69.83.84.192.168.110.46.0 = INTEGER: 1
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.18.0.8.67.65.70.69.84.69.83.84.192.168.110.15.0 = Counter32: 12890
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.18.0.8.67.65.70.69.84.69.83.84.192.168.110.46.0 = Counter32: 13123
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.19.0.8.67.65.70.69.84.69.83.84.192.168.110.15.0 = Counter64: 12890
SNMPv2-SMI::enterprises.9.9.161.1.3.1.1.19.0.8.67.65.70.69.84.69.83.84.192.168.110.46.0 = Counter64: 13123
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.2.0.10.72.83.67.65.70.69.84.69.83.84 = INTEGER: 2
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.3.0.10.72.83.67.65.70.69.84.69.83.84 = Gauge32: 7
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.4.0.10.72.83.67.65.70.69.84.69.83.84 = IpAddress: 192.168.110.110
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.5.0.10.72.83.67.65.70.69.84.69.83.84 = INTEGER: 80
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.6.0.10.72.83.67.65.70.69.84.69.83.84 = INTEGER: 6
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.7.0.10.72.83.67.65.70.69.84.69.83.84 = INTEGER: 1
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.8.0.10.72.83.67.65.70.69.84.69.83.84 = INTEGER: 1
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.9.0.10.72.83.67.65.70.69.84.69.83.84 = STRING: "CAFETEST"
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.10.0.10.72.83.67.65.70.69.84.69.83.84 = Gauge32: 10
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.11.0.10.72.83.67.65.70.69.84.69.83.84 = Gauge32: 3600
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.12.0.10.72.83.67.65.70.69.84.69.83.84 = INTEGER: 0
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.13.0.10.72.83.67.65.70.69.84.69.83.84 = Gauge32: 0
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.14.0.10.72.83.67.65.70.69.84.69.83.84 = Gauge32: 0
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.15.0.10.72.83.67.65.70.69.84.69.83.84 = Gauge32: 10
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.11.0.10.72.83.67.65.70.69.84.69.83.84 = Gauge32: 3600
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.12.0.10.72.83.67.65.70.69.84.69.83.84 = INTEGER: 0
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.13.0.10.72.83.67.65.70.69.84.69.83.84 = Gauge32: 0
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.14.0.10.72.83.67.65.70.69.84.69.83.84 = Gauge32: 0
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.15.0.10.72.83.67.65.70.69.84.69.83.84 = Gauge32: 0
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.16.0.10.72.83.67.65.70.69.84.69.83.84 = INTEGER: 1
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.17.0.10.72.83.67.65.70.69.84.69.83.84 = Gauge32: 0
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.18.0.10.72.83.67.65.70.69.84.69.83.84 = Counter32: 26014
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.19.0.10.72.83.67.65.70.69.84.69.83.84 = Counter64: 26014
SNMPv2-SMI::enterprises.9.9.161.1.4.1.1.20.0.10.72.83.67.65.70.69.84.69.83.84 = IpAddress: 255.255.255.255
SNMPv2-SMI::enterprises.9.9.161.1.8.1.0 = INTEGER: 2
SNMPv2-SMI::enterprises.9.9.161.1.8.2.0 = INTEGER: 2
-----------------------------------------------------------------------------------
Running the following php script produces the following results.
<html><head><title> SLB info</title></head><body>
<?php
$a = snmpwalk("192.168.108.254", "rmsy", ".1.3.6.1.4.1.9.9.161");
for ($i=0; $i < count($a); $i++) {echo " {$a[$i]}<br />";}
?>
</body></html>
-----------------------------------------------------------------------------------
Counter32: 49609797
Counter32: 2776670
Counter32: 26014
Counter32: 26013
Counter32: 26014
Counter32: 6
Counter32: 0
INTEGER: 1
INTEGER: 3
Gauge32: 2
Gauge32: 0
INTEGER: 1
INTEGER: 2
INTEGER: 2
Gauge32: 0
Gauge32: 0
Gauge32: 0
Gauge32: 0
Gauge32: 4294967295
Gauge32: 4294967295
Gauge32: 8
Gauge32: 8
Gauge32: 8
Gauge32: 8
Gauge32: 0
Gauge32: 0
Gauge32: 1
Gauge32: 1
INTEGER: 360
INTEGER: 360
Gauge32: 1
Gauge32: 1
Gauge32: 1
Gauge32: 1
Gauge32: 0
Gauge32: 0
Counter32: 5
Counter32: 2
INTEGER: 1
INTEGER: 1
Counter32: 12890
Counter32: 13123
INTEGER: 2
Gauge32: 7
IpAddress: 192.168.110.110
INTEGER: 80
INTEGER: 6
INTEGER: 1
INTEGER: 1
STRING: "CAFETEST"
Gauge32: 10
Gauge32: 3600
INTEGER: 0
Gauge32: 0
Gauge32: 0
Gauge32: 0
INTEGER: 1
Gauge32: 0
Counter32: 26014
IpAddress: 255.255.255.255
INTEGER: 2
INTEGER: 2
------------------------------------------------------------------------------------------
Most of the indexed items are missing from the output. I believe this is because
the php snmpwalk function does not actually call snmpwalk. It uses a combination
of snmpget and snmpgetnext calls which do not visit every branch in the MIB tree.
Because the indexes are part of the OID field the output of snmpget and snmpgetnext
calls are missing vital information.
I would suggest the php snmpwalk function be coded to call the actual snmpwalk routine.
There would then be no need for the snmprealwalk and snmpwalkoid functions.
Reproduce code:
---------------
command line call:
---------------------------------------------------------
snmpwalk -v2c -crmsy 192.168.108.254 .1.3.6.1.4.1.9.9.161
php script:
---------------------------------------------------------
<html><head><title> SLB info</title></head><body>
<?php
$a = snmpwalk("192.168.108.254", "rmsy", ".1.3.6.1.4.1.9.9.161");
for ($i=0; $i < count($a); $i++) {echo " {$a[$i]}<br />";}
?>
</body></html>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 18:00:02 2025 UTC |
The following bash script shows that snmpwalk and snmpget/getnext produce the same number of lines and output when called from the command line.... #!/bin/bash # # Compare snmpwalk and snmpget/getnext output. # #set -vx walkoid="SNMPv2-SMI::enterprises.9.9.161" lc=$(snmpwalk -v2c -crmsy 192.168.108.254 $walkoid|wc -l) echo snmpwalk: $lc lines. startmib="$walkoid.1.1.1.1.2.0" nextmib=$startmib oper="snmpget";lc=0 while :; do mib=$($oper -v2c -crmsy 192.168.108.254 $nextmib) oper="snmpgetnext" if [ $(echo $mib|grep ".9.9.161"|wc -l) -eq 0 ];then break;fi # echo $mib let lc=lc+1 nextmib=${mib%%\ =\ *} done echo snmpget/next: $lc lines. exit