PHP使用SNMP相關函數的有關問題
最後更新:2016-06-13
來源:互聯網
上載者:User
PHP使用SNMP相關函數的問題
SNMP服務已經配置好了
使用PHP_SNMP.DLL模組
使用函數 SNMPWALK
原代碼如下
$a = snmpwalkoid("127.0.0.1", "public", "");
?>
for (reset($a); $i = key($a); next($a)) {
echo "$i: $a[$i]
\n";
}
?>
這個是沒問題的 但是一旦指定相關OBJECT就會出問題 SNMPWALK協助文檔提供的原代碼中
$host = '127.0.0.1';
$community = 'public';
$object_id = 'IF-MIB::interfaces.ifTables.ifEntry.ifAdminStatus';
$sysdesc = snmpwalk($host, $community, $object_id);
print_r($sysdesc);
?>
提示SNMPWALK出錯
但是是有東西輸出的
錯誤資訊 Warning: snmpwalk() [function.snmpwalk]: Invalid object identifier: IF-MIB::interfaces.ifTables.ifEntry.ifAdminStatus in E:\work\php\black\snmpwalk3.php on line 6
輸出資訊
Array ( [0] => "Windows WWW-476F9BE6F90 5.1.2600 Service Pack 3 XP Professional x86 Family 6 Model 23 Stepping 10" [1] => OID: enterprises.8072.3.2.13 [2] => Timeticks: (138255) 0:23:02.55 [3] => "Me " [4] => "WWW-476F9BE6F90" [5] => "Right here, right now." [6] => Timeticks: (4) 0:00:00.04 [7] => OID: 31 [8] => OID: 49 [9] => OID: 4 [10] => OID: 50 [11] => OID: .iso.org.dod.internet.snmpV2.snmpModules.1 [12] => OID: .iso.org.dod.internet.snmpV2.snmpModules.16.2.2.1 [13] => OID:
求協助
------解決方案--------------------
'IF-MIB::interfaces.ifTables.ifEntry.ifAdminStatus'
當初我也碰到這個問題了。
網上找到的都是這種表達方式,好像是linux系統專用的。
windows系統下,需要用.iso.開頭的地址,或者0.1.3.6數字形式的。
iso就是1.
Invalid object identifier就是表示這個'IF-MIB::interfaces.ifTables.ifEntry.ifAdminStatus'不存在。