Hi,

I followed the steps mentioned in the following website
(http://search.cpan.org/~hardaker/NetSNMP-TrapReceiver-5.0301/TrapReceiver.pm)
and configured snmptrapd.conf to register my perl module.

The module is called for every trap received but when the first trap
is received the formatting is not proper.

My conf:

snmptrapd.conf is edited with:

perl do "/usr/local/share/snmp/mytrapd.pl";

and mytrapd.pl contains:
############################
sub my_receiver {
      print "********** PERL RECEIVED A NOTIFICATION:\n";

      # print the PDU info (a hash reference)
      print "PDU INFO:\n";
      foreach my $k(keys(%{$_[0]})) {
        $log->debug("$k\t$_[0]{$k}\n");
      }

      # print the variable bindings:
      print "VARBINDS:\n";
      foreach my $x (@{$_[1]}) {
          $log->debug("$x->[0]\t$x->[2]\t$x->[1]\n");
      }
  }

  NetSNMP::TrapReceiver::register("all", \&my_receiver) ||
    warn "failed to register our perl trap handler\n";

  print STDERR "Loaded the example perl snmptrapd handler\n";
############################


Output I got for the first time:
****************************************
[2010/08/17 21:25:39] DEBUG 130 - ciscoEnvMonFanStatusIndex     2
 INTEGER: 1
[2010/08/17 21:25:39] DEBUG 130 - ciscoEnvMonFanStatusDescr     4
 STRING: "status"
[2010/08/17 21:25:39] DEBUG 130 - ciscoEnvMonFanState   2       INTEGER: 1
[2010/08/17 21:25:39] DEBUG 130 - snmpTrapAddress.0     64
IpAddress: 10.64.116.241
[2010/08/17 21:25:39] DEBUG 130 - snmpTrapCommunity.0   4       STRING: "public"
[2010/08/17 21:25:39] DEBUG 130 - snmpTrapEnterprise.0  6       OID:
CISCO-ENVMON-MIB::ciscoEnvMonMIBNotificationPrefix


Second time:
****************************************
[2010/08/17 21:37:47] DEBUG 130 - ciscoEnvMonFanStatusIndex     2       1
[2010/08/17 21:37:47] DEBUG 130 - ciscoEnvMonFanStatusDescr     4       "status"
[2010/08/17 21:37:47] DEBUG 130 - ciscoEnvMonFanState   2       1
[2010/08/17 21:37:47] DEBUG 130 - snmpTrapAddress.0     64      10.64.116.241
[2010/08/17 21:37:47] DEBUG 130 - snmpTrapCommunity.0   4       "public"
[2010/08/17 21:37:47] DEBUG 130 -
snmpTrapEnterprise.0    6       ciscoEnvMonMIBNotificationPrefix



Pls let me know what is happening. Thank you.

Regards

Karthik

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to