Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8145673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:44:41+00:00 2026-06-06T13:44:41+00:00

I’m trying to send a trap as part of a larger Perl script. I’ve

  • 0

I’m trying to send a trap as part of a larger Perl script. I’ve copied the trapsending code to another file, and am running it by itself. The code seems to think the trap sends successfully, yet I’m not seeing the trap on either machine that I have a trap listener running on.

Here’s the code:

#! /usr/local/bin/perl
use strict;
use warnings;

use Net::SNMP;

#messy hardcoding
my $snmp_target = '192.168.129.50';
#my $snmp_target = '10.200.6.105'; # Server running trap listener
my $enterprise = '1.3.6.1.4.1.27002.1';

my ($sess, $err) = Net::SNMP->session(
    -hostname  => $snmp_target,
    -version => 1, #trap() requires v1
);

if (!defined $sess) {
    print "Error connecting to target ". $snmp_target . ": ". $err;
    next;
}

my @vars = qw();
my $varcounter = 1;

push (@vars, $enterprise . '.' . $varcounter);
push (@vars, OCTET_STRING);
push (@vars, "Test string");

my $result = $sess->trap(
    -varbindlist => \@vars,
    -enterprise => $enterprise,
    -specifictrap => 1,
);

if (! $result)
{
    print "An error occurred sending the trap: " . $sess->error();
}

EDIT: Added $sess->debug(255) call, here’s the output:

debug: [440] Net::SNMP::Dispatcher::_event_insert(): created new head and tail [ARRAY(0x1af1fea8)]
debug: [687] Net::SNMP::Message::send(): transport address 192.168.129.50:161
debug: [2058] Net::SNMP::Message::_buffer_dump(): 70 bytes
[0000]  30 44 02 01  00 04 06 70  75 62 6C 69  63 A4 37 06   0D.....public.7.
[0016]  09 2B 06 01  04 01 81 D2  7A 01 40 04  C0 A8 81 85   .+......z.@.....
[0032]  02 01 06 02  01 01 43 01  00 30 1B 30  19 06 0A 2B   ......C..0.0...+
[0048]  06 01 04 01  81 D2 7A 01  01 04 0B 54  65 73 74 20   ......z....Test 
[0064]  73 74 72 69  6E 67                                   string
debug: [517] Net::SNMP::Dispatcher::_event_delete(): deleted [ARRAY(0x1af1fea8)], list is now empty

EDIT: Can anyone running a trap listener try this code on their machine and let me know if it works?

EDIT: Tried it from my MBP. Same result. Then noticed that the debug info says it is sending to port 161. Forced -port => 162 parameter, and it works. That leaves me with a couple of questions:

  1. Why does the trap sender default to 161?
  2. I get this error when I run with debug on. What does it mean?

    error: [97] Net::SNMP::Transport::IPv4::UDP::agent_addr(): Failed to disconnect: Address family not supported by protocol family

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:44:43+00:00Added an answer on June 6, 2026 at 1:44 pm

    Fixed by changing ‘Port’ setting from default 161 to 162.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to render a haml file in a javascript response like so:
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.