Paul Chen (QD/LJC) wrote:
> Hi,
> 
> I want to use a scipt to handle the trap messages that  trapd received.  So I 
> configured the snmptrapd.conf as following:
> 
> ###########################################################################
> #
> # snmptrapd.conf
> #
> #   - created by the snmpconf configuration program
> #
> 
> 
> 
> ###########################################################################
> # SECTION: Trap Handlers
> #
> #   Here we define what programs are run when a trap is
> #   received by the trap receiver.
> 
> # traphandle: When traps are received, a program can be run.
> #   When traps are received, the list of configured trap
> #   handles is consulted and any configured program is run.
> #   If no handler is found, any handler with "default" as the
> #   traphandle type is run instead.  The information contained
> #   in trap is passed to the program via standard input (see
> #   the snmptrapd.conf manual page for details).
> #
> #   arguments: oid|"default" program args
> 
> traphandle  SNMPv2-MIB::coldStart /home/niping/net-snmp-5.2.1.rc3/trap cold
> traphandle  SNMPv2-MIB::warmStart /home/niping/net-snmp-5.2.1.rc3/trap warm
> 
>  /home/niping/net-snmp-5.2.1.rc3/trap  is an example script,as following:
> 
> #!/bin/sh
> 
> echo 'hello world.'
> read host
> read ip
> vars=
> 
> while read oid val
> do
>   if [ "$vars" = "" ]
>   then
>     vars="$oid = $val"
>   else
>     vars="$vars, $oid = $val"
>   fi
> done
> 
> echo trap: $1 $host $ip $vars
> 
> But after I run up the snmptrapd and send a trap message using snmptrap, 
> nothing is printed on the screen, even the "hello world." is not seed.
> 
> Why, any errors in the config file of the script?

The output of any trap handler will not be output to the screen.  Try
sending the output to a file instead.  For example:

echo trap: $1 $host $ip $vars >> /tmp/trap.out

Alex



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
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