<p>I'm querying a bunch of information from cisco switches using SNMP.  For instance, I'm pulling information on neighbors detected using CDP by doing an snmpwalk on .1.3.6.1.4.1.9.9.23</p>

<p>Can I use this OID across different cisco models?  What pitfalls should I be aware of?  To me, I'm a little uneasy about using numeric OIDs - it seems like I should be using a MIB database or something and using the named OIDs, in order to gain cross-device compatibility, but perhaps I'm just imagining the need for that.</p>

[{'answer_id': 65901, 'author': 'Michael Wolfe', 'author_id': 7956, 'author_profile': 'https://Stackoverflow.com/users/7956', 'pm_score': 2, 'selected': False, 'text': '<p>It is very consistent.</p>\n<p>Monitoring tools depend on the consistency and the MIBs produced by Cicso rarely change old values and usually only implement new ones.</p>\n<p>Check out the Cisco <a href="http://tools.cisco.com/Support/SNMP/do/BrowseOID.do?local=en&amp;translate=Translate&amp;objectInput=1.3.6.1.4.1.9.9.23" rel="nofollow noreferrer">OID look up tool</a>.</p>\n<p>Notice how it doesn\'t ask you what product the look up is for.</p>\n<p>-mw</p>\n'}, {'answer_id': 65902, 'author': 'DGentry', 'author_id': 4761, 'author_profile': 'https://Stackoverflow.com/users/4761', 'pm_score': 3, 'selected': True, 'text': '<p>Once a MIB has been published it won\'t move to a new OID. Doing so would break network management tools and cause support calls, which nobody wants. To continue your example, the CDP MIB has been published at Cisco\'s <A HREF="http://tools.cisco.com/Support/SNMP/do/BrowseMIB.do?local=en&amp;step=2&amp;mibName=CISCO-CDP-MIB" rel="nofollow noreferrer">SNMP Object Navigator.</A></p>\n\n<p>For general code cleanliness it would be good to define the OIDs in a central place, especially since you don\'t want to duplicate the full OID for every single table you need to access.</p>\n\n<p>The place you need to be most careful is a unique MIB in a product which Cisco recently acquired. The OID will change, if nothing else to move it into their own Enterprise OID space, but the MIB may also change to conform to Cisco\'s SNMP practices.</p>\n'}, {'answer_id': 73150, 'author': 'Jay', 'author_id': 12479, 'author_profile': 'https://Stackoverflow.com/users/12479', 'pm_score': 0, 'selected': False, 'text': "<ul>\n<li>I would avoid putting in numeric OIDs and instead use 'OID names' and leave that hard work (of translating) to whatever SNMP API you are using. </li>\n</ul>\n\n<p>If that is not possible, then it is okay to use OIDs as they should not change per the SNMP MIB guidelines. Unless the device itself changes but that requires a new MIB anyway which can't reuse old OIDs. </p>\n\n<ul>\n<li>This is obvious, but be sure to look at the attributes of the SNMP MIB variable. Be sure not to query variables that have a status of 'obsolete'.</li>\n</ul>\n\n<p>Jay..</p>\n"}, {'answer_id': 104152, 'author': 'AndrewJFord', 'author_id': 6154, 'author_profile': 'https://Stackoverflow.com/users/6154', 'pm_score': 0, 'selected': False, 'text': '<p>In some cases, using the names instead of the numerical representations can be a serious performance hit due to the need to read and parse the MIB files to get the numerical representations of the OIDs that the lower level libraries need.</p>\n\n<p>For instance, say your using a program to collect something every minute, then loading the MIBs over and over is very inefficient.</p>\n\n<p>As stated by others, once published, the name to numerical mapping will never change, so the fact that you\'re hard-coding stuff into your programs is not really a problem.</p>\n\n<p>If you have access to command line SNMP tools, check out \'<a href="http://www.net-snmp.org/docs/man/snmptranslate.html" rel="nofollow noreferrer">snmptranslate</a>\' for a nice tool to get back and forth from text to numerical OIDs.</p>\n'}, {'answer_id': 104580, 'author': 'Jay', 'author_id': 12479, 'author_profile': 'https://Stackoverflow.com/users/12479', 'pm_score': 0, 'selected': False, 'text': '<p>I think that is a common misconception (about MIB reload each time you resolve a name).  </p>\n\n<p>Most of the SNMP APIs (such as AdventNet, CMU) load the MIBS at startup and after that there is no \'overhead\' of loading MIBs everytime you ask for a \'translation\' from name to oid and vice versa.  What\'s more, some of them cache the results and at that point, there is no difference between name lookups and directly coding the OID.   </p>\n\n<p>This is  a bit similar  to specifying an "IP Address" versus a \'hostname\'.</p>\n'}, {'answer_id': 960162, 'author': 'mas', 'author_id': 19007, 'author_profile': 'https://Stackoverflow.com/users/19007', 'pm_score': 1, 'selected': False, 'text': '<p>The OIDs can vary with hardware but also with firmware version for the same hardware as, over time, the architecture of the management functions can change and require new MIBs. It is worth checking whether any of the OIDs you intend to use are in deprecated MIBs, or become so in the life of the application, as this indicates not only that the MIB could one day be unsupported but also that there is likely to be improved, richer data or access to data. It is also good practice to test management apps against a sample upgraded device as part of the routine testing of firmware updates before widespread deployment. </p>\n\n<p>An example of a change of OID due to a MIB being deprecated is at</p>\n\n<p><a href="http://www.cisco.com/en/US/tech/tk648/tk362/technologies_configuration_example09186a0080094aa6.shtml" rel="nofollow noreferrer">http://www.cisco.com/en/US/tech/tk648/tk362/technologies_configuration_example09186a0080094aa6.shtml</a></p>\n\n<blockquote>\n  <p>"This document shows how to copy a\n  configuration file to and from a Cisco\n  device with the CISCO-CONFIG-COPY-MIB.\n  If you start from Cisco IOS® software\n  release 12.0, or on some devices as\n  early as release 11.2P, Cisco has\n  implemented a new means of Simple\n  Network Management Protocol (SNMP)\n  configuration management with the new\n  CISCO-CONFIG-COPY-MIB. This MIB\n  replaces the deprecated configuration\n  section of the OLD-CISCO-SYSTEM-MIB. "</p>\n</blockquote>\n'}]
['https://Stackoverflow.com/questions/65809', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7548/']