首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHP SNMP警告: SNMP::get():127.0.0.1没有响应

PHP SNMP警告: SNMP::get():127.0.0.1没有响应
EN

Stack Overflow用户
提问于 2018-07-13 09:52:40
回答 1查看 2.5K关注 0票数 1

我试图让PHP在XAMPPPHP7.1.9上工作

我总是得到这样的结果:Warning: SNMP::get(): No response from 127.0.0.1

我所做的是:

  1. 启用php_snmp.dll on php.ini
  2. 已安装的net-snmp-5.5.0-2.x64
  3. 添加windows环境变量MIBDIRS,其值为C:\usr\share\snmp\mibs

我正在运行以测试的代码:

代码语言:javascript
复制
<?php
    $session = new SNMP(SNMP::VERSION_1, "127.0.0.1", "public");
    $sysdescr = $session->get("sysDescr.0");
    echo "$sysdescr\n";
    $session->close();

我是新手,所以我不知道我错过了什么。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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环境值。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51322443

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档