RE: To get a row/column objects - SNMP

This is a discussion on RE: To get a row/column objects - SNMP ; > From: net-snmp-users-bounces@lists.sourceforge.net > [mailto:net-snmp-users-bounces@lists.sourceforge.net] On > Behalf Of Pachiappan D > Sent: Tuesday, July 29, 2008 11:36 AM > I use net-snmp 5.4.1 and am using "snmpgetnext" to retrieve > the table rows/columns. > > To retrieve a row ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: RE: To get a row/column objects

  1. RE: To get a row/column objects

    > From: net-snmp-users-bounces@lists.sourceforge.net
    > [mailto:net-snmp-users-bounces@lists.sourceforge.net] On
    > Behalf Of Pachiappan D
    > Sent: Tuesday, July 29, 2008 11:36 AM


    > I use net-snmp 5.4.1 and am using "snmpgetnext" to retrieve
    > the table rows/columns.
    >
    > To retrieve a row , i did as below,
    > snmpgetnext -v3 -uadmin -lauthNoPriv -aMD5 -Apassword
    > localhost ifTable - gives the first row ( 1st column )
    > IF-MIB::ifIndex.1 = INTEGER: 1
    >
    > snmpgetnext -v3 -uadmin -lauthNoPriv -aMD5 -Apassword
    > localhost ifTable.1 ( Index1 of 3 ) - Need to give the second
    > row (1st column )
    > IF-MIB::ifIndex.1 = INTEGER: 1 ( i am getting the first row
    > again wrongly )
    >
    > Can anyone help me on this?


    The MIB says:

    [SNIP]
    ifTable OBJECT-TYPE
    SYNTAX SEQUENCE OF IfEntry
    MAX-ACCESS not-accessible
    STATUS current
    DESCRIPTION
    "A list of interface entries. The number of entries is
    given by the value of ifNumber."
    ::= { interfaces 2 }
    [/SNIP]

    ...so that's the base of our table. Next:

    [SNIP]
    ifEntry OBJECT-TYPE
    SYNTAX IfEntry
    MAX-ACCESS not-accessible
    STATUS current
    DESCRIPTION
    "An entry containing management information applicable to a
    particular interface."
    INDEX { ifIndex }
    ::= { ifTable 1 }
    [/SNIP]

    You'll see this in every table. Don't ask why - it just has to be there[1]. Note that it attaches to ifTable. After this:

    [SNIP]
    IfEntry ::=
    SEQUENCE {
    ifIndex InterfaceIndex,
    ifDescr DisplayString,
    ifType IANAifType,
    ifMtu Integer32,
    ifSpeed Gauge32,
    ifPhysAddress PhysAddress,
    ifAdminStatus INTEGER,
    ifOperStatus INTEGER,
    ifLastChange TimeTicks,
    ifInOctets Counter32,
    ifInUcastPkts Counter32,
    ifInNUcastPkts Counter32, -- deprecated
    ifInDiscards Counter32,
    ifInErrors Counter32,
    ifInUnknownProtos Counter32,
    ifOutOctets Counter32,
    ifOutUcastPkts Counter32,
    ifOutNUcastPkts Counter32, -- deprecated
    ifOutDiscards Counter32,
    ifOutErrors Counter32,
    ifOutQLen Gauge32, -- deprecated
    ifSpecific OBJECT IDENTIFIER -- deprecated
    }
    [/SNIP]

    This is another if those "don't ask" type of features that must be there[1]. After that:

    [SNIP]
    ifIndex OBJECT-TYPE
    SYNTAX InterfaceIndex
    MAX-ACCESS read-only
    STATUS current
    DESCRIPTION
    "A unique value, greater than zero, for each interface. It
    is recommended that values are assigned contiguously
    starting from 1. The value for each interface sub-layer
    must remain constant at least from one re-initialization of
    the entity's network management system to the next re-
    initialization."
    ::= { ifEntry 1 }
    [/SNIP]

    You will never see one of these objects. Why? Because it's an index (see the INDEX clause of ifEntry), and in SNMP indices are never returned as objects, since they are already included as part of the OID. After that:

    [SNIP]
    ifDescr OBJECT-TYPE
    SYNTAX DisplayString (SIZE (0..255))
    MAX-ACCESS read-only
    STATUS current
    DESCRIPTION
    "A textual string containing information about the
    interface. This string should include the name of the
    manufacturer, the product name and the version of the
    interface hardware/software."
    ::= { ifEntry 2 }
    [/SNIP]

    ...which is the first returnable object. Note that, like ifIndex, this is attached to ifEntry, not ifTable.

    To sum it all up the first returnable object is ifTable.ifEntry.ifDescr, or ifTable.1.2 . If you get next on ifTable, the correct response is ifTable.1.2.(first index). If you get next on ifIndex.1, or ifTable.1.1, the correct response is ifTable.1.2.(first index).

    Note that ifIndex is not guarant3eed to start at 1, nor are values guaranteed to be contiguous.

    You may be interested in the snmptable command.


    HTH,

    Mike


    [1] - Not that you should never ask - it's just not relevant to the immediate problem.

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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/...net-snmp-users


  2. Re: To get a row/column objects

    A minor amendment to what Mike said:

    2008/7/30 Mike Ayers :

    > The MIB says:




    > [SNIP]
    > ifIndex OBJECT-TYPE
    > SYNTAX InterfaceIndex
    > MAX-ACCESS read-only
    > STATUS current
    > DESCRIPTION


    > ::= { ifEntry 1 }
    > [/SNIP]
    >
    > You will never see one of these objects.


    In a well-designed table, this would be true, for exactly the reasons
    Mike outlines:

    > Why? Because it's an index (see the INDEX clause of ifEntry),
    > and in SNMP indices are never returned as objects, since they
    > are already included as part of the OID.


    Unfortunately, the ifTable is a hold-over from the very beginning of
    SNMP, when men were men, women were women, and MIB table
    design was not particularly well understood.

    So this particular index column *does* actually appear in the output
    of the agent. This information is completely redundant, and there's
    no point in returning it like this, but the MAX-ACCESS clause says
    "read-only" so the agent will return it.

    A better designed table would have a MAX-ACCESS clause of
    "not-accessible", and would indeed omit the index column
    altogether.


    So:
    > To sum it all up the first returnable object is ifTable.ifEntry.ifDescr, or ifTable.1.2 .
    > If you get next on ifTable, the correct response is ifTable.1.2.(first index).
    > If you get next on ifIndex.1, or ifTable.1.1, the correct response is ifTable.1.2.(first index).


    *ought* to be true, but isn't.
    The first returnable object is actually ifTable.ifEntry.ifIndex (ifTable.1.1)
    and these GETNEXTs would actually return ifTable.1.1.(first index)

    Dave

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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/...net-snmp-users


  3. RE: To get a row/column objects


    > From: dave.shield@googlemail.com
    > [mailto:dave.shield@googlemail.com] On Behalf Of Dave Shield
    > Sent: Tuesday, July 29, 2008 11:49 PM


    > Unfortunately, the ifTable is a hold-over from the very beginning of
    > SNMP, when men were men, women were women, and MIB table
    > design was not particularly well understood.


    ...and the sheep were relieved!

    > So:
    > > To sum it all up the first returnable object is

    > ifTable.ifEntry.ifDescr, or ifTable.1.2 .
    > > If you get next on ifTable, the correct response is

    > ifTable.1.2.(first index).
    > > If you get next on ifIndex.1, or ifTable.1.1, the correct

    > response is ifTable.1.2.(first index).
    >
    > *ought* to be true, but isn't.
    > The first returnable object is actually
    > ifTable.ifEntry.ifIndex (ifTable.1.1)
    > and these GETNEXTs would actually return ifTable.1.1.(first index)


    Thanks for the clarification. So if the OP performed the second get-next on ifTable.1.1 instead of ifTable.1, the intended result would have been achieved, but, again, it is often better to use snmpgetnext or one of the helper functions like snmptable or snmpwalk than to try to anticipate the next value.


    HTH,

    Mike

    P.S. Naughty crossposting OP! Now both Dave and I have fallen prey to your evil schemes! I shall have my revengessss.... SHIIIIIIRE..... BAGGGINNNSSSSSSSSSSS.....

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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/...net-snmp-users


  4. Re: To get a row/column objects

    2008/7/30 Mike Ayers :
    >> The first returnable object is actually
    >> ifTable.ifEntry.ifIndex (ifTable.1.1)
    >> and these GETNEXTs would actually return ifTable.1.1.(first index)

    >
    > Thanks for the clarification. So if the OP performed the second get-next on
    > ifTable.1.1 instead of ifTable.1, the intended result would have been achieved


    Errr... no.

    ifTable.1.1 is ifIndex, so GETNEXT on ifTable.1.1 would return the value
    of ifIndex.{first} (being the first accessible instance within the table).
    Similarly, GETNEXT on ifTable.1 would also return ifIndex.{first}

    In order to get an entry from the second row of the table (and assuming
    that the first value of ifIndex was 1), you would need to run GETNEXT
    on ifTable.1.1.1 = ifIndex.1

    More generally, if GETNEXT ifTable.1 (or GETNEXT ifTable.1.1)
    returned a value of {N}, then the second index would be retrieved
    by running GETNEXT on ifTable.1.1.{N}


    > it is often better to use snmpgetnext or one of the helper functions
    > like snmptable or snmpwalk than to try to anticipate the next value.


    The simplest way to retrieve the table is to use 'snmptable'
    or 'snmpwalk' - sure.

    Dave

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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/...net-snmp-users


  5. RE: To get a row/column objects


    > From: dave.shield@googlemail.com
    > [mailto:dave.shield@googlemail.com] On Behalf Of Dave Shield
    > Sent: Wednesday, July 30, 2008 2:56 PM


    > > Thanks for the clarification. So if the OP

    > performed the second get-next on
    > > ifTable.1.1 instead of ifTable.1, the intended result would

    > have been achieved
    >
    > Errr... no.
    >
    > ifTable.1.1 is ifIndex, so GETNEXT on ifTable.1.1 would
    > return the value
    > of ifIndex.{first} (being the first accessible instance
    > within the table).
    > Similarly, GETNEXT on ifTable.1 would also return ifIndex.{first}


    DOH! Funny, I *feel* more alert in the morning... *sigh*


    Thanks,

    Mike

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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/...net-snmp-users


+ Reply to Thread