bengmau has asked for the wisdom of the Perl Monks concerning the following question:

Hey, I built an snmptrap module however now I would like to be able to override the originating trap source before I send the trap since some devices I'm monitoring are through a host server. Therefore by default the trap will generate as if the error was on the host server as opposed to the actual device.
my $session = Net::SNMP->session( -community => $cfg->{input}->{'community'}, -hostname => $cfg->{input}->{'trapdest'}, -port => SNMP_TRAP_PORT, ); my $result=$session->trap( -enterprise => $enterprise, -specifictrap => $specific, ....
read up and the only thing that appears like I can do is add a:
- localaddr => $nodeIwant,
to my session or trap definition. Is that right or is that only for redefining the return source if you send a get instead of trap? hmmm actually localaddr is set at object creation.. I think I need to use:
-agentaddr => $ipaddress,
for the trap() function. but can I only set IP address or hostname.

Replies are listed 'Best First'.
Re: net::snmp module sendtrap but change originating node name
by NetWallah (Canon) on Jun 27, 2005 at 20:26 UTC
    The -agentaddr      => $ipaddress, seems to be designed for exactly the purpose you are using it for.

    Please try that and post your results. The alternative is ugly - create a seperate $session object for each agent you are proxying for.

         "There are only two truly infinite things. The universe and stupidity, and I'm not too sure about the universe"- Albert Einstein

      yea.. my concern with the documentation for
      -agentaddr => $ipaddress
      is that the notation must be in IP dot notation and I can't just throw a hostname which I could with the -localaddr however yes you are right.. I don't want to keep creating new sessions..
      neither solution works well if I try to put a nodename in either localaddr or agentaddr no trap is generated. localaddr actually tries to resolve an IP from the hostname and appears that agentaddr requires an IP not hostname as per the documentation.. so I can't fake the source hostname with virtual node name. anyone have a solution for this?