-1

I run snmptrapd and can see incoming trap, when send trap via 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"

But I no have trap, when send via Perl script

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"]]);

What's wrong?

4

1 回答 1

1

您的第二个版本,即 perl 版本没有指定社区或版本,与第一个不同。尝试添加它们

$sess = new SNMP::Session(DestHost => '127.0.0.1', 
                                      RemotePort => "162",
                                      Community => "public,
                                      Version => 2);

另请参阅http://www.remothelast.altervista.org/SNMP_Perl.htmlhttp://www.net-snmp.org/docs/perl-SNMP-README.html以了解 SNMP::Session 用法。

于 2015-03-06T10:58:13.323 回答