23 January 2010

เปิด extension snmp แล้วใช้งาน command line ไม่ได้

ถ้าเปิด extension snmp ของ php.ini แล้วเจอ error

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 (SNMPv2-MIB): At line 0 in (none)
Cannot find module (SNMPv2-SMI): 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 (no
Cannot find module (SNMP-VIEW-BASED-ACM-MIB): At line
Cannot find module (SNMP-COMMUNITY-MIB): At line 0 in
Cannot find module (UCD-DLMOD-MIB): At line 0 in (none
Cannot find module (SNMP-FRAMEWORK-MIB): At line 0 in
Cannot find module (SNMP-MPD-MIB): At line 0 in (none)
Cannot find module (SNMP-USER-BASED-SM-MIB): At line 0
Cannot find module (SNMP-NOTIFICATION-MIB): At line 0
Cannot find module (SNMPv2-TM): At line 0 in (none)

เพราะว่าเราได้ทำการ เปิด

extension=php_snmp.dll

ให้ทำงานแต่ module ของ snmp นั้นไม่สามารถทำงานได้ วิธีแก้ไขให้สร้าง folder ขึ้นมาใน Drive ที่ลง php ไว้เช่น
ใช้ Appserv ลงใน Drive C:\Appserv\php5 ก็ให้สร้าง C:\usr ขึ้นมาแล้ว copy Folder ใน

C:\AppServ\php5\extras\mibs

มาไว้ที่

C:\usr

เท่านี้ก็สารมารถใช้ php ผ่าน Command line ได้และยังสามารถเรียกใช้ MIB Name เช่น system.sysDescr.0 ได้อีกด้วย

วิธีนี้สามารถใช้ได้ทั้งแบบที่ลงจาก php เองหรือใช้ appserv ลงได้ ^^"