Re: Scotty mem usage growing

Sveinar Rasmussen (sveinarr@stud.cs.uit.no)
Tue, 29 Jul 1997 14:48:11 +0200 (METDST)

On Mon, 28 Jul 1997, Juergen Schoenwaelder wrote:

>
> Sveinar Rasmussen <sveinarr@stud.cs.uit.no> said:
>
> Sveinar> Now, getting back to the idea of "simply updating the
> Sveinar> Tcl variable". Does anyone know where scotty stores
> Sveinar> the Snmp values? I'm trying to just set the global tcl
> Sveinar> variable used with "$s instance", but that
> Sveinar> unfortunately, didn't work. No variables got an
> Sveinar> update, but I know for a fact that the global tcl
> Sveinar> variable of mine was updated. It's not reflected in
> Sveinar> the snmp database:
>
> Scotty reads the values out of global Tcl variables. The problem you
> have is probably related to the variable names you are using. If I
> call setMIB with the parameters ifDescr.42 and "hello", you will bind
> the snmp instance to the global Tcl variable "ifDescr.42". Note that
> the Tcl interpreter does not easily accept this as a variable name,
> e.g. "puts $ifDescr.42" will not work (you have to write "puts
> ${ifDescr.42}" to make it work).
>
> I would suggest to map instances into arrays indexed by the instance
> identifier, e.g ifDescr(42). This will probably solve the problem.
>

Thanks answering so quickly :) Have been trying to get this updating
to work now for almost 6 straight hours, but no luck so far. I'm
hoping that someone can (still hehe :) help...

Implementing your idea with the array, I've got the following code
for a MIB update:

proc setMIB {var val} {
set tmp [split $var "."]
set arrayX [lindex $tmp 0]
set arrayY [lindex $tmp 1]
global mibVals s
if { ! [ info exists mibVals($arrayX,$arrayY) ] } {
puts "New: mibVals($arrayX,$arrayY)= $val"
set mibVals($arrayX,$arrayY) $val
$s instance $var mibVals($arrayX,$arrayY) $mibVals($arrayX,$arrayY)
} else {
if {$val != $mibVals($arrayX,$arrayY)} {
puts "Upd: mibVals($arrayX,$arrayY):\
$mibVals($arrayX,$arrayY) -> $val"
set mibVals($arrayX,$arrayY) $val
}
}
}

It's a two-dimensional array. Tcl seems to be enjoyably happy about the
variable names, since the output is:

---Start---
New: mibVals(hrSystemUptime,0)= 653119500
New: mibVals(hrSystemDate,0)= 1997 07 29 14 32 32 0 +100
New: mibVals(hrSystemNumUsers,0)= 10
New: mibVals(hrSystemProcesses,0)= 140
New: mibVals(hrSystemMaxProcesses,0)= 350
---Looping---
Upd: mibVals(hrSystemUptime,0): 653119500 -> 653120400
Upd: mibVals(hrSystemDate,0): 1997 07 29 14 32 32 0 +100 -> 1997 07 29 14
32 41 0 +100
---Looping---
..

Now, the problem isn't too shocking: none of the variables gets updated
as far as snmp browser is concerned. The snmp value is always the same.
If I remove the optional [default value] in the "$s instance" code,
I simply get zeros on every variable. It seems to me that there hasn't
been a successful binding between the global Tcl variable and the
Scotty internals. It probably can't read the variable in the varName
field. I provide it with a string similar to that of the output,
which should be fine according to the C code of Scotty (tnmSnmpInst.c,
function Tnm_SnmpCreateNode). It is a global variable...

I have also recompiled scotty again incorporating Martin Knoll's
memory leak fix in the function InedGets (8 kB mem eating when snmp
trap comes in). However, the problem didn't go away (scotty just got
bigger with instances) - probably since I'm not dealing with any traps.

I have also tried a version of my setMIB proc using standard global
tcl variables (instead of an array), like ifDescr42 from the original
ifDescr.42. That didn't work either. Same problem as with the
current solution mibVals(ifDescr,42) :)

So... I'm stuck! No progress has been made during the last few days,
and this does not look good in light of the project handin due 10th
of August :) hehe... *smile*

Pretty pretty please if anyone have a clue on what's going terribly
wrong in my code --> mail it to the mailinglist <--

Thanks in advance ;-)

_______________________________________________________________________
| Sveinar Rasmussen -*- Attend master of comp.sci. engineering course |
| sveinar@rasmussen.org -*- http://www.cs.uit.no/~sveinarr/ |

--
!! 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.