|Think about Loose Coupling|
RFC: Who wants to design a better SNMP API?by Hercynium (Hermit)
|on Nov 28, 2007 at 17:28 UTC||Need Help??|
I have what I hope is an interesting proposition for whomever's reading this node!
I am trying to design a distribution for working with SNMP, that I will eventually upload to CPAN. I've been disappointed in one way or another by the API of every SNMP module I've tried, but I haven't given up hope that there can be something better.
Smarter hackers than I have put their hands to this task before, but I still believe there's a better way and I need your help to find it!
Everything in this RFC is up for debate and constructive criticism, and if anyone wishes to collaborate further on this project, I welcome you!
To begin, I have laid out the following terminology:
Some additional notes:
An OID is a way of identifying objects in a MIB. an OID is composed of an array of Octets, represented by integers with a \. between each element. Each object in a MIB has a unique OID, and instances of objects have additional octets on the end that define their identity in relation to their object-type.
There are several types of objects, but only a few can be queried. The queriable object types are scalars and columns, but for the purposes of this we only will consider columns, because scalars are *much* simpler.
Column objects are assembled into groupings called Tables, and tables contain a Table Entry object which defines what indexes are used to construct the instance_id of available Object Instances of the column objects within the table.
These concepts are what SNMP is built on. SNMP is essentially object-oriented, but uses mechanisms and concepts that are (academically) supposed to be straight-forward to implement in C. (they usually aren't) It's both elegantly simple and frustratingly complex, depending on the implementation, much like some programming languages. ;)
With this terminology in mind, I have the following scenarios as 'use cases'for which I am trying to develop a clean, clear, flexible general API.
Objects that I am presenting in these use cases will be specified not using their Numeric OIDs (.126.96.36.199.4.1...) but rather their Symbolic OIDs (textual names defined in the MIB Files)
First, a simple one:
We want to retrieve the full_oid of any ifInOctets objects whose instance_id matches (the instance_ids of all ifType objects whose value is 18) and (the instance_ids of all ifAdminStatus objects whose value is 1)
Second, a more complex one:
We want to retrieve the values of the adMX2820M13NetFuncServState objects that are only provisioned in slots whose adMX2820M13PrvCardPairID value is not blank and does not match '/not in use/i'
If you could write code to implement any of these use cases any way you wished, what would it look like? Pseudo-code is just as welcome as Perl.