Hi James
to monitor traps I use the following script (and it works):
package require Tnm 3.0
# load the private MIB
Tnm::mib load path/mibfile.mib
# open trap session
set ts [Tnm::snmp listener]
# configuration can stay as it is
# -port 162 -version SNMPv1 -transport udp -tags {}
# bind events to the trap session
$ts bind trap {puts "\nsession %S received a trap.\n\
sender's IP address: %A\n\
varbind list: %V\n\"}
Try it! Good luck
Bernd
James Harper schrieb:
> I have been trying to use the Scotty bind command to bind scripts to
> SNMP events. My aim is to use it to receive traps, though after
> experiencing problems with them I've tried binding to other events and I
> still didn't have any luck.
>
> >From the man page, it mentions that scripts bound to events execute like
> callback scripts from other commands, i.e., they count as "event based
> programming" So, I tried things like the following:
>
> >> tclsh
> % load /users/fwtest/tools/lib/tnm2.1.10.sl
> % set sess [snmp session]
> snmp0
> % $sess configure -port 162
> -address 127.0.0.1 -port 162 -version SNMPv1 -community public -timeout
> 5 -retries 3 -window 10 -delay 0
> % $sess configure -address fwlab150
> -address 10.224.58.52 -port 162 -version SNMPv1 -community public
> -timeout 5 -retries 3 -window 10 -delay 0
> % $sess bind {} trap {
> puts "Trap Received!"
> }
> % set x 0
> 0
> % vwait x
>
> I can initiate actions on fwlab150 that cause traps to be sent to
> fwlab201. The bind script however is not called and I have to Ctrl-c to
> quit out of the event loop. I have tried this using different addresses
> (fwlab201's and localhost), and without calling vwait in case the script
> didn't require the event loop.
>
> I also tried setting up bind scripts for send and receive events. In
> another window I made some getnext calls, but they did not activate the
> bound scripts. In contrast, the callback script functionality for
> getnext worked fine:
>
> >> tclsh
> % load /users/fwtest/tools/lib/tnm2.1.10.sl
> % set sess [snmp session]
> snmp0
> % $sess configure -address fwlab150
> -address 10.224.58.52 -port 161 -version SNMPv1 -community public
> -timeout 5 -retries 3 -window 10 -delay 0
> % $sess getnext 1.3.6.1 {
> puts "Reply received"
> set x 1
> }
> 1720
> % vwait x
> Reply received
> %
>
> I've noticed that a getnext command with a callback script returns an
> event ID though binding a script to an event does not. Beyond that, I'm
> not sure what's wrong with what I'm doing.
>
> James Harper
> --
> !! This message is brought to you via the `tkined & scotty' mailing list.
> !! Please do not reply to this message to unsubscribe. To subscribe or
> !! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
> !! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.
-- !! This message is brought to you via the `tkined & scotty' mailing list. !! Please do not reply to this message to unsubscribe. To subscribe or !! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>. !! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.
This archive was generated by hypermail 2b29 : Thu Jan 03 2002 - 14:56:26 MET