in reply to Re: SNMP Trap not working with Perl 5.8.3
in thread SNMP Trap not working with Perl 5.8.3

I tried both 161 and 162. Also used snoop to see if packet goes out. It does not. Neil
  • Comment on Re^2: SNMP Trap not working with Perl 5.8.3

Replies are listed 'Best First'.
Re^3: SNMP Trap not working with Perl 5.8.3
by hsinclai (Deacon) on Jun 09, 2004 at 18:49 UTC
    I don't think your problem is Perl related. Somehow harder to figure out - may be something up with your systems?

    I changed your code block slightly - just to use strict - and it works perfectly sending to a remote FreeBSD machine receiving traps on 162.

    #!/usr/bin/perl -w use strict; use Net::SNMP qw(:asn1); my $message="hi_there"; my $manager='1.2.3.4'; my $host='1.2.3.5'; my $sysedgemgmt='1.3.6.1.4.1.546.9.6'; my $sysedgemule='1.3.6.1.4.1.546.9.6.0.2724'; my @oid=($sysedgemule, OCTET_STRING, $message); my ($session, $error)=Net::SNMP->session( -hostname => shift || $host, -version => 'snmpv1', -community => 'ellengirl', -port => shift || 162, ); if (!defined($session)) { printf("SESSIONERROR: %s.\n", $error); } my $procdown = $session->trap( -enterprise => $sysedgemgmt, -agentaddr => $manager, -generictrap => 6, -specifictrap => 2724, -varbindlist => \@oid, ); if (!defined($procdown)) { printf("ERROR: %s.\n", $session->error); } $session->close; exit 0;


    and here's the data we received at UDP 162
    Jun 9 14:45:14 remotehost snmptrapd[13197]: 1.2.3.5: Enterprise Speci +fic Trap (2724) Uptime: 0:00:00.00, SNMPv2-SMI::enterprises.546.9.6.0 +.2724 = STRING: "hi_there" Jun 9 14:45:14 remotehost hsinclai: The default snmptrapd traphandler + has just made a mark.

    Note: I've got snmptrapd creating a log event after receiving a trap
    Also note, hm specified v1, but logged in as snmpv2 !!
      Also note, hm specified v1, but logged in as snmpv2

      that's not what the SNMPv2-SMI means. it's still v1 but the oid is under enterprises which is defined in the SNMPv2-SMI mib. snmp is a *mess*.

      to OP, your original program worked fine for me as well. but you do want to be sending to port 162.

      That seemed to work. not sure why. I am now able to send traps. Thank you very much, Neil
        Excellent.

        I bet it didn't work before because the variables being sent to Net::SNMP were not declared, under strictures... maybe the module is fussy!! I only declared your variables where applicable..