I am designing an SNMPv2 MIB to allow management of a set of resources that come and go over time. Their unique identifier is a string. I will create a table
resourceName resourceDescription resourceAttr1 etc
I see alternatives for the index to this table:
- Add a generated numeric index field
- Use the Name
I'm asking for advice on which alternative to use (or indeed for other options). I have no experience of using SNMP to manage systems in the real world and so I find it hard to evaluate the practical implications of this choice.
Pros and Cons for each:
Generated numeric index
Really simple. Just obtain my list of resources, the index value derives from the position in the sequence.
The index value is not stable over time. The resource list will be alphabetical by Name, so addition of a resource can insert in the middle of the list, deletion will also have the effect of changing the index values of later items in the list.
I see from questions likes this that index instability does cause some problems. The interface interface MIB has been designed to use an artificial, unstable, integer index rather than the unique interface identifier. In that example the instability occurs in the rare case of agent restart, in my case instability occurs much more frequently, whenever a resources is created. So why not use a:
Unique String Index
PROs: It's stable, we access the resource by its name.
CONs: The oid derived from the string index is a string of encoded characters. As decribed here the resulting oid is not readily intelligible.
for example, the only indication of the username “alice” in the usmUserTable of 220.127.116.11 The usmUserTable might be the OID fragment 18.104.22.168.101, representing the ASCII codes for the letters a.l.i.c.e.
worse, SNMPv2 requires that index items be marked as not accessible, and so would not be returned in an SNMP GET - the idea being that the index value is represented in the OID. I suppose I could address that last point by adding an extra column.
My guess is that I should follow the seemingly universal practice of using a numeric index and assume that folks work around the instability. Agreed?