User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 426,456 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,240 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 3268 | Replies: 6
Reply
Join Date: Jun 2005
Posts: 17
Reputation: bigfoot_80906 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
bigfoot_80906 bigfoot_80906 is offline Offline
Newbie Poster

Script needed to check OID values

  #1  
Jun 6th, 2005
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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2004
Posts: 21
Reputation: vgersh99 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
vgersh99's Avatar
vgersh99 vgersh99 is offline Offline
Newbie Poster

Re: Script needed to check OID values

  #2  
Jun 6th, 2005
Originally Posted by bigfoot_80906
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
vlad
+-----------------------------------+
| #include <disclaimer.h> |
+-----------------------------------+
Reply With Quote  
Join Date: Jun 2005
Posts: 17
Reputation: bigfoot_80906 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
bigfoot_80906 bigfoot_80906 is offline Offline
Newbie Poster

Re: Script needed to check OID values

  #3  
Jun 7th, 2005
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?
Reply With Quote  
Join Date: Nov 2004
Posts: 21
Reputation: vgersh99 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
vgersh99's Avatar
vgersh99 vgersh99 is offline Offline
Newbie Poster

Re: Script needed to check OID values

  #4  
Jun 7th, 2005
  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.
vlad
+-----------------------------------+
| #include <disclaimer.h> |
+-----------------------------------+
Reply With Quote  
Join Date: Jun 2005
Posts: 17
Reputation: bigfoot_80906 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
bigfoot_80906 bigfoot_80906 is offline Offline
Newbie Poster

Re: Script needed to check OID values

  #5  
Jun 7th, 2005
is the tree I showed normal?
Reply With Quote  
Join Date: Nov 2004
Posts: 21
Reputation: vgersh99 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
vgersh99's Avatar
vgersh99 vgersh99 is offline Offline
Newbie Poster

Re: Script needed to check OID values

  #6  
Jun 7th, 2005
Originally Posted by bigfoot_80906
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.
vlad
+-----------------------------------+
| #include <disclaimer.h> |
+-----------------------------------+
Reply With Quote  
Join Date: Jun 2005
Posts: 17
Reputation: bigfoot_80906 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
bigfoot_80906 bigfoot_80906 is offline Offline
Newbie Poster

Re: Script needed to check OID values

  #7  
Jun 8th, 2005
I guess I was just wondering if there was a standard way of making the MIB trees.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 3:25 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC