Re: Help with the Agent.

Buz Owen (ado@BBN.COM)
Tue, 29 Oct 1996 20:54:25 -0500

...
> week). I have one Mib, one very simple agent and I'm using the aplication
> mibtree and scwish shell to test this agent and learn more about scotty. The
> scotty man page and the agents examples are very usefull for me.
>
> For now, I can get some instances (statics or not) of my mib and See
> the instances of a table or all the table. But i did this loading all the table
> when the agent is started. There are two things I'm trying to do and i can't.
>
> 1) Use the index objects of the table to get one intance of some
> object or one row of this table.

> 2) Make the agent load only the requested row at execution time.
>

Suppose you have a mib table with variables myMibVarA, myMibVarB, etc. in its
rows. Identify one variable which is guaranteed to always be in every row.
Any one of the variables which happens to be in the index set for the table
qualifies automatically, but it is never stictly necessary to retrieve an
index variable (because such values can be extracted from the oids of other
variables). If myMibVarA is such a variable, the following scotty statement:

set indices {}
set oid [ mib oid myMibVarA ]
$sessionid walk x myMibVarA {
set tmp [ lindex $x 0 ]
set id [ lindex $tmp 0 ]
regexp $oid\.(.*) $id junk idx
lappend indices $idx
}

will put the current set of row indices into the variable `indices', each time
it is executed. (You would execute this perioodically in a scotty script, that
you write, in place of using mibtree.) Subsequently, or inside the same loop,
after producing the variable `idx', these indices can be used to retrieve the
other variables in the rows of the table which turn out to be new rows, (as for
example "$sessionid get myMibVarB.$idx"). If several variables in a table are
always going to be retrieved in a table, something like {myMibVarA myMibVarB
myMibVarC myMibVarD} can be substituted for myMibVarA as the second argument
to walk - but if you are using the walk to discover new rows, you may not want
to retreive the variables from rows that are already in the table.

Now, suppose that the index variables for this table are myMibInx1 and
myMibInx2,
that myMibInx1 is the first index variable, and has some specific meaning, like
being an ip address, such that all rows in your table that pertain to some
specific
host have that host's address in myMibVar1 in that row. Modify the above loop
to
start:

$sessionid walk x MyMibVarA.$host {

This will restrict the walk to only rows which concern the host whose ip
address
is in $host - thus using the mib walk as a sort of database query.

> Can somebody help me ? Maybe one example of a code can help.

hope this helps.

/b