关于SNMP的一个问题:向管理端发送SNMP Trap报警信息。

2025-05-04 17:23:12
推荐回答(4个)
回答1:

snmptrapd需要一个配置文档,snmptrapd.conf。
此文件用来指定管理进程如何处理接收到的snmp notification。
1. 在net-snmp安装目录下新建snmptrapd.conf文件,假设本系统使用以下路径:/ABC/soft/net-snmp/share/snmp/snmptrapd.conf

2. 在snmptrapd.conf中加入以下指令:
authCommunity log,execute,net public
这条指令指明以“public”为“community”请求的snmp “notification”允许的操作。
各变量意义如下:
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.

3. 若想对接收到的信息进行处理,可以使用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接收的OID,第二个参数为调用的程序。此系统未做traphandle处理。

4. 启动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

回答2:

你的/etc/snmp/snmpd.conf文件没有进行配置,需要做下修改。最简单的使用的话,添加如下
authCommunity log,execute,net public到配置文件,再运行snmptrapd -d -f -Lo即可。

回答3:

访问控制没有配置.

回答4:

修改下命令