0

全部。我对 snmp2_real_walk 有疑问。
我的 PHP 版本:<code>PHP 5.1.6 OS: Red Hat Enterprise Linux Server release 5.5.我有一个最多 8 核的主机。而且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 查询本地主机的 cpu 信息或一些具有 4 个核心的远程主机时,它会得到正确的结果。
PS:我在使用 cacti 0.8.7e 时发现了这个问题。我尝试使用SNMP - Get Processor Information数据查询来绘制 8 核远程机器的图形。但它只检测到 7 个核心。我发现仙人掌使用 snmp2_real_walk 函数来获取 cpu 的信息。

4

1 回答 1

0

我已经找出问题所在。snmp2_real_walk 需要 PHP >= 5.2 而我主机的 PHP 版本是 5.1。
所以我升级了PHP并解决了问题。

于 2013-08-01T07:54:46.850 回答