Hi Greeting:

    Thanks to Dave I have my agent correctly return the corresponded values for 
each table items. The understanding of what name[*length -1] represent for is 
the key. 
    Just want to check see if the following is reasonable and feasible.

    For example my agent  returned the values for the snmpwalk on the oid of 
moduleID something like -
       (In the var_xxTable after the header_simple_table(); I have  Index = 
name[ *length -1 ];)

    moduleID.1   [interger] 1001
moduleID.2  [integer] 3001

The user desired to see the return values for another table item such as ;
 
[A]
moduleType.1001 [integer]  controller
moduleType.3001 [integer]  collector

...
[B]
Currently my agent return the values as -
moduleType.1 [integer]  controller
moduleType.1 [integer]  collector

I tried to do the following in my code hoping to see some output like [A] in 
the above -

case moduleType:
     If (( index == 1 ) || (index == controller_id))
         { 
Name[ *length -1] = controller_id;  
long_ret = 1; // controller) .....}


I realized it's invalid to modify the instance number for the return value - 
perhaps only 1 and 2 are valid index. In the header_simple_table I specified 
the MAX_VALID_INDEX (the last parameter) to 2. I guess I can change 
MAX_VALID_INDEX to a larger number (said 4000) - even the row number is only 2. 
Can I do that? 
I think what the out put in [A] is doable but I just don't have the knowledge 
yet. 
It seems the user expect to append the returned moduleID to the other  object 
items in the same table so each returned values exactly belonged to that 
moduleID. 
I guess I still can do it with header_simple_table. But it looks a little bit 
odd to give a big range of MAX_VALID_INDEX (for only two row). Is there a 
smarter way to do it? 
[Question # 1]
How to append the result from one table item to another table item as the 
instance index ? Is this valid? If it is valid what is the clean way to do it? 

Luckily the number of instance (row # of the table is fixed. In this case it's 
2) so the value was easily returned in between two index number.
[Question # 2]
What if the row # is not fixed and only known from the polling from a text  
(created by other process) or another resource (share memory, command line, 
etc.)?
I think the header_simple_table() still can handle that according to the 
definition of simple table. The index is within some range, the index is 
integer, etc.   
Under this situation (a max number is given during run time) how the 
var_xxxtable() determine what value (among the collected data from some where 
out side agent) to return?

I appreciate your time and answer.

Thanks,
Jim
-----Original Message-----
From: Jim Su [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 07, 2005 5:04 PM
To: Dave Shield
Cc: Net-Snmp-Users
Subject: RE: iteration of entry in table

Hi Dave;

   Thanks a lot!
   You've gave a very  clear flow of how the header_simple_table works. I will 
read the document  again to comprehend the logic.

Thanks again,
Jim

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Dave Shield
Sent: Thursday, April 07, 2005 4:43 PM
To: Jim Su
Cc: Net-Snmp-Users
Subject: RE: iteration of entry in table

On Wed, 2005-04-06 at 11:29, Jim Su wrote:
> What I'm not clear is how the var_xxxtable() return each instance
> to correlate to the data previous read?

Using the 'name' parameter.
On input, this holds the OID being requested.
On return, this holds the OID of the value being returned.

I presume you've read the documentation in "AGENT.txt" ?


> How the agent correlates the array element to each instance?

Using the last entry in this 'name' array.
All of this is handled by the 'header_simple_table()' call.
So your var_xxxtable routine can start:

    if ( header_simple_table( vp, name, length, exact, var_len,
                              write_method, MAX_ENTRIES)
             != MATCH_SUCCEEDED)
        return NULL;

    index = name[ length-1 ];

and 'index' will hold the index value of the row that you need.



> Yes, the table is indexed by an integer - in this case the moduleId is
> the index. However it can be any integer number set up by user.

Ah - so there can be "gaps" in the indexing, yes?

In which case it's not strictly a "simple table".
(See the description in AGENT.txt).

That doesn't matter - you can still use header_simple_table() to do
most of the work, but you'll have to do a bit more yourself.

Having called 'header_simple_table' and extracted the index (see above),
you'll then need to check whether this particular index value is valid.
If it is, then no problem - continue as before.
If it's not, then:

  - for an "exact" (GET) request, the request can't be
       fulfilled, so return NULL immediately.
  - for an "inexact" (GETNEXT) request, you need to find the
       next index value that *is* valid, and use that instead.
    One way is to keep calling 'header_simple_table' and let
       that do all the work.  Or you could do this yourself.

You'd end up with something like:

    if ( NOT_VALID( index ) ) {
        if ( exact )
            return NULL;     /* GET request */

        while ( NOT_VALID( index ) ) {
            index++;
            if ( index >= MAX_ENTRIES )
                return NULL;  /* No more rows */
        }
        name[length-1] = index;
    }

then continue processing as before.

Dave



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
HW夸)b粗h?+y羕N??v??y?'z汻jwbv楝?,│n?煡?!3諢?傳諲j溣[津??(赭?'!死嘈l飩瓜X砧瘱J^?^J眱須?)??嗓?l〥gr?i?

Reply via email to