为了调试方便,我在Windows环境中使用的是XAMPP 1.7.1集成应用,其提供了Apache、PHP、Mysql、PHPMyAdmin等一系列的工具,简单易用。今天,想打开php_snmp模块,却遇到一些问题。Apache后台日志报一堆的错误:
引用
Cannot find module (IP-MIB): At line 0 in (none)
……
……
后来发现,原来是MIBDIRS变量没设好。
XAMPP是安装在D:\Tools\xampp目录下的,修改该目录下的php\php.ini文件,打开php_snmp模块支持:
引用
extension=php_snmp.dll
重新启动Apache,发现error.log日志报:
引用
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 (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 (UCD-DLMOD-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)
[Tue May 31 15:31:43 2011] [notice] Child 2372: Child process is running
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 (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 (UCD-DLMOD-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)
[Tue May 31 15:31:43 2011] [notice] Child 2372: Child process is running
原因是,没有设置php_snmp模块使用的mibs目录路径。
在操作系统后台——控制面板——高级系统设置——环境变量中(Win7为例),加入“系统环境变量”:
引用
变量名:MIBDIRS
变量值:D:\Tools\xampp\php\extras\mibs
变量值:D:\Tools\xampp\php\extras\mibs
※ 注意:不要加错用户变量了,要加入系统环境变量。
最后,重启Apache即可。
打开http://localhost/xampp/phpinfo.php 连接,可看到snmp模块已激活:
※ 2011-06-29 补充
若在使用PHP时,需调用MIBs 模块中定义的OID点,则务必把相关的MIBs文件放到mibs目录下。
例如,使用监控Heartbeat 3.0的LINUX-HA-MIB.txt。
(该文件可从Heartbeat 3.0的pacemaker-mgmt 包中获取)
[转]Better PHP Practices
PHP设计模式——策略模式
PHP设计模式——命令模式
PHP设计模式——观察者模式
PHP设计模式——单元素模式
PHP设计模式——策略模式
PHP设计模式——命令模式
PHP设计模式——观察者模式
PHP设计模式——单元素模式
原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/103942.html