doushi9376 2013-04-06 08:10
浏览 59

PHP snmp使用一个连接

Is there any way to make one connection and work with it?

Now I have this:

snmp2_get("ip", "public", ".1.3.6.1.2.1.1.5.0");
snmp2_get("ip", "public", ".1.3.6.1.2.1.1.6.0");

Is there any function to make one connection and work with it or how I can put multi OIDS?

  • 写回答

1条回答 默认 最新

  • dsogx84602 2014-01-07 04:28
    关注

    SNMP over UDP, the default setup, is connectionless to begin with. The PHP functions do not provide a means of generating a "handle" that can be reused; typically, you would create your own wrapper if you wanted this functionality.

    Note, however, that PHP 5.4 introduced the "SNMP" class (see the documentation here), which would allow you to do exactly what you want.

    For example:

    $session = new SNMP( SNMP::VERSION_2C, "127.0.0.1", "public" );
    $value1 = $session->get( ".1.3.6.1.2.1.1.5.0" );
    $value2 = $session->get( ".1.3.6.1.2.1.1.6.0" );
    
    评论

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图