[PHP] 啟用 php_snmp 後出現「Cannot find module」

最近因為專案需要使用snmp和網路硬體設備做通訊,所以使用了php_snmp這個模組

修改完php.ini重新啟動服務後出現了許多錯誤訊息:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
MIB search path: c:/usr/share/snmp/mibs
Cannot find module (IP-MIB): At line 0 in (none)
Cannot find module (IF-MIB): At line 0 in (none)
Cannot find module (TCP-MIB): At line 0 in (none)
Cannot find module (UDP-MIB): At line 0 in (none)
Cannot find module (HOST-RESOURCES-MIB): At line 0 in (none)
Cannot find module (SNMPv2-MIB): At line 0 in (none)
Cannot find module (SNMPv2-SMI): At line 0 in (none)
Cannot find module (NOTIFICATION-LOG-MIB): At line 0 in (none)
Cannot find module (UCD-SNMP-MIB): At line 0 in (none)
Cannot find module (UCD-DEMO-MIB): At line 0 in (none)
Cannot find module (SNMP-TARGET-MIB): At line 0 in (none)
Cannot find module (NET-SNMP-AGENT-MIB): At line 0 in (none)
Cannot find module (DISMAN-EVENT-MIB): At line 0 in (none)
Cannot find module (SNMP-VIEW-BASED-ACM-MIB): At line 0 in (none)
Cannot find module (SNMP-COMMUNITY-MIB): At line 0 in (none)
Cannot find module (SNMP-FRAMEWORK-MIB): At line 0 in (none)
Cannot find module (SNMP-MPD-MIB): At line 0 in (none)
Cannot find module (SNMP-USER-BASED-SM-MIB): At line 0 in (none)
Cannot find module (SNMP-NOTIFICATION-MIB): At line 0 in (none)
Cannot find module (SNMPv2-TM): At line 0 in (none)

 

原因是因為沒有安裝 SNMP MIB,解法當然是安裝 SNMP MIB,個人是找了 Net-SNMP 這套安裝,安裝完後基本上就可以直接使用了。

如果安裝完後還是不能用的話就自己手動加一個環境變數:

1
2
Variable Name:mibdirs
Variable Value:{Path to Net-SNMP install folder}\share\snmp\mibs (Default Install Path:C:\usr\share\snmp\mibs)
Licensed under CC BY-NC-SA 3.0 TW
comments powered by Disqus