我试图让PHP在XAMPPPHP7.1.9上工作
我总是得到这样的结果:Warning: SNMP::get(): No response from 127.0.0.1
我所做的是:
我正在运行以测试的代码:
<?php
$session = new SNMP(SNMP::VERSION_1, "127.0.0.1", "public");
$sysdescr = $session->get("sysDescr.0");
echo "$sysdescr\n";
$session->close();我是新手,所以我不知道我错过了什么。
发布于 2018-07-16 08:07:20
问题是MIBDIRS的路径。
我跟踪了php文档,上面写着:The Windows distribution of Net-SNMP contains support files for SNMP in the mibs directory. This directory should added to Windows' environment variables, as MIBDIRS, with the value being the full path to the mibs directory: e.g. c:\usr\mibs.
问题是在我的net安装中找不到c:\usr\mibs,所以我使用了C:\usr\share\snmp\mibs。
解决方案:
我尝试使用具有snmp支持的设备,而不是127.0.0.1,并在cli上运行snmpget,并确认net安装确实有效。我想问题一定是因为path php正在使用它来运行snmp。
因此,我使用where snmpget检查命令路径,然后用C:\usr\bin\snmpget.exe的结果更改MIBDIRS环境值。
https://stackoverflow.com/questions/51322443
复制相似问题