I need to write a script that will be able to go down the MIB tree of a device and output the values to either the screen or a .txt file. Any ideas what that would look like, or where I can search for a script to use as a template?

I need to write a script that will be able to go down the MIB tree of a device and output the values to either the screen or a .txt file. Any ideas what that would look like, or where I can search for a script to use as a template?

  1. Translate all the MIB(s) your device supports into a a file of scalar OIDs - one OID per line
  2. Depending on the tools you have [snmpget...] iterate through the OID file executing one snmpget [or whatever] at the time against a device in question
while read OID
do
    snmpget deviceAddress "${OID}"
done < fileWithOIDs

How would you recommend pulling the OID's' out of the MIB file? this is what the tree looks like:
The CP-7600 Enterprise MIB Tree:
iso (1)
|-org (3)
| |-dod (6)
| | |-internet (1)
| | | |-private (4)
| | | | |-enterprises (1)
| | | | | |-terayon (1456)
| | | | | | |-videoProducts (20)
| | | | | | | |-dvsSouth (3)
| | | | | | | | |-cp7600 (3)
| | | | | | | | |-snmpControl (1)
| | | | | | | | | |-communityString (1)
| | | | | | | | | |-trapConfig (2)
This is just a small section of the tree, but the rest looks the same. cp7600 is the top-level that doesn't change. snmpControl is the first of 9 or so sub-categories, and each sub-category has categories within it. Is there any way to write the script without the tree? Maybe start at the top and do snmpgets until it returns a value instead of an error message. Then output the value and the OID in a different file. continue doing this until it finds another errror message, append the OID until it returns another value, and then output that value with its OID to the file. The script would continue to do this until it returns a certain number of error messages. How feasible is this?

  1. if you can [???] create a file MIB file with just FULL OID specification - one OID [to snmpget] per line. Some MIB tools allow you to do that. Having file in this format will greatly simplify the logic
  2. You have a MIB file in the format above - you'll have to write a parser to build your fully-qualified OID spec based on the poasted tree - where the leaves of the tree [scalars] will be your OID AND the 'branches' are the intermeddiate 'hope' of the tree prefixed with multiple '|'. The example of the MIB tree you posted don't contain any scalars - seems it stops at the branches/tables.

Is it doable?
Yes in both scenarios - with bullet item [1] being easier to do.

is the tree I showed normal?

is the tree I showed normal?

'normal' as in opposite of being 'ABnormal'? ;)

This is just one of the possible formats. The other format being the file containg the OIDs one per line.

I guess I was just wondering if there was a standard way of making the MIB trees.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.