本文目录一览:
- java 开发 SNMP 一些疑问
- java测试snmp监听端口是否可用
- java通过snmp多线程并发访问设备获取数据
- java 发送snmp trap消息如何确定发送成功
- java支持snmp协议实现吗
java 开发 SNMP 一些疑问
- 具体实现可参考开源snmp代码 snmp4j: 里面有具体实现方法,网上相关介绍也有不少。
- 如果仅仅是配置客户端trap,有很多小工具安装配置一下就可以,如net-snmp(网上相关资料也不少)
- 代理端是需要开一个线程监听客户端trap消息的
java测试snmp监听端口是否可用
用SNMPWALK,如果对方的SNMP服务开启,工作正常的话,就会列出SNMP查询的数据。如果不正常工作或者未开启,则提示查询超时。 SNMPWALK在网上可以下载下来使用。 在DOS下,输入:
snmpwalk -c 【SNMP字串】 -v 【1|2c】 【IP地址】
例如:
snmpwalk -c public -v 2c 192.168.1.1
java通过snmp多线程并发访问设备获取数据
snmp访问设备获取数据有异步的方法,跟多线程同时使用效果更好
java 发送snmp trap消息如何确定发送成功
snmptrapd需要一个配置文档,snmptrapd.conf。 此文件用来指定管理进程如何处理接收到的snmp notification。
- 在net-snmp安装目录下新建snmptrapd.conf文件,假设本系统使用以下路径:
/ABC/soft/net-snmp/share/snmp/snmptrapd.conf
- 在snmptrapd.conf中加入以下指令:
这条指令指明以“public”为“community”请求的snmp “notification”允许的操作。 各变量意义如下:authCommunity log,execute,net public
log
: log the details of the notification - either in a specified file, to standard output (or stderr), or via syslog(or similar).execute
: pass the details of the trap to a specified handler program, including embedded perl.net
: forward the trap to another notification receiver.
- 若想对接收到的信息进行处理,可以使用traphandle,示例如下:
第一个参数为从snmptrapd接收的OID,第二个参数为调用的程序。此系统未做traphandle处理。traphandle SNMPv2-MIB::coldStart /usr/nba/bin/traps cold traphandle SNMPv2-MIB::warmStart /usr/nba/bin/traps warm traphandle IF-MIB::linkDown /usr/nba/bin/traps down traphandle IF-MIB::linkUp /usr/nba/bin/traps up
- 启动snmptrapd
使用以下指令启动snmptrapd:
该指令将接收到的信息通过标准输出设备打印出来,各参数意义如下:snmptrapd -f -Lo
-f
: Do not fork() from the calling shell.-L[efos]
: Specify where logging output should be directed (standard error or output, to a file or via syslog)
java支持snmp协议实现吗
基于java开发的SugarNMStool,支持SNMP协议实现,SugarNMStool是带拓扑图界面的全功能SNMP工具,可用于SNMP设备开发调试、SNMP诊断的日常必备工具