#!/bin/sh
# the next line restarts using scotty -*- tcl -*- \
exec scotty2.1.11 "$0" "$@"

package require Tnm 2.1

##
## This functions is called whenever an SNMP trap is received.
##

proc traphandler {ip args} {
    set msg "SNMP trap from $ip:"
    foreach vb $args {
	append msg " [mib name [lindex $vb 0]]=\"[lindex $vb 2]\""
    }
    syslog critical $msg
}

catch {
    set s [snmp session -version SNMPv1]
    $s bind "" trap "traphandler %A %V"
}

catch {
    set s [snmp session -version SNMPv2C]
    $s bind "" trap "traphandler %A %V"
}

catch {
    set s [snmp session -version SNMPv2U]
    $s bind "" trap "traphandler %A %V"
}

