I apologize if this is an obvious question but, I have been working on this and can't seem to get it working. I want to do an SNMP get then generate a trap with the information recieved from the get and some other information. I have stripped this code down to it bare essentials:
#!/opt/VRTSnc/bin/perl -w use Net::SNMP; my $NodeAddress = '10.72.36.1'; my $ReadCommunity = 'public'; my ($session1, @trapvars, $error) = Net::SNMP->session( -hostname => $NodeAddress, -community => $ReadCommunity); if (!defined($session1)){ printf("ERROR: %s.'n", $error); exit 1;} my $ifAlias = '.1.3.6.1.2.1.31.1.1.1.18.110'; my $result = $session1->get_request( -varbinds => [$ifAlias]); if (!defined($session1)){ printf("ERROR: %.'n", $error); exit 1;} my $ifDescr = $result->{$ifAlias}; my ($session2) = Net::SNMP->session( -hostname => '10.62.11.58', -port => '162', -community => 'public'); if (!defined($session2)){ printf("ERROR: %s.'n", $error); exit 1;} $trapvars[0] = ".1.3.6.1.4.1.78.0.100147"; $trapvars[1] = OCTET_STRING; $trapvars[2] = 'IFName'; $trapvars[3] = ".1.3.6.1.4.1.78.0.100147"; $trapvars[4] = OCTET_STRING; $trapvars[5] = $result->{$ifDescr}; $session2->trap( -enterprise => '1.3.6.1.4.1.78', -agentaddr => $NodeAddress, -generictrap => '6', -specifictrap => '100147', -varbindlist => \@trapvars); if (!defined($session2)){ printf("ERROR: %s.'n", $error); exit 1;} $session1->close;
If I print the array i see the following information: .1.3.6.1.4.1.78.0.100147 4 IFName .1.3.6.1.4.1.78.0.100147 4 HASH(0xeea8c)

In reply to SNMP Get and Trap by CongoGrey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.