Re: [tkined] SNMP Agent Not Re-entrant?

Juergen Schoenwaelder (schoenw@ibr.cs.tu-bs.de)
Wed, 21 Apr 1999 16:56:01 +0200

>>>>> Cary O'Brien writes:

Cary> I am trying to create an snmp agent that gathers up snmp data
Cary> from other places and presents it on one machine. I.E. in this
Cary> agent the callback for an snmp get does an snmp get of some
Cary> other machine. It doesn't seem to work. I get genErr. My
Cary> suspicion is that some the SNMP agent is not re-entrant.

You can do SNMP operations while sitting in a callback. However, you
must be careful that you use asynchronous operations and that you do
not leave the callback until you have gathered the data. Here is an
example:

set a [snmp session -port 1234 -agent {}]
$a bind sysDescr.0 get {fetch}

proc fetch {} {
set r [snmp session -address xxxx]
$r get sysDescr.0 {
set tnm_system(sysDescr) [lindex [lindex "%V" 0] 2]
}
$r wait
$r destroy
}

The first two lines setup an agent and bind the procedure fetch to a
get event on sysDescr.0. The fetch procedure opens a SNMP session to a
remote host and starts an asynchronous get. Once the result comes in,
the value will be written to the global tnm_system(sysDescr) variable.
The wait command ensures that we remain in fetch until we got the
response. Finally, we remove the session before returning from the get
callback. The agent will now read tnm_system(sysDescr) and return the
value to the manager. I tested this piece of code with scotty 2.1.10.

[I am myself somtimes surprised about what one can do with this toy.
But it may be hard for many people to really understand the control
flow in code examples like the one shown above.]

Juergen

-- 
Juergen Schoenwaelder  schoenw@ibr.cs.tu-bs.de http://www.cs.tu-bs.de/~schoenw
Technical University Braunschweig, Dept. Operating Systems & Computer Networks
Bueltenweg 74/75, 38106 Braunschweig, Germany.        (Tel. +49 531 / 391 3289)
--
!! 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.