On 2 April 2010 17:24, PEOPLES, MICHAEL P (ATTSI) <mp4...@att.com> wrote:
> When you walk that branch of the MIB, get the OID that is pointing to value
> you are trying to get.  You might then have to add “.0” or “.1.0” to the
> snmpget.

Adding ".0" is typically only relevant for scalar objects
(i.e. a MIB object that is not part of a table).

One of the original design decisions of SNMP is that *all* references to
MIB values should include an "index" value (called an "instance subidentifier").
In the case of tables, this indicates which of potentially multiple copies of
this value is required.
   In the case of scalar objects, there can be only one - so the instance
subidentifier is not strictly necessary.

But the SNMP designers decided to require such an "index" value anyway,
for consistency with table values.   So all scalar values automatically have
the instance subidentifier ".0".



> The whole concept of snmp tables is a mystery to me

They're really not that difficult - particularly if you concentrate on simple
tables first, and think about them by analogy with a programming language.
If you were coding a table in C, you might have a data structure

   struct contact {
       char   name[100];
       int      age;
       char   birthday[20];
   }

and then define an address book as an array of such structures:

   struct contact  myContacts[1000];

You could then refer to individual contacts using something like:

    for (i=0; i<numContacts; i++) {
        if ( today == myContacts[i].birthday ) {
           printf("Happy birthday dear %s\n, Happy birthday to you\n",
                    myContacts[i].name);
           myContacts[i].age++;
        }
    }

This uses an integer value (i) to index into the array (myContacts)
and then refers to individual fields within this data structure.


With SNMP, things are much the same, with this data structure being
essentially one row of the table.  The most obvious difference is that
the index comes *after* the field (column) name:

    contactName.{i},   contactAge{i},    contactBDay.{i}


This is similar to having three parallel arrays:

    char contactName[1000][100];
    int  contactAge[1000];
    char contactBDay[1000][20];

(and yes - I should be using defined constants!)



String-indexed tables are less usual in C, but are reasonably common
in languages like Perl ("hashes") where you might easily define a structure
like:

   $month{ "January" } = 31;
   $month{ "February" } = 28;
   $month{ "March" } = 31;
       etc

SNMP might display this information using something like

    monthLen."January" = INTEGER 31
    monthLen."February" = INTEGER 28
    monthLen."March" = INTEGER 31
       etc

which is very similar.

Note that low-down, this would actually be represented using individual
characters for the "instance subidentifiers" (along with the length of the
string).  So this would actually be

    monthLen.5.'M'.'a'.'r'.'c'.'h' = INTEGER 31

(where '5' is the length of the string "March").
  That length subidentifier then has an effect on walking the table,
since short index strings (with a small valued for the length subidentifier)
will come before longer index strings (with a higher value).

But the fundamental idea is very similar to Perl hashes.


More complex tables might have multiple indexes (similar
to multi-dimensional arrays in programming languages).
And there are some situations where a string-index may
not include the length subidentifier.
   But those two probably cover the majority of tables you
are likely to encounter.



Hope this helps.

Dave

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to