php的snmp2_real_walk函数无法获得正确的cpu编号

时间:2013-07-29 12:19:00

标签: php snmp cacti

所有。我有一个关于snmp2_real_walk的问题 我的PHP版本:PHP 5.1.6操作系统:Red Hat Enterprise Linux Server release 5.5。我有一个8核的remost主机。而localhost的机器cpu编号也是8核心 当我使用snmpwalk命令时,如下所示:

[root@webjk tmp]# snmpwalk -v 2c -c public xxx.xxx.xxx.xxx .1.3.6.1.2.1.25.3.3.1
HOST-RESOURCES-MIB::hrProcessorFrwID.768 = OID: SNMPv2-SMI::zeroDotZero  
HOST-RESOURCES-MIB::hrProcessorFrwID.769 = OID: SNMPv2-SMI::zeroDotZero  
HOST-RESOURCES-MIB::hrProcessorFrwID.770 = OID: SNMPv2-SMI::zeroDotZero  
HOST-RESOURCES-MIB::hrProcessorFrwID.771 = OID: SNMPv2-SMI::zeroDotZero  
HOST-RESOURCES-MIB::hrProcessorFrwID.772 = OID: SNMPv2-SMI::zeroDotZero  
HOST-RESOURCES-MIB::hrProcessorFrwID.773 = OID: SNMPv2-SMI::zeroDotZero  
HOST-RESOURCES-MIB::hrProcessorFrwID.774 = OID: SNMPv2-SMI::zeroDotZero   
HOST-RESOURCES-MIB::hrProcessorFrwID.775 = OID: SNMPv2-SMI::zeroDotZero  
HOST-RESOURCES-MIB::hrProcessorLoad.768 = INTEGER: 1  
HOST-RESOURCES-MIB::hrProcessorLoad.769 = INTEGER: 1  
HOST-RESOURCES-MIB::hrProcessorLoad.770 = INTEGER: 2  
HOST-RESOURCES-MIB::hrProcessorLoad.771 = INTEGER: 1  
HOST-RESOURCES-MIB::hrProcessorLoad.772 = INTEGER: 3  
HOST-RESOURCES-MIB::hrProcessorLoad.773 = INTEGER: 1  
HOST-RESOURCES-MIB::hrProcessorLoad.774 = INTEGER: 6  
HOST-RESOURCES-MIB::hrProcessorLoad.775 = INTEGER: 13  
HOST-RESOURCES-MIB::hrProcessorLoad.775 = No more variables left in this MIB View (It is past the end of the MIB tree)

然后我使用以下php代码:

<?php
$a=snmp2_real_walk("58.211.72.38:161", "public", ".1.3.6.1.2.1.25.3.3.1", (500 * 1000), 1);
print_r($a);
?>  

结果如下:

Array
(
    [HOST-RESOURCES-MIB::hrProcessorFrwID.768] => OID: SNMPv2-SMI::zeroDotZero
    [HOST-RESOURCES-MIB::hrProcessorFrwID.769] => OID: SNMPv2-SMI::zeroDotZero
    [HOST-RESOURCES-MIB::hrProcessorFrwID.770] => OID: SNMPv2-SMI::zeroDotZero
    [HOST-RESOURCES-MIB::hrProcessorFrwID.771] => OID: SNMPv2-SMI::zeroDotZero
    [HOST-RESOURCES-MIB::hrProcessorFrwID.772] => OID: SNMPv2-SMI::zeroDotZero
    [HOST-RESOURCES-MIB::hrProcessorFrwID.773] => OID: SNMPv2-SMI::zeroDotZero
    [HOST-RESOURCES-MIB::hrProcessorFrwID.774] => OID: SNMPv2-SMI::zeroDotZero
    [HOST-RESOURCES-MIB::hrProcessorFrwID.775] => OID: SNMPv2-SMI::zeroDotZero
    [HOST-RESOURCES-MIB::hrProcessorLoad.768] => INTEGER: 1
    [HOST-RESOURCES-MIB::hrProcessorLoad.769] => INTEGER: 1
    [HOST-RESOURCES-MIB::hrProcessorLoad.770] => INTEGER: 2
    [HOST-RESOURCES-MIB::hrProcessorLoad.771] => INTEGER: 1
    [HOST-RESOURCES-MIB::hrProcessorLoad.772] => INTEGER: 2
    [HOST-RESOURCES-MIB::hrProcessorLoad.773] => INTEGER: 1
    [HOST-RESOURCES-MIB::hrProcessorLoad.774] => INTEGER: 7
    [HOST-RESOURCES-MIB::hrProcessorLoad.775] => No more variables left in this MIB View (It is past the end of the MIB tree)
)  

当使用snmp2_real_walk时,它只找到7个cpu核心,而不是snmpwalk的8个cpu核心。但是当我使用snmp2_real_walk查询localhost的cpu信息或者有4个核心的远程主机时,它会得到正确的结果。
PS:当我使用cacti 0.8.7e时,我发现了这个问题。我尝试使用SNMP - Get Processor Information数据查询来绘制8核远程机器的图形。但它只检测7个核心。我发现仙人掌使用snmp2_real_walk函数来获取cpu的信息。

1 个答案:

答案 0 :(得分:0)

我找到了问题所在。 snmp2_real_walk需要PHP&gt; = 5.2并且我的主机的PHP版本是5.1 所以我升级了PHP并解决了问题。