May
31
[原]激活Windows下Apache的php_snmp 模块支持
为了调试方便,我在Windows环境中使用的是XAMPP 1.7.1集成应用,其提供了Apache、PHP、Mysql、PHPMyAdmin等一系列的工具,简单易用。今天,想打开php_snmp模块,却遇到一些问题。Apache后台日志报一堆的错误:
后来发现,原来是MIBDIRS变量没设好。
XAMPP是安装在D:\Tools\xampp目录下的,修改该目录下的php\php.ini文件,打开php_snmp模块支持:
重新启动Apache,发现error.log日志报:
原因是,没有设置php_snmp模块使用的mibs目录路径。
在操作系统后台——控制面板——高级系统设置——环境变量中(Win7为例),加入“系统环境变量”:
※ 注意:不要加错用户变量了,要加入系统环境变量。
最后,重启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 包中获取)
引用
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 包中获取)
ejzhang
2014/09/23 11:00
MIBs文件可以到net-snmp源码的mibs文件夹中找
分页: 1/1 1