我运行snmptrapd并在通过snmptrap
发送陷阱时可以看到传入的陷阱snmptrap -c public -v 2c localhost "" 1.3.3.3.3.3.3.3 1.2.2.2.2.2.2 s "Aliens here"
但是当我通过Perl脚本发送
时,我没有陷阱use SNMP;
$sess = new SNMP::Session(DestHost => '127.0.0.1', RemotePort => "162" );
$sess->trap(enterprise=>'.1.3.6.1.4.1.2021', # or 'ucdavis' [default]
agent => '127.0.0.1', # or 'localhost',[dflt 1st intf on host]
generic => specific, # can be omitted if 'specific' supplied
specific => 5, # can be omitted if 'generic' supplied
uptime => 1234, # dflt to localhost uptime (0 on win32)
[[ifIndex, 1, 1],[sysLocation, 0, "here"]]);
怎么了?
答案 0 :(得分:1)
您的第二个版本,即perl版本未指定社区或版本,与第一个版本不同。尝试添加它们
$sess = new SNMP::Session(DestHost => '127.0.0.1',
RemotePort => "162",
Community => "public,
Version => 2);
另见http://www.remothelast.altervista.org/SNMP_Perl.html 和http://www.net-snmp.org/docs/perl-SNMP-README.html用于SNMP ::会话使用。