Re: Scotty snmpd on unsafe Tcl

Juergen Schoenwaelder (schoenw@ibr.cs.tu-bs.de)
Tue, 31 Oct 1995 01:14:30 +0100

Hi!

Garry Grimes <grimesg@ul.ie> said:

Garry> I am running Scotty on an unsafe Tcl distribution and
Garry> I'm informed that I can't run the snmpd supplied with the
Garry> Scotty 2.0.1 distribution because of that. I'm a newcomer to
Garry> Scotty and I'd like to get the agent running to see how it
Garry> works. I just want to create a simple V1 agent but the whole
Garry> thing seems to be geared towards using safe-Tcl only (ie. the
Garry> Safe Scotty commands). Any help would be great.

It is not easy to make the scripts in the agents directory work with
an unsafe Tcl version. You can either upgrade to Tcl7.5a2 and Tk4.1a2
(which includes safe Tcl) or you can play around by doing your own
first steps. Below is the slightly updated version from the
snmp/README file which shows how you can create a simple agent with
some funny bindings.

Juergen

7. A simple agent with a counter SNMP variable (abusing sysLocation):

set s [snmp session -port 8161 -agent ""]

# Create a counter binding for the sysLocation variable:

$s bind sysLocation.0 get {
incr sysLocation
}

# Send a set request to yourself to initialize the sysLocation
# counter.

$s set {{sysLocation.0 1}} {puts "%E %V"}

# you can even send asynchronous requests to yourself :-)

$s get sysLocation.0 {puts "%V"}

# and you can add more bindings to the MIB tree

$s bind system get "puts {GET request on session %S from %A}"

$s get sysLocation.0 {puts "%V"}

# and you can do special things when variables are set

$s bind sysContact.0 set {
set sysContact [string toupper "%v"]
# a break makes sure that no other (default) bindings are invoked
break
}

$s set {{sysContact.0 foobar}} {puts "%E %V"}