Hi, I never tried in Solaris but I think that you should just have 1 line in the snmptrapd.conf(at least in linux is like this):
perl do "/usr/local/share/snmp/mytrapd.pl" HTH, Hugo Caçote -----Original Message----- From: mobby lin [mailto:[EMAIL PROTECTED] Sent: Thu 5/19/2005 5:43 PM To: Hugo Monteiro Cacote Cc: [email protected] Subject: SNMP TrapReceiver fail Now build net-snmp with embbed_perl, make , make test and make install. >From TrapReciver manual, I do 1. in Solaris 9, /usr/local/share/snmp/snmptrapd.conf, I put two lines here perl NetSNMP::TrapReceiver::register("all", \&mytrapd); perl do "/usr/local/share/snmp/mytrapd.pl"; 2. mytrapd.pl as below #!/usr/bin/perl 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]})) { printf " %-30s %s\n", $k, $_[0]{$k}; } # print the variable bindings: print "VARBINDS:\n"; foreach my $x (@{$_[1]}) { printf " %-30s type=%-2d value=%s\n", $x->[0], $x->[2], $x->[1]; } } NetSNMP::TrapReceiver::register("all", \&my_receiver) ¦¦ warn "failed to register our perl trap handler\n"; print STDERR "Loaded the example perl snmptrapd handler\n"; Then I run /usr/local/sbin/snmptrapd -f -Le I got /usr/local/share/snmp/snmptrapd.conf: line 1: Warning: Unknown token: perl. /usr/local/share/snmp/snmptrapd.conf: line 2: Warning: Unknown token: perl. 2005-05-19 23:39:58 NET-SNMP version 5.2.1 Started. Then I try to send snmptrap -v 1 -c public localhost 1.3.6.1.4.1.2790.2500 "" 6 3003 "" I can only just 2005-05-19 23:36:14 192.168.1.203(via UDP: [127.0.0.1]:32827) TRAP, SNMP v1, community public SNMPv2-SMI::enterprises.2790.2500 Enterprise Specific Trap (3003) Uptime: 0:43:13.66 What wrong with my setting? Mobby --- Hugo Caçote <[EMAIL PROTECTED]> wrote: > Hi, > > look at the CVS in: > http://cvs.sourceforge.net/viewcvs.py/net-snmp/net-snmp/perl/TrapReceiver/ > > and for the example look at the man page of TrapReceiver (after > installing net-snnp configured with embedded_perl support ): > > man 3 NetSNMP::TrapReceiver > > Hope this helps > Hugo Caçote > > > mobby lin wrote: > > Would you point me which example files I can refer, and how to > > compiler/use it? thanks,. > > > > How to use handler perl module in C program or perl program? > > > > Thanks. > > > > Mobby > > > > */Hugo Ca蔞te <[EMAIL PROTECTED]>/* wrote: > > > > Hi, > > > > Why don't try to use the TrapReceiver perl module?? If you > compile the > > net-snmp package with embedded perl support snmptrapd will > execute a > > perl handler that will process the SNMP trap received. > There is an > > example of the perl trap handler in the net-snmp > distribution. > > > > Hopoe this helps, > > Hugo Ca蔞te > > > > mobby lin wrote: > > > > > I need to used snmp-trap function to receive some > trap/information > > > messages, then run a external command to process the > messages. > > > > > > I try to understand the source file of snmptrapd in the > net-snmp > > > 5.2.1. To me, this is a little complex to understand the > whole > > coding. > > > Specially I trace the snmptrapd.c, it calls the file, > > > snmplib/snmp_alarms.c; I don't know which module and > which variable > > > sent out the following string: > > > > > > ./snmptrapd -f -Le > > > ... > > > 2005-05-17 12:00 sunserver2.org.com [12.1.45.1] > enterprise.2790.2500: > > > Enterprise Specfic Trap (1224) Uptime: 5 days....... > > > > > > Anyone uses the perl module to receive this message, > what's the perl > > > example? > > > > > > Regards, > > > Mobby, [EMAIL PROTECTED] > > > > > > > > > > > > > > > ------------------------------------------------------------------------ > > > Yahoo! Mail > > > Stay connected, organized, and protected. Take the tour > > > > > > > > > > > > ------------------------------------------------------------------------ > > Yahoo! Mail Mobile > > Take Yahoo! Mail with you! > > > <http://us.rd.yahoo.com/mail_us/taglines/mobile/*http://mobile.yahoo.com/learn/mail> > > Check email on your mobile phone. > > > -- > Hugo Caçote @ CERN/IT > Discover Yahoo! Stay in touch with email, IM, photo sharing and more. Check it out! http://discover.yahoo.com/stayintouch.html ------------------------------------------------------- This SF.Net email is sponsored by Oracle Space Sweepstakes Want to be the first software developer in space? Enter now for the Oracle Space Sweepstakes! http://ads.osdn.com/?ad_idt12&alloc_id344&op=click _______________________________________________ Net-snmp-users mailing list [email protected] Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users
